Skip to content

Commit

Permalink
1.19.2 backport (#551)
Browse files Browse the repository at this point in the history
* Update to 22w43a (#496)

* Add accessor to access game menu buttons

* Fix Curseforge version

* Add 1.19.3 branch to Crowdin

* [1.19.3] Validate modpack mods correctly (#506)

- Fixed modpack badge being added to builtin mods

* Update to 1.19.3

* Add several translation keys for mods to use (#503)

Added two donation platforms (`GitHub Sponsors` and `PayPal`) plus a generic `Donate`, also `Mastodon` to compliment `Twitter`

* Update 1.19.3 translations (#508)

- Updated translations

Co-authored-by: Crowdin Bot <[email protected]>

* Update actions

* Update actions again

* Fix pause screen crash

- Fixed a crash on the pause screen

* Update 1.19.3 translations (#515)

Co-authored-by: Crowdin Bot <[email protected]>

* Allow default descriptions for Minecraft and Java to be translated

- Use translation keys for default Minecraft and Java descriptions

* Update credits

- Update Mod Menu credits list

* Generate more pleasant colors for the built in "java" mod (#529)

Co-authored-by: Jab125 <[email protected]>

- Give builtin "java" mod more pleasing random background colors

* Update 1.19.3 translations

- Updated translations

* Change fabric dummy mod to use fabric-api

* Refactor translated mod descriptions and summaries, add translatable mod names

- Allow mod names to be localized
- Added an option to disable the random colors of the builtin 'java' mod
- Added options to disable mod name and description localization.
- Builtin 'java' mod is now named "Java" with vendor details in the description

* Add 1.19.4 to crowdin workflow

* Add config mode and minor refactors

* Fix java background, add hidden configs

- Add "Config mode" option for modpack creators
- Add option for modpack creators to hide specific mods' config menus

* Fix search bar width

* Update 1.19.3 translations (#536)

Co-authored-by: Crowdin Bot <[email protected]>

* Update 1.19.3 translations (#543)

Co-authored-by: Crowdin Bot <[email protected]>

* Add update checker (#546)

Co-authored-by: Pyrrha Wills <[email protected]>
- Added Modrinth mod update checker

* Add updates search term

* s

* Add the library badge to Fabric Language Kotlin

* Fix quilt support for mod update checker

* missing file oops

* Revert "missing file oops"

This reverts commit 63d4617.

* Fix update checker making hundreds of API requests

- Added config for modpack authors to disable specific mods' update checkers

* Backport to 1.19.2.

* small fixes

* Fix missing translation for update indicator option

* Fix quilt mod discarding hash from superclass, checking bundled mods (#552)


- Fix hash checking sometimes disregarded on Quilt

---------

Co-authored-by: Benjamin Norton <[email protected]>
Co-authored-by: jackassmc <[email protected]>
Co-authored-by: haykam821 <[email protected]>
Co-authored-by: Jab125 <[email protected]>
Co-authored-by: triphora <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Crowdin Bot <[email protected]>
Co-authored-by: Prospector <[email protected]>
Co-authored-by: Prospector <[email protected]>
Co-authored-by: Lilly Rose Berner <[email protected]>
  • Loading branch information
11 people authored Feb 17, 2023
1 parent abab194 commit 3dfa13c
Show file tree
Hide file tree
Showing 176 changed files with 3,301 additions and 568 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
max-parallel: 1
matrix:
branch: ["1.17", "1.18", "1.19"]
branch: ["1.17", "1.18", "1.19", "1.19.3", "1.19.4"]
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.0-SNAPSHOT'
}

apply from: 'https://raw.githubusercontent.com/TerraformersMC/GradleScripts/2.5/ferry.gradle'
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ maven_group=com.terraformersmc
archive_name=modmenu

minecraft_version=1.19.2
yarn_mappings=1.19.2+build.1
loader_version=0.14.8
fabric_version=0.58.6+1.19.2
quilt_loader_version=0.17.1
yarn_mappings=1.19.2+build.28
loader_version=0.14.13
fabric_version=0.73.2+1.19.2
quilt_loader_version=0.17.7

# Project Metadata
project_name=Mod Menu
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/com/terraformersmc/modmenu/ModMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.terraformersmc.modmenu.config.ModMenuConfig;
import com.terraformersmc.modmenu.config.ModMenuConfigManager;
import com.terraformersmc.modmenu.event.ModMenuEventHandler;
import com.terraformersmc.modmenu.util.ModrinthUtil;
import com.terraformersmc.modmenu.util.mod.Mod;
import com.terraformersmc.modmenu.util.mod.fabric.FabricDummyParentMod;
import com.terraformersmc.modmenu.util.mod.fabric.FabricMod;
Expand All @@ -26,29 +27,31 @@
import org.slf4j.LoggerFactory;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.Supplier;

public class ModMenu implements ClientModInitializer {
public static final String MOD_ID = "modmenu";
public static final String GITHUB_REF = "TerraformersMC/ModMenu";
public static final Logger LOGGER = LoggerFactory.getLogger("Mod Menu");
public static final Gson GSON = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setPrettyPrinting().create();
public static final Gson GSON_MINIFIED = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();

public static final Map<String, Mod> MODS = new HashMap<>();
public static final Map<String, Mod> ROOT_MODS = new HashMap<>();
public static final LinkedListMultimap<Mod, Mod> PARENT_MAP = LinkedListMultimap.create();
public static boolean modUpdateAvailable = false;

private static ImmutableMap<String, ConfigScreenFactory<?>> configScreenFactories = ImmutableMap.of();
private static List<Supplier<Map<String, ConfigScreenFactory<?>>>> dynamicScreenFactories = new ArrayList<>();

private static int cachedDisplayedModCount = -1;
public static boolean runningQuilt = false;

public static Screen getConfigScreen(String modid, Screen menuScreen) {
if (ModMenuConfig.HIDDEN_CONFIGS.getValue().contains(modid)) {
return null;
}
ConfigScreenFactory<?> factory = configScreenFactories.get(modid);
if (factory != null) {
return factory.create(menuScreen);
Expand All @@ -65,6 +68,7 @@ public static Screen getConfigScreen(String modid, Screen menuScreen) {
@Override
public void onInitializeClient() {
ModMenuConfigManager.initializeConfig();
runningQuilt = FabricLoader.getInstance().isModLoaded("quilt_loader");
Map<String, ConfigScreenFactory<?>> factories = new HashMap<>();
Set<String> modpackMods = new HashSet<>();
FabricLoader.getInstance().getEntrypointContainers("modmenu", ModMenuApi.class).forEach(entrypoint -> {
Expand All @@ -85,16 +89,20 @@ public void onInitializeClient() {
// Fill mods map
for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
if (!ModMenuConfig.HIDDEN_MODS.getValue().contains(modContainer.getMetadata().getId())) {
if(FabricLoader.getInstance().isModLoaded("quilt_loader")){
if (ModMenu.runningQuilt) {
QuiltMod mod = new QuiltMod(modContainer, modpackMods);
MODS.put(mod.getId(), mod);
}else {
} else {
FabricMod mod = new FabricMod(modContainer, modpackMods);
MODS.put(mod.getId(), mod);
}
}
}

if (ModMenuConfig.UPDATE_CHECKER.getValue()) {
ModrinthUtil.checkForUpdates();
}

Map<String, Mod> dummyParents = new HashMap<>();

// Initialize parent map
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/com/terraformersmc/modmenu/config/ModMenuConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,29 @@ public class ModMenuConfig {
public static final BooleanConfigOption MODIFY_TITLE_SCREEN = new BooleanConfigOption("modify_title_screen", true);
public static final BooleanConfigOption MODIFY_GAME_MENU = new BooleanConfigOption("modify_game_menu", true);
public static final BooleanConfigOption HIDE_CONFIG_BUTTONS = new BooleanConfigOption("hide_config_buttons", false);
public static final BooleanConfigOption RANDOM_JAVA_COLORS = new BooleanConfigOption("random_java_colors", true);
public static final BooleanConfigOption TRANSLATE_NAMES = new BooleanConfigOption("translate_names", true);
public static final BooleanConfigOption TRANSLATE_DESCRIPTIONS = new BooleanConfigOption("translate_descriptions", true);
public static final BooleanConfigOption CONFIG_MODE = new BooleanConfigOption("config_mode", false);
public static final BooleanConfigOption DISABLE_DRAG_AND_DROP = new BooleanConfigOption("disable_drag_and_drop", false);
public static final StringSetConfigOption HIDDEN_MODS = new StringSetConfigOption("hidden_mods", new HashSet<>());
public static final StringSetConfigOption HIDDEN_CONFIGS = new StringSetConfigOption("hidden_configs", new HashSet<>());
public static final StringSetConfigOption DISABLE_UPDATE_CHECKER = new StringSetConfigOption("disable_update_checker", new HashSet<>());
public static final BooleanConfigOption UPDATE_CHECKER = new BooleanConfigOption("update_checker", true);
public static final BooleanConfigOption BUTTON_UPDATE_BADGE = new BooleanConfigOption("button_update_badge", true);

public static SimpleOption<?>[] asOptions() {
ArrayList<SimpleOption<?>> options = new ArrayList<>();
for (Field field : ModMenuConfig.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && OptionConvertable.class.isAssignableFrom(field.getType()) && !field.getName().equals("HIDE_CONFIG_BUTTONS") && !field.getName().equals("MODIFY_TITLE_SCREEN") && !field.getName().equals("MODIFY_GAME_MENU")) {
if (Modifier.isStatic(field.getModifiers())
&& Modifier.isFinal(field.getModifiers())
&& OptionConvertable.class.isAssignableFrom(field.getType())
&& !field.getName().equals("HIDE_CONFIG_BUTTONS")
&& !field.getName().equals("MODIFY_TITLE_SCREEN")
&& !field.getName().equals("MODIFY_GAME_MENU")
&& !field.getName().equals("CONFIG_MODE")
&& !field.getName().equals("DISABLE_DRAG_AND_DROP")
) {
try {
options.add(((OptionConvertable) field.get(null)).asOption());
} catch (IllegalAccessException e) {
Expand All @@ -50,7 +67,7 @@ public static SimpleOption<?>[] asOptions() {

public enum Sorting {
@SerializedName("ascending")
ASCENDING(Comparator.comparing(mod -> mod.getName().toLowerCase(Locale.ROOT))),
ASCENDING(Comparator.comparing(mod -> mod.getTranslatedName().toLowerCase(Locale.ROOT))),
@SerializedName("descending")
DESCENDING(ASCENDING.getComparator().reversed());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.terraformersmc.modmenu.gui.ModsScreen;
import com.terraformersmc.modmenu.gui.widget.ModMenuButtonWidget;
import com.terraformersmc.modmenu.gui.widget.ModMenuTexturedButtonWidget;
import com.terraformersmc.modmenu.util.ModrinthUtil;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
Expand Down Expand Up @@ -33,7 +34,7 @@ public static void register() {
"key.modmenu.open_menu",
InputUtil.Type.KEYSYM,
InputUtil.UNKNOWN_KEY.getCode(),
"category.modmenu.name"
"key.categories.misc"
));
ClientTickEvents.END_CLIENT_TICK.register(ModMenuEventHandler::onClientEndTick);

Expand Down Expand Up @@ -84,10 +85,11 @@ private static void afterTitleScreenInit(Screen screen) {
} else if (ModMenuConfig.MODS_BUTTON_STYLE.getValue() == ModMenuConfig.ModsButtonStyle.SHRINK) {
buttons.add(modsButtonIndex, new ModMenuButtonWidget(screen.width / 2 + 2, buttonsY, 98, 20, ModMenuApi.createModsButtonText(), screen));
} else if (ModMenuConfig.MODS_BUTTON_STYLE.getValue() == ModMenuConfig.ModsButtonStyle.ICON) {
buttons.add(modsButtonIndex, new ModMenuTexturedButtonWidget(screen.width / 2 + 104, buttonsY, 20, 20, 0, 0, FABRIC_ICON_BUTTON_LOCATION, 32, 64, button -> MinecraftClient.getInstance().setScreen(new ModsScreen(screen)), ModMenuApi.createModsButtonText()));
buttons.add(modsButtonIndex, new ModMenuTexturedButtonWidget(screen.width / 2 + 104, buttonsY, 20, 20, 0, 0, FABRIC_ICON_BUTTON_LOCATION, 32, 64, button -> MinecraftClient.getInstance().setScreen(new ModsScreen(screen)), ModMenuApi.createModsButtonText(), true));
}
}
}
ModrinthUtil.triggerV2DeprecatedToast();
}

private static void afterGameMenuScreenInit(Screen screen) {
Expand Down Expand Up @@ -123,7 +125,7 @@ private static void afterGameMenuScreenInit(Screen screen) {
if (style == ModMenuConfig.ModsButtonStyle.CLASSIC) {
buttons.add(modsButtonIndex, new ModMenuButtonWidget(screen.width / 2 - 102, buttonsY + spacing, 204, 20, ModMenuApi.createModsButtonText(), screen));
} else if (style == ModMenuConfig.ModsButtonStyle.ICON) {
buttons.add(modsButtonIndex, new ModMenuTexturedButtonWidget(screen.width / 2 + 4 + 100 + 2, screen.height / 4 + 72 + -16, 20, 20, 0, 0, FABRIC_ICON_BUTTON_LOCATION, 32, 64, button -> MinecraftClient.getInstance().setScreen(new ModsScreen(screen)), ModMenuApi.createModsButtonText()));
buttons.add(modsButtonIndex, new ModMenuTexturedButtonWidget(screen.width / 2 + 4 + 100 + 2, screen.height / 4 + 72 - 16, 20, 20, 0, 0, FABRIC_ICON_BUTTON_LOCATION, 32, 64, button -> MinecraftClient.getInstance().setScreen(new ModsScreen(screen)), ModMenuApi.createModsButtonText()));
}
}
}
Expand All @@ -145,7 +147,7 @@ private static void shiftButtons(ClickableWidget button, boolean shiftUp, int sp
if (shiftUp) {
button.y -= spacing / 2;
} else if (!button.getMessage().equals(TitleScreen.COPYRIGHT)) {
button.y += spacing - (spacing / 2);
button.y += spacing / 2;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ protected void init() {
this.list = new ButtonListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
this.list.addAll(ModMenuConfig.asOptions());
this.addSelectableChild(this.list);
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 27, 200, 20, ScreenTexts.DONE, (button) -> {
ModMenuConfigManager.save();
this.client.setScreen(this.previous);
}));
this.addDrawableChild(
new ButtonWidget(
this.width / 2 - 100, this.height - 27,
200, 20,
ScreenTexts.DONE, (button) -> {
ModMenuConfigManager.save();
this.client.setScreen(this.previous);
}
));
}

public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
Expand All @@ -45,7 +50,6 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (list != null) {
this.renderOrderedTooltip(matrices, list, mouseX, mouseY);
}

}

public void removed() {
Expand Down
Loading

0 comments on commit 3dfa13c

Please sign in to comment.