Class StringSetting
java.lang.Object
com.minecolonies.core.colony.buildings.modules.settings.StringSetting
- All Implemented Interfaces:
ISetting<String>,IStringSetting<String>
- Direct Known Subclasses:
BeekeeperCollectionSetting,BuilderModeSetting,StringSettingWithDesc
Stores a string-list setting (Like enum, but easily serializable).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intCurrent index of the setting.static final intThe maximum possible width of the trigger button. -
Constructor Summary
ConstructorsConstructorDescriptionStringSetting(String... settings) Create a new string list setting.StringSetting(List<String> settings, int currentIndex) Create a new string list setting. -
Method Summary
Modifier and TypeMethodDescriptionvoidCopy value from another instance.protected intgetButtonWidth(ISettingsModuleView settingsModuleView) Get the width to render the button at.intGet the current index of the setting.Get the default value.protected net.minecraft.network.chat.ComponentGet the text to render on the button, defaults to the stored index value.net.minecraft.resources.ResourceLocationGet the resource location of the view you want to use for this setting.Get the list of all settings.getValue()Get the setting value.booleanisIndexAllowed(int index) voidrender(ISettingKey<?> key, com.ldtteam.blockui.Pane pane, ICommonSettingsModule settingsModuleView, IBuildingView building, com.ldtteam.blockui.views.BOWindow window) Update the handling (e.g update settings text).voidSet the setting to a specific index.voidsetupHandler(ISettingKey<?> key, com.ldtteam.blockui.Pane pane, ICommonSettingsModule settingsModuleView, IBuildingView building, com.ldtteam.blockui.views.BOWindow window) Add the handling of the specific setting to the box in the UI.voidtrigger()Trigger a setting.voidupdateSetting(ISetting<?> setting) Allow updating a setting with new data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.buildings.modules.settings.ISetting
getInactiveReason, getToolTipText, isActive, isActive, onUpdate, setHoverPane, shouldHideWhenInactive
-
Field Details
-
MAX_BUTTON_WIDTH
public static final int MAX_BUTTON_WIDTHThe maximum possible width of the trigger button.- See Also:
-
currentIndex
protected int currentIndexCurrent index of the setting.
-
-
Constructor Details
-
StringSetting
Create a new string list setting.- Parameters:
settings- the overall list of settings.
-
StringSetting
Create a new string list setting.- Parameters:
settings- the overall list of settings.currentIndex- the current selected index.
-
-
Method Details
-
getValue
Description copied from interface:IStringSettingGet the setting value. -
getDefault
Description copied from interface:IStringSettingGet the default value.- Specified by:
getDefaultin interfaceIStringSetting<String>- Returns:
- the default value.
-
getCurrentIndex
public int getCurrentIndex()Description copied from interface:IStringSettingGet the current index of the setting.- Specified by:
getCurrentIndexin interfaceIStringSetting<String>- Returns:
- the index.
-
getSettings
Description copied from interface:IStringSettingGet the list of all settings.- Specified by:
getSettingsin interfaceIStringSetting<String>- Returns:
- a copy of the list.
-
getLayoutItem
public net.minecraft.resources.ResourceLocation getLayoutItem()Description copied from interface:ISettingGet the resource location of the view you want to use for this setting.- Specified by:
getLayoutItemin interfaceISetting<String>- Returns:
- the resource location indicating which view to use.
-
setupHandler
public void setupHandler(ISettingKey<?> key, com.ldtteam.blockui.Pane pane, ICommonSettingsModule settingsModuleView, IBuildingView building, com.ldtteam.blockui.views.BOWindow window) Description copied from interface:ISettingAdd the handling of the specific setting to the box in the UI.- Specified by:
setupHandlerin interfaceISetting<String>- Parameters:
key- the key of the setting.pane- the pane of it.settingsModuleView- the module view that holds the setting.building- the building.window- the calling window.
-
render
public void render(ISettingKey<?> key, com.ldtteam.blockui.Pane pane, ICommonSettingsModule settingsModuleView, IBuildingView building, com.ldtteam.blockui.views.BOWindow window) Description copied from interface:ISettingUpdate the handling (e.g update settings text). -
getDisplayText
protected net.minecraft.network.chat.Component getDisplayText()Get the text to render on the button, defaults to the stored index value.- Returns:
- the component to render on the button.
-
trigger
public void trigger()Description copied from interface:ISettingTrigger a setting. -
isIndexAllowed
public boolean isIndexAllowed(int index) -
updateSetting
Description copied from interface:ISettingAllow updating a setting with new data.- Specified by:
updateSettingin interfaceISetting<String>- Parameters:
setting- the setting with new data
-
copyValue
Description copied from interface:ISettingCopy value from another instance. -
set
Description copied from interface:IStringSettingSet the setting to a specific index.- Specified by:
setin interfaceIStringSetting<String>- Parameters:
value- the value to set.
-
getButtonWidth
Get the width to render the button at. This can be at most 145, to leave adequate spacing.- Parameters:
settingsModuleView- the module view that holds the setting.- Returns:
- the width.
-