AbstractTabbedConfigScreen.java 1.1 KB

123456789101112131415161718192021222324252627282930
  1. package me.shedaniel.clothconfig2.gui;
  2. import com.google.common.collect.Maps;
  3. import me.shedaniel.clothconfig2.api.TabbedConfigScreen;
  4. import net.minecraft.client.gui.screen.Screen;
  5. import net.minecraft.text.Text;
  6. import net.minecraft.util.Identifier;
  7. import java.util.Map;
  8. public abstract class AbstractTabbedConfigScreen extends AbstractConfigScreen implements TabbedConfigScreen {
  9. private final Map<Text, Identifier> categoryBackgroundLocation = Maps.newHashMap();
  10. protected AbstractTabbedConfigScreen(Screen parent, Text title, Identifier backgroundLocation) {
  11. super(parent, title, backgroundLocation);
  12. }
  13. @Override
  14. public final void registerCategoryBackground(Text text, Identifier identifier) {
  15. this.categoryBackgroundLocation.put(text, identifier);
  16. }
  17. @Override
  18. public Identifier getBackgroundLocation() {
  19. Text selectedCategory = getSelectedCategory();
  20. if (categoryBackgroundLocation.containsKey(selectedCategory))
  21. return categoryBackgroundLocation.get(selectedCategory);
  22. return super.getBackgroundLocation();
  23. }
  24. }