Centralise code for config GUI category classes
This commit is contained in:
@@ -24,57 +24,57 @@ public class GuiConfigWizardry extends GuiConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<IConfigElement> getConfigEntries(){
|
private static List<IConfigElement> getConfigEntries(){
|
||||||
|
|
||||||
List<IConfigElement> configList = new ArrayList<IConfigElement>(1);
|
List<IConfigElement> configList = new ArrayList<IConfigElement>(1);
|
||||||
configList.add(new DummyCategoryElement("spellsConfig", "config." + Wizardry.MODID + ".category." + Settings.SPELLS_CATEGORY,
|
|
||||||
SpellsCategory.class));
|
configList.add(new DummyCategoryElement("spellsConfig", "config." + Wizardry.MODID + ".category." + Settings.SPELLS_CATEGORY, SpellsCategory.class));
|
||||||
configList.add(new DummyCategoryElement("resistancesConfig",
|
configList.add(new DummyCategoryElement("resistancesConfig", "config." + Wizardry.MODID + ".category." + Settings.RESISTANCES_CATEGORY, ResistancesCategory.class));
|
||||||
"config." + Wizardry.MODID + ".category." + Settings.RESISTANCES_CATEGORY, ResistancesCategory.class));
|
|
||||||
configList.addAll(new ConfigElement(Wizardry.settings.getConfigCategory(Configuration.CATEGORY_GENERAL))
|
configList.addAll(new ConfigElement(Wizardry.settings.getConfigCategory(Configuration.CATEGORY_GENERAL)).getChildElements());
|
||||||
.getChildElements());
|
|
||||||
return configList;
|
return configList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Spells category of the config gui. This adds a button which opens up the spells category config. */
|
// The reason this system is so convoluted is that it's designed for use with the @Config annotation. The problem is,
|
||||||
public static class SpellsCategory extends CategoryEntry {
|
// I'm not sure whether that will play well with the load phases. Hmmm...
|
||||||
public SpellsCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop){
|
|
||||||
|
public static abstract class CategoryBase extends CategoryEntry {
|
||||||
|
|
||||||
|
private final String category;
|
||||||
|
|
||||||
|
public CategoryBase(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop, String category){
|
||||||
super(owningScreen, owningEntryList, prop);
|
super(owningScreen, owningEntryList, prop);
|
||||||
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GuiScreen buildChildScreen(){
|
protected GuiScreen buildChildScreen(){
|
||||||
// This GuiConfig object specifies the configID of the object and as such will force-save when it is closed.
|
// This GuiConfig object specifies the configID of the object and as such will force-save when it is closed.
|
||||||
// The parent GuiConfig object's entryList will also be refreshed to reflect the changes.
|
// The parent GuiConfig object's entryList will also be refreshed to reflect the changes.
|
||||||
GuiConfig spellsMenu = new GuiConfig(this.owningScreen,
|
GuiConfig childScreen = new GuiConfig(this.owningScreen,
|
||||||
(new ConfigElement(Wizardry.settings.getConfigCategory(Settings.SPELLS_CATEGORY)))
|
(new ConfigElement(Wizardry.settings.getConfigCategory(category))).getChildElements(),
|
||||||
.getChildElements(),
|
this.owningScreen.modID, category, false, false,
|
||||||
this.owningScreen.modID, Settings.SPELLS_CATEGORY, false, false,
|
Wizardry.NAME + " - " + I18n.format("config." + Wizardry.MODID + ".title." + category));
|
||||||
Wizardry.NAME + " - " + I18n.format("config." + Wizardry.MODID + ".title." + Settings.SPELLS_CATEGORY));
|
|
||||||
|
|
||||||
spellsMenu.titleLine2 = I18n.format("config." + Wizardry.MODID + ".subtitle." + Settings.SPELLS_CATEGORY);
|
childScreen.titleLine2 = I18n.format("config." + Wizardry.MODID + ".subtitle." + category);
|
||||||
|
|
||||||
return spellsMenu;
|
return childScreen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resistances category of the config gui. */
|
/** Resistances category of the config gui. */
|
||||||
public static class ResistancesCategory extends CategoryEntry {
|
public static class SpellsCategory extends CategoryBase {
|
||||||
public ResistancesCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop){
|
|
||||||
super(owningScreen, owningEntryList, prop);
|
public SpellsCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop){
|
||||||
|
super(owningScreen, owningEntryList, prop, Settings.SPELLS_CATEGORY);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
/** Resistances category of the config gui. */
|
||||||
protected GuiScreen buildChildScreen(){
|
public static class ResistancesCategory extends CategoryBase {
|
||||||
// This GuiConfig object specifies the configID of the object and as such will force-save when it is closed.
|
|
||||||
// The parent GuiConfig object's entryList will also be refreshed to reflect the changes.
|
|
||||||
GuiConfig idsMenu = new GuiConfig(this.owningScreen,
|
|
||||||
(new ConfigElement(Wizardry.settings.getConfigCategory(Settings.RESISTANCES_CATEGORY)))
|
|
||||||
.getChildElements(),
|
|
||||||
this.owningScreen.modID, Settings.RESISTANCES_CATEGORY, false, false,
|
|
||||||
Wizardry.NAME + " - " + I18n.format("config." + Wizardry.MODID + ".title." + Settings.RESISTANCES_CATEGORY));
|
|
||||||
|
|
||||||
idsMenu.titleLine2 = I18n.format("config." + Wizardry.MODID + ".subtitle." + Settings.RESISTANCES_CATEGORY);
|
public ResistancesCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop){
|
||||||
|
super(owningScreen, owningEntryList, prop, Settings.RESISTANCES_CATEGORY);
|
||||||
return idsMenu;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user