Skip to content

Commit

Permalink
✂ Cut something off
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Aug 23, 2023
1 parent c2b6aed commit 6825419
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
8 changes: 5 additions & 3 deletions common/src/main/java/ziyue/tjmetro/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void set(Boolean value) {
}
};
public static final Key<Boolean> USE_TIANJIN_METRO_FONT = new Key<>("use_tianjin_metro_font", false);
@Deprecated
public static final Key<Boolean> EXPERIMENTAL_MTR_CONFIG_SCREEN = new Key<>("experimental_mtr_config_screen", false);

protected static final Path CONFIG_FILE_PATH = Minecraft.getInstance().gameDirectory.toPath().resolve("config").resolve("tjmetro.json");
Expand Down Expand Up @@ -147,9 +148,9 @@ public static Screen getConfigScreen(boolean hasTimeAndWindControls, boolean use
ConfigCategory categoryTianjinMetro = builder.getOrCreateCategory(Text.translatable("config.category.tjmetro"));
BooleanListEntry booleanMTRFilters = entryBuilder.startBooleanToggle(Text.translatable("config.tjmetro.enable_mtr_filters"), ENABLE_MTR_FILTERS.get()).setDefaultValue(ENABLE_MTR_FILTERS.getDefault()).build();
BooleanListEntry booleanUseTianjinMetroFont = entryBuilder.startBooleanToggle(Text.translatable("config.tjmetro.use_tianjin_metro_font"), USE_TIANJIN_METRO_FONT.get()).setTooltip(Text.translatable("tooltip.tjmetro.use_tianjin_metro_font"), Text.translatable("tooltip.tjmetro.experimental").withStyle(ChatFormatting.YELLOW)).build();
BooleanListEntry booleanExperimentalMTRConfigScreen = entryBuilder.startBooleanToggle(Text.translatable("config.tjmetro.experimental_mtr_config_screen"), EXPERIMENTAL_MTR_CONFIG_SCREEN.get()).setTooltip(Text.translatable("tooltip.tjmetro.mtr_config_screen"), Text.translatable("tooltip.tjmetro.experimental").withStyle(ChatFormatting.YELLOW)).build();
//BooleanListEntry booleanExperimentalMTRConfigScreen = entryBuilder.startBooleanToggle(Text.translatable("config.tjmetro.experimental_mtr_config_screen"), EXPERIMENTAL_MTR_CONFIG_SCREEN.get()).setTooltip(Text.translatable("tooltip.tjmetro.mtr_config_screen"), Text.translatable("tooltip.tjmetro.experimental").withStyle(ChatFormatting.YELLOW)).build();
TextListEntry textFooter = entryBuilder.startTextDescription(FOOTERS.get(new Random().nextInt(FOOTERS.size())).get()).build();
categoryTianjinMetro.addEntry(booleanMTRFilters).addEntry(booleanUseTianjinMetroFont).addEntry(booleanExperimentalMTRConfigScreen).addEntry(textFooter);
categoryTianjinMetro.addEntry(booleanMTRFilters).addEntry(booleanUseTianjinMetroFont)/*.addEntry(booleanExperimentalMTRConfigScreen)*/.addEntry(textFooter);

if (tianjinMetroConfig) builder.setFallbackCategory(categoryTianjinMetro);

Expand All @@ -158,7 +159,7 @@ public static Screen getConfigScreen(boolean hasTimeAndWindControls, boolean use

ENABLE_MTR_FILTERS.set(booleanMTRFilters.getValue());
USE_TIANJIN_METRO_FONT.set(booleanUseTianjinMetroFont.getValue());
EXPERIMENTAL_MTR_CONFIG_SCREEN.set(booleanExperimentalMTRConfigScreen.getValue());
//EXPERIMENTAL_MTR_CONFIG_SCREEN.set(booleanExperimentalMTRConfigScreen.getValue());
});
return builder.build();
}
Expand Down Expand Up @@ -233,6 +234,7 @@ public T getDefault() {
}
}

@Deprecated
public enum LanguageOptions
{
DEFAULT(0),
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/ziyue/tjmetro/TianjinMetro.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void init(
/* SIGNS */
registerEnchantedBlockItem.accept("station_name_sign_1", BlockList.STATION_NAME_SIGN_1, SIGNS);
/* DECORATION */
registerEnchantedBlockItem.accept("decoration_light", BlockList.DECORATION_LIGHT, DECORATION);
// registerEnchantedBlockItem.accept("decoration_light", BlockList.DECORATION_LIGHT, DECORATION);
/* CEILINGS */
registerEnchantedBlockItem.accept("ceiling", BlockList.STATION_COLOR_CEILING, CEILINGS);
registerEnchantedBlockItem.accept("ceiling_light", BlockList.STATION_COLOR_CEILING_LIGHT, CEILINGS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ protected ConfigScreenMixin(Component title) {
}

@Override
public boolean hasTimeAndWindControls() {
public boolean tianjin_Metro$hasTimeAndWindControls() {
return hasTimeAndWindControls;
}

@Override
public boolean useTimeAndWindSync() {
public boolean tianjin_Metro$useTimeAndWindSync() {
return useTimeAndWindSync;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -39,6 +40,7 @@
@Mixin(CreativeModeInventoryScreen.class)
public abstract class CreativeModeInventoryScreenMixin extends EffectRenderingInventoryScreen<CreativeModeInventoryScreen.ItemPickerMenu> implements CreativeModeInventoryScreenProperties
{
@Unique
private static final ResourceLocation ICONS = new ResourceLocation(Reference.MOD_ID, "textures/gui/filters.png");

@Shadow
Expand All @@ -63,9 +65,9 @@ protected void beforeRender(PoseStack poseStack, int i, int j, float f, Callback
Filter.FILTERS.forEach((map, filter1) -> showButtons(filter1, false));
Filter.FILTERS.forEach((map, filter) -> filter.forEach(button -> button.visible = false));

if (!Filter.isTabHasFilters(getSelectedTab())) return;
if (!Filter.isTabHasFilters(tianjin_Metro$getSelectedTab())) return;
updateItems();
Filter.FilterList filter = Filter.FILTERS.get(getSelectedTab());
Filter.FilterList filter = Filter.FILTERS.get(tianjin_Metro$getSelectedTab());
showButtons(filter, true);
for (int o = 0; o < filter.size(); o++) {
if ((o >= filter.filterIndex) && (o < filter.filterIndex + 4)) {
Expand All @@ -80,9 +82,9 @@ protected void beforeRender(PoseStack poseStack, int i, int j, float f, Callback

@Inject(at = @At("TAIL"), method = "render")
protected void afterRender(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) {
if (!Filter.isTabHasFilters(getSelectedTab())) return;
if (!Filter.isTabHasFilters(tianjin_Metro$getSelectedTab())) return;

Filter.FilterList filter = Filter.FILTERS.get(getSelectedTab());
Filter.FilterList filter = Filter.FILTERS.get(tianjin_Metro$getSelectedTab());
if (filter.btnScrollUp.isHovered()) renderTooltip(poseStack, filter.btnScrollUp.getMessage(), i, j);
if (filter.btnScrollDown.isHovered()) renderTooltip(poseStack, filter.btnScrollDown.getMessage(), i, j);
if (filter.btnEnableAll.isHovered()) renderTooltip(poseStack, filter.btnEnableAll.getMessage(), i, j);
Expand All @@ -98,8 +100,8 @@ protected void afterInit(CallbackInfo ci) {
Filter.FILTERS.forEach((map, filter) -> {
filter.btnScrollUp = new IconButton(this.leftPos - 22, this.topPos - 12, Text.translatable("button.tjmetro.scroll_up").withStyle(ChatFormatting.WHITE), button -> filter.filterIndex--, ICONS, 0, 0);
filter.btnScrollDown = new IconButton(this.leftPos - 22, this.topPos + 127, Text.translatable("button.tjmetro.scroll_down").withStyle(ChatFormatting.WHITE), button -> filter.filterIndex++, ICONS, 16, 0);
filter.btnEnableAll = new IconButton(this.leftPos - 50, this.topPos + 10, Text.translatable("button.tjmetro.enable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(getSelectedTab()).forEach(filter1 -> filter1.enabled = true), ICONS, 32, 0);
filter.btnDisableAll = new IconButton(this.leftPos - 50, this.topPos + 32, Text.translatable("button.tjmetro.disable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(getSelectedTab()).forEach(filter1 -> filter1.enabled = false), ICONS, 48, 0);
filter.btnEnableAll = new IconButton(this.leftPos - 50, this.topPos + 10, Text.translatable("button.tjmetro.enable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(tianjin_Metro$getSelectedTab()).forEach(filter1 -> filter1.enabled = true), ICONS, 32, 0);
filter.btnDisableAll = new IconButton(this.leftPos - 50, this.topPos + 32, Text.translatable("button.tjmetro.disable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(tianjin_Metro$getSelectedTab()).forEach(filter1 -> filter1.enabled = false), ICONS, 48, 0);
filter.btnOptions = new IconButton(this.leftPos - 50, this.topPos + 54, Text.translatable("button.tjmetro.tianjin_metro_options").withStyle(ChatFormatting.WHITE), button -> minecraft.setScreen(Config.getConfigScreen()), ICONS, 64, 0);
addButton(filter.btnScrollUp);
addButton(filter.btnScrollDown);
Expand All @@ -111,6 +113,7 @@ protected void afterInit(CallbackInfo ci) {
});
}

@Unique
protected void showButtons(Filter.FilterList list, boolean visible) {
if (list.size() > 4) {
list.btnScrollUp.visible = visible;
Expand All @@ -124,10 +127,11 @@ protected void showButtons(Filter.FilterList list, boolean visible) {
list.btnOptions.visible = visible;
}

@Unique
protected void updateItems() {
visibleTags.clear();
menu.items.clear(); // clear the tab
Filter.FILTERS.get(getSelectedTab()).forEach(
Filter.FILTERS.get(tianjin_Metro$getSelectedTab()).forEach(
filter -> {
if (filter.enabled) {
filter.items.forEach(item -> menu.items.add(new ItemStack(item))); // add items
Expand All @@ -142,7 +146,7 @@ protected void updateItems() {
}

@Override
public int getSelectedTab() {
public int tianjin_Metro$getSelectedTab() {
return selectedTab;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* @see ConfigScreenProperties
* @since beta-1
*/

@Deprecated
@Mixin(Minecraft.class)
public abstract class MinecraftMixin extends ReentrantBlockableEventLoop<Runnable> implements SnooperPopulator, WindowEventHandler
{
Expand All @@ -37,7 +39,7 @@ public MinecraftMixin(String string) {
private void beforeSetScreen(Screen screen, CallbackInfo ci) {
if (Config.EXPERIMENTAL_MTR_CONFIG_SCREEN.get()) {
if (screen instanceof ConfigScreenProperties properties) {
this.setScreen(Config.getConfigScreen(properties.hasTimeAndWindControls(), properties.useTimeAndWindSync(), false));
this.setScreen(Config.getConfigScreen(properties.tianjin_Metro$hasTimeAndWindControls(), properties.tianjin_Metro$useTimeAndWindSync(), false));
ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public interface ConfigScreenProperties
{
boolean hasTimeAndWindControls();
boolean tianjin_Metro$hasTimeAndWindControls();

boolean useTimeAndWindSync();
boolean tianjin_Metro$useTimeAndWindSync();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

public interface CreativeModeInventoryScreenProperties
{
int getSelectedTab();
int tianjin_Metro$getSelectedTab();
}

0 comments on commit 6825419

Please sign in to comment.