java.lang.Object
com.minecolonies.core.colony.buildings.modules.settings.StringSetting
All Implemented Interfaces:
ISetting<String>, IStringSetting<String>
Direct Known Subclasses:
BeekeeperCollectionSetting, BuilderModeSetting, StringSettingWithDesc

public class StringSetting extends Object implements IStringSetting<String>
Stores a string-list setting (Like enum, but easily serializable).
  • Field Details

    • MAX_BUTTON_WIDTH

      public static final int MAX_BUTTON_WIDTH
      The maximum possible width of the trigger button.
      See Also:
    • currentIndex

      protected int currentIndex
      Current index of the setting.
  • Constructor Details

    • StringSetting

      public StringSetting(String... settings)
      Create a new string list setting.
      Parameters:
      settings - the overall list of settings.
    • StringSetting

      public StringSetting(List<String> settings, int currentIndex)
      Create a new string list setting.
      Parameters:
      settings - the overall list of settings.
      currentIndex - the current selected index.
  • Method Details

    • getValue

      public String getValue()
      Description copied from interface: IStringSetting
      Get the setting value.
      Specified by:
      getValue in interface ISetting<String>
      Specified by:
      getValue in interface IStringSetting<String>
      Returns:
      the current value.
    • getDefault

      public String getDefault()
      Description copied from interface: IStringSetting
      Get the default value.
      Specified by:
      getDefault in interface IStringSetting<String>
      Returns:
      the default value.
    • getCurrentIndex

      public int getCurrentIndex()
      Description copied from interface: IStringSetting
      Get the current index of the setting.
      Specified by:
      getCurrentIndex in interface IStringSetting<String>
      Returns:
      the index.
    • getSettings

      public List<String> getSettings()
      Description copied from interface: IStringSetting
      Get the list of all settings.
      Specified by:
      getSettings in interface IStringSetting<String>
      Returns:
      a copy of the list.
    • getLayoutItem

      public net.minecraft.resources.ResourceLocation getLayoutItem()
      Description copied from interface: ISetting
      Get the resource location of the view you want to use for this setting.
      Specified by:
      getLayoutItem in interface ISetting<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: ISetting
      Add the handling of the specific setting to the box in the UI.
      Specified by:
      setupHandler in interface ISetting<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: ISetting
      Update the handling (e.g update settings text).
      Specified by:
      render in interface ISetting<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.
    • 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: ISetting
      Trigger a setting.
      Specified by:
      trigger in interface ISetting<String>
    • isIndexAllowed

      public boolean isIndexAllowed(int index)
    • updateSetting

      public void updateSetting(ISetting<?> setting)
      Description copied from interface: ISetting
      Allow updating a setting with new data.
      Specified by:
      updateSetting in interface ISetting<String>
      Parameters:
      setting - the setting with new data
    • copyValue

      public void copyValue(ISetting<?> setting)
      Description copied from interface: ISetting
      Copy value from another instance.
      Specified by:
      copyValue in interface ISetting<String>
      Parameters:
      setting - the setting to copy from
    • set

      public void set(String value)
      Description copied from interface: IStringSetting
      Set the setting to a specific index.
      Specified by:
      set in interface IStringSetting<String>
      Parameters:
      value - the value to set.
    • getButtonWidth

      protected int getButtonWidth(ISettingsModuleView settingsModuleView)
      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.