Browse Source

Refresh button (fixes #3), update to 1.15.2

master
Martmists 2 months ago
parent
commit
6f2146f6c8
5 changed files with 32 additions and 9 deletions
  1. +5
    -5
      gradle.properties
  2. +8
    -2
      src/main/java/com/martmists/customtitlescreen/CustomTitleScreenMod.java
  3. +10
    -0
      src/main/java/com/martmists/customtitlescreen/buttons/RefreshButton.java
  4. +2
    -1
      src/main/java/com/martmists/customtitlescreen/mixin/AbstractButtonWidgetMixin.java
  5. +7
    -1
      src/main/java/com/martmists/customtitlescreen/mixin/TitleScreenMixin.java

+ 5
- 5
gradle.properties View File

@@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx4G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.15.1
yarn_mappings=1.15.1+build.17
loader_version=0.7.2+build.175
minecraft_version=1.15.2
yarn_mappings=1.15.2+build.2
loader_version=0.7.5+build.178

#Fabric api
api_version=0.4.26+build.283-1.15
api_version=0.4.29+build.290-1.15

# Mod Properties
mod_version = 1.15-0.0.5
mod_version = 1.15.2-0.1.0
maven_group = com.martmists
archives_base_name = customtitlescreen

+ 8
- 2
src/main/java/com/martmists/customtitlescreen/CustomTitleScreenMod.java View File

@@ -20,8 +20,14 @@ public class CustomTitleScreenMod implements ClientModInitializer {

@Override
public void onInitializeClient() {
config = ConfigManager.loadConfig(CTSConfig.class);
buttonConfig = ConfigManager.loadConfig(ButtonConfig.class);
loadConfig();
System.out.println("CustomMainMenu initialized!");
}

public static void loadConfig(){
CustomTitleScreenMod.allButtons = new ArrayList<>();
CustomTitleScreenMod.buttonCache = new IdentityHashMap<>();
CustomTitleScreenMod.config = ConfigManager.loadConfig(CTSConfig.class);
CustomTitleScreenMod.buttonConfig = ConfigManager.loadConfig(ButtonConfig.class);
}
}

+ 10
- 0
src/main/java/com/martmists/customtitlescreen/buttons/RefreshButton.java View File

@@ -0,0 +1,10 @@
package com.martmists.customtitlescreen.buttons;

import com.martmists.customtitlescreen.CustomTitleScreenMod;
import net.minecraft.client.gui.widget.ButtonWidget;

public class RefreshButton extends ButtonWidget {
public RefreshButton(int i, int j, int k, int l, String string) {
super(i, j, k, l, string, (ButtonWidget x)->CustomTitleScreenMod.loadConfig());
}
}

+ 2
- 1
src/main/java/com/martmists/customtitlescreen/mixin/AbstractButtonWidgetMixin.java View File

@@ -14,6 +14,7 @@ import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.texture.TextureUtil;
import net.minecraft.util.Identifier;
import org.lwjgl.stb.STBTTFontinfo;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -56,7 +57,7 @@ public class AbstractButtonWidgetMixin extends DrawableHelper {
try {
byteBuffer = TextureUtil.readResource(new FileInputStream(f));
render.setFonts(Lists.newArrayList(new Font[]{
new TrueTypeFont(TrueTypeFont.getSTBTTFontInfo(byteBuffer), 11.0f, 1.0f, 0f, 0f, "")
new TrueTypeFont(byteBuffer, STBTTFontinfo.malloc(), 11.0f, 1.0f, 0f, 0f, "")
}));
return render;
} catch (IOException e) {


+ 7
- 1
src/main/java/com/martmists/customtitlescreen/mixin/TitleScreenMixin.java View File

@@ -2,6 +2,7 @@ package com.martmists.customtitlescreen.mixin;

import com.martmists.customtitlescreen.CustomTitleScreenMod;
import com.martmists.customtitlescreen.buttons.LanguagesButton;
import com.martmists.customtitlescreen.buttons.RefreshButton;
import com.martmists.customtitlescreen.config.SingleButtonConfig;
import com.martmists.customtitlescreen.buttons.UrlButton;
import net.fabricmc.loader.api.FabricLoader;
@@ -19,7 +20,6 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.io.*;
@@ -115,6 +115,12 @@ class TitleScreenMixin extends Screen {
CustomTitleScreenMod.buttonCache.put(button, key);
break;
}
case "refresh": {
RefreshButton button = new RefreshButton(CustomTitleScreenMod.screenWidth / 2 + value.x, value.y - (360 - CustomTitleScreenMod.screenHeight), value.width, value.height, value.text);
this.addButton(button);
CustomTitleScreenMod.buttonCache.put(button, key);
break;
}
default: {
System.out.println("[CMM] Error: Unknown button type: " + value.type);
}


Loading…
Cancel
Save