-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
216 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
src/main/java/com/thatmg393/usefulhuds/config/gui/ModClothConfigScreen.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/main/java/com/thatmg393/usefulhuds/config/gui/clothconfig/ModClothConfigScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.thatmg393.usefulhuds.config.gui.clothconfig; | ||
|
||
import com.thatmg393.usefulhuds.UsefulHUDs; | ||
import com.thatmg393.usefulhuds.config.ModConfigManager; | ||
import com.thatmg393.usefulhuds.config.gui.clothconfig.categories.FPSCategory; | ||
import com.thatmg393.usefulhuds.config.gui.clothconfig.categories.STDCategory; | ||
|
||
import me.shedaniel.clothconfig2.api.ConfigBuilder; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.text.Text; | ||
|
||
public class ModClothConfigScreen { | ||
public static Screen getConfigGui(Screen parent) { | ||
ConfigBuilder configBuilder = ConfigBuilder.create(); | ||
configBuilder.setParentScreen(parent); | ||
configBuilder.setTitle(Text.of("cOnFIG")); // FIXME: Use Text.translatable() instead | ||
configBuilder.setSavingRunnable(() -> { | ||
UsefulHUDs.LOGGER.info("Saving configs..."); | ||
ModConfigManager.saveConfig(); | ||
}); | ||
|
||
new FPSCategory().build(configBuilder); | ||
new STDCategory().build(configBuilder); | ||
|
||
return configBuilder.build(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ain/java/com/thatmg393/usefulhuds/config/gui/clothconfig/base/AbstractConfigCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.thatmg393.usefulhuds.config.gui.clothconfig.base; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.thatmg393.usefulhuds.config.ModConfigManager; | ||
import com.thatmg393.usefulhuds.config.data.ModConfigData; | ||
|
||
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; | ||
import me.shedaniel.clothconfig2.api.ConfigBuilder; | ||
import me.shedaniel.clothconfig2.api.ConfigCategory; | ||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; | ||
import net.minecraft.text.Text; | ||
|
||
public abstract class AbstractConfigCategory { | ||
public final Text title; | ||
|
||
public final ConfigEntryBuilder entryBuilder = ConfigEntryBuilder.create(); | ||
|
||
public final ModConfigData config; | ||
public final ModConfigData defaultConfig; | ||
|
||
public AbstractConfigCategory(Text title) { | ||
this.title = title; | ||
this.config = ModConfigManager.loadConfig(); | ||
this.defaultConfig = ModConfigManager.getDefaultConfig(); | ||
} | ||
|
||
@SuppressWarnings("rawtypes") | ||
public abstract ArrayList<AbstractConfigListEntry> getEntries(); | ||
|
||
public void build(ConfigBuilder configBuilder) { | ||
ConfigCategory cc = configBuilder.getOrCreateCategory(title); | ||
getEntries().stream().parallel() | ||
.forEach(e -> cc.addEntry(e)); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../java/com/thatmg393/usefulhuds/config/gui/clothconfig/base/AbstractConfigSubCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.thatmg393.usefulhuds.config.gui.clothconfig.base; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.thatmg393.usefulhuds.config.data.ModConfigData; | ||
|
||
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; | ||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; | ||
import me.shedaniel.clothconfig2.gui.entries.SubCategoryListEntry; | ||
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder; | ||
import net.minecraft.text.Text; | ||
|
||
public abstract class AbstractConfigSubCategory { | ||
public final Text title; | ||
public final ConfigEntryBuilder entryBuilder; | ||
|
||
public final ModConfigData config; | ||
public final ModConfigData defaultConfig; | ||
|
||
public AbstractConfigSubCategory(Text title, AbstractConfigCategory cc) { | ||
this.title = title; | ||
this.entryBuilder = cc.entryBuilder; | ||
this.config = cc.config; | ||
this.defaultConfig = cc.defaultConfig; | ||
} | ||
|
||
public AbstractConfigSubCategory(Text title, AbstractConfigSubCategory csc) { | ||
this.title = title; | ||
this.entryBuilder = csc.entryBuilder; | ||
this.config = csc.config; | ||
this.defaultConfig = csc.defaultConfig; | ||
} | ||
|
||
public abstract ArrayList<AbstractConfigListEntry> getEntries(); | ||
|
||
public SubCategoryListEntry build() { | ||
SubCategoryBuilder scle = entryBuilder.startSubCategory(title); | ||
scle.addAll(getEntries()); | ||
return scle.build(); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/com/thatmg393/usefulhuds/config/gui/clothconfig/categories/FPSCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.thatmg393.usefulhuds.config.gui.clothconfig.categories; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.thatmg393.usefulhuds.config.gui.clothconfig.base.AbstractConfigCategory; | ||
import com.thatmg393.usefulhuds.config.gui.clothconfig.base.AbstractConfigSubCategory; | ||
|
||
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; | ||
import net.minecraft.text.Text; | ||
|
||
public class FPSCategory extends AbstractConfigCategory { | ||
public class SubCategory extends AbstractConfigSubCategory { | ||
public SubCategory() { | ||
super(Text.of("Advanced"), FPSCategory.this); | ||
} | ||
|
||
@Override | ||
public ArrayList<AbstractConfigListEntry> getEntries() { | ||
ArrayList<AbstractConfigListEntry> entries = new ArrayList<>(); | ||
|
||
entries.add( | ||
entryBuilder.startBooleanToggle( | ||
Text.of("Show MinAvgMax"), | ||
config.FPS.ADVANCED.showAdvanceInfo | ||
).setDefaultValue(defaultConfig.FPS.ADVANCED.showAdvanceInfo) | ||
.setSaveConsumer(v -> config.FPS.ADVANCED.showAdvanceInfo = v) | ||
.build() | ||
); | ||
|
||
return entries; | ||
} | ||
} | ||
|
||
private SubCategory ADVANCED = new SubCategory(); | ||
|
||
public FPSCategory() { | ||
super(Text.of("FPS")); | ||
} | ||
|
||
@Override | ||
public ArrayList<AbstractConfigListEntry> getEntries() { | ||
ArrayList<AbstractConfigListEntry> entries = new ArrayList<>(); | ||
|
||
entries.add( | ||
entryBuilder.startBooleanToggle( | ||
Text.of("Show HUD"), | ||
config.FPS.showHud | ||
).setDefaultValue(defaultConfig.FPS.showHud) | ||
.setSaveConsumer(nv -> config.FPS.showHud = nv) | ||
.build() | ||
); | ||
|
||
entries.add( | ||
entryBuilder.startColorField( | ||
Text.of("HUD Text Color"), | ||
config.FPS.textColor | ||
).setDefaultValue(defaultConfig.FPS.textColor) | ||
.setSaveConsumer(nv -> config.FPS.textColor = nv) | ||
.build() | ||
); | ||
|
||
entries.add(ADVANCED.build()); | ||
return entries; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/thatmg393/usefulhuds/config/gui/clothconfig/categories/STDCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.thatmg393.usefulhuds.config.gui.clothconfig.categories; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.thatmg393.usefulhuds.config.gui.clothconfig.base.AbstractConfigCategory; | ||
|
||
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; | ||
import net.minecraft.text.Text; | ||
|
||
public class STDCategory extends AbstractConfigCategory { | ||
public STDCategory() { | ||
super(Text.of("SprintToggleDisplay")); | ||
} | ||
|
||
@Override | ||
public ArrayList<AbstractConfigListEntry> getEntries() { | ||
ArrayList<AbstractConfigListEntry> entries = new ArrayList<>(); | ||
|
||
entries.add( | ||
entryBuilder.startBooleanToggle( | ||
Text.of("Show HUD"), | ||
config.STD.showHud | ||
).setDefaultValue(defaultConfig.STD.showHud) | ||
.setSaveConsumer(v -> config.STD.showHud = v) | ||
.build() | ||
); | ||
|
||
entries.add( | ||
entryBuilder.startColorField( | ||
Text.of("Text Color"), | ||
config.STD.textColor | ||
).setDefaultValue(config.STD.textColor) | ||
.setSaveConsumer(v -> config.STD.textColor = v) | ||
.build() | ||
); | ||
|
||
return entries; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/com/thatmg393/usefulhuds/config/integrations/ModMenuIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters