mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
MidnightLib 1.5.5
- Fixed button always being visible - Various visual improvements
This commit is contained in:
18
build.gradle
18
build.gradle
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
|
||||
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||
}
|
||||
|
||||
architectury {
|
||||
@@ -36,7 +37,22 @@ allprojects {
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 17
|
||||
options.release = 21
|
||||
}
|
||||
ext {
|
||||
releaseChangelog = {
|
||||
def changes = new StringBuilder()
|
||||
changes << "## MidnightLib v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/MidnightLib/commits/)"
|
||||
def proc = "git log --max-count=1 --pretty=format:%s".execute()
|
||||
proc.in.eachLine { line ->
|
||||
def processedLine = line.toString()
|
||||
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
|
||||
changes << "\n- ${processedLine.capitalize()}"
|
||||
}
|
||||
}
|
||||
proc.waitFor()
|
||||
return changes.toString()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
@@ -26,23 +26,24 @@ public class MixinOptionsScreen extends Screen {
|
||||
@Unique TextIconButtonWidget button = TextIconButtonWidget.builder(Text.translatable("midnightlib.overview.title"), (
|
||||
buttonWidget) -> Objects.requireNonNull(client).setScreen(new MidnightConfigOverviewScreen(this)), true)
|
||||
.texture(new Identifier("midnightlib","icon/midnightlib"), 16, 16).dimension(20, 20).build();
|
||||
@Unique boolean shouldShowButton = MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.TRUE) || (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.MODMENU) && !PlatformFunctions.isModLoaded("modmenu"));
|
||||
|
||||
protected MixinOptionsScreen(Text title) {super(title);}
|
||||
@Inject(at = @At("HEAD"), method = "init")
|
||||
public void midnightlib$onInit(CallbackInfo ci) {
|
||||
this.midnightlib$setupButton();
|
||||
this.addDrawableChild(button);
|
||||
if (shouldShowButton) {
|
||||
this.midnightlib$setupButton();
|
||||
this.addDrawableChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(MinecraftClient client, int width, int height) {
|
||||
super.resize(client, width, height);
|
||||
this.midnightlib$setupButton();
|
||||
if (shouldShowButton) this.midnightlib$setupButton();
|
||||
}
|
||||
@Unique
|
||||
public void midnightlib$setupButton() {
|
||||
if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.TRUE) || (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.MODMENU) && !PlatformFunctions.isModLoaded("modmenu"))) {
|
||||
button.setPosition(layout.getWidth() / 2 + 158, layout.getY() + layout.getFooterHeight() - 4);
|
||||
}
|
||||
button.setPosition(layout.getWidth() / 2 + 158, layout.getY() + layout.getFooterHeight() - 4);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class MidnightConfigOverviewScreen extends Screen {
|
||||
protected void init() {
|
||||
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> Objects.requireNonNull(client).setScreen(parent)).dimensions(this.width / 2 - 100, this.height - 26, 200, 20).build());
|
||||
|
||||
this.list = new MidnightConfig.MidnightConfigListWidget(this.client, this.width, this.height - 64, 24, 25);
|
||||
this.list = new MidnightConfig.MidnightConfigListWidget(this.client, this.width, this.height - 57, 24, 25);
|
||||
this.addSelectableChild(this.list);
|
||||
List<String> sortedMods = new ArrayList<>(MidnightConfig.configClass.keySet());
|
||||
Collections.sort(sortedMods);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -167,7 +168,7 @@ public abstract class MidnightConfig {
|
||||
info.value = isNumber? value : s;
|
||||
else if (inLimits) {
|
||||
if (((List<String>) info.value).size() == info.index) ((List<String>) info.value).add("");
|
||||
((List<String>) info.value).set(info.index, Arrays.stream(info.tempValue.replace("[", "").replace("]", "").split(", ")).toList().get(0));
|
||||
((List<String>) info.value).set(info.index, Arrays.stream(info.tempValue.replace("[", "").replace("]", "").split(", ")).toList().getFirst());
|
||||
}
|
||||
|
||||
if (info.field.getAnnotation(Entry.class).isColor()) {
|
||||
@@ -303,7 +304,7 @@ public abstract class MidnightConfig {
|
||||
Objects.requireNonNull(client).setScreen(parent);
|
||||
}).dimensions(this.width / 2 + 4, this.height - 26, 150, 20).build());
|
||||
|
||||
this.list = new MidnightConfigListWidget(this.client, this.width, this.height - 64, 24, 25);
|
||||
this.list = new MidnightConfigListWidget(this.client, this.width, this.height - 57, 24, 25);
|
||||
this.addSelectableChild(this.list);
|
||||
|
||||
fillList();
|
||||
@@ -383,17 +384,30 @@ public abstract class MidnightConfig {
|
||||
super.render(context,mouseX,mouseY,delta);
|
||||
this.list.render(context, mouseX, mouseY, delta);
|
||||
|
||||
if (tabs.size() < 2) context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFF);
|
||||
if (tabs.size() < 2)
|
||||
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFF);
|
||||
list.renderHeaderSeperator = tabs.size() < 2;
|
||||
}
|
||||
}
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class MidnightConfigListWidget extends ElementListWidget<ButtonEntry> {
|
||||
boolean renderHeaderSeperator = true;
|
||||
public MidnightConfigListWidget(MinecraftClient client, int width, int height, int y, int itemHeight) {
|
||||
super(client, width, height, y, itemHeight);
|
||||
}
|
||||
@Override
|
||||
public int getScrollbarX() { return this.width -7; }
|
||||
|
||||
@Override
|
||||
protected void drawHeaderAndFooterSeparators(DrawContext context) {
|
||||
if (renderHeaderSeperator) super.drawHeaderAndFooterSeparators(context);
|
||||
else {
|
||||
RenderSystem.enableBlend();
|
||||
context.drawTexture(this.client.world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE, this.getX(), this.getBottom(), 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
}
|
||||
|
||||
public void addButton(List<ClickableWidget> buttons, Text text, EntryInfo info) {
|
||||
this.addEntry(new ButtonEntry(buttons, text, info));
|
||||
}
|
||||
@@ -406,20 +420,22 @@ public abstract class MidnightConfig {
|
||||
public final List<ClickableWidget> buttons;
|
||||
private final Text text;
|
||||
public final EntryInfo info;
|
||||
public boolean centered = false;
|
||||
public static final Map<ClickableWidget, Text> buttonsWithText = new HashMap<>();
|
||||
|
||||
private ButtonEntry(List<ClickableWidget> buttons, Text text, EntryInfo info) {
|
||||
if (!buttons.isEmpty()) buttonsWithText.put(buttons.get(0),text);
|
||||
public ButtonEntry(List<ClickableWidget> buttons, Text text, EntryInfo info) {
|
||||
if (!buttons.isEmpty()) buttonsWithText.put(buttons.getFirst(),text);
|
||||
this.buttons = buttons;
|
||||
this.text = text;
|
||||
this.info = info;
|
||||
if (info != null) this.centered = info.centered;
|
||||
}
|
||||
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
buttons.forEach(b -> { b.setY(y); b.render(context, mouseX, mouseY, tickDelta); });
|
||||
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty())) {
|
||||
int wrappedY = y;
|
||||
for(Iterator<OrderedText> textIterator = textRenderer.wrapLines(text, (buttons.size() > 1 ? buttons.get(1).getX()-24 : MinecraftClient.getInstance().getWindow().getScaledWidth() - 24)).iterator(); textIterator.hasNext(); wrappedY += 9) {
|
||||
context.drawTextWithShadow(textRenderer, textIterator.next(), (info.centered) ? (MinecraftClient.getInstance().getWindow().getScaledWidth() / 2 - (textRenderer.getWidth(text) / 2)) : 12, wrappedY + 5, 0xFFFFFF);
|
||||
context.drawTextWithShadow(textRenderer, textIterator.next(), (centered) ? (MinecraftClient.getInstance().getWindow().getScaledWidth() / 2 - (textRenderer.getWidth(text) / 2)) : 12, wrappedY + 5, 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
id "me.shedaniel.unified-publishing"
|
||||
}
|
||||
repositories {
|
||||
maven { url "https://maven.terraformersmc.com/releases" }
|
||||
@@ -63,16 +64,38 @@ components.java {
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
unifiedPublishing {
|
||||
project {
|
||||
displayName = "MidnightLib v$project.version - Fabric $project.minecraft_version"
|
||||
releaseType = "$project.release_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = []
|
||||
gameLoaders = ["fabric","quilt"]
|
||||
mainPublication remapJar
|
||||
relations {
|
||||
depends {
|
||||
curseforge = "fabric-api"
|
||||
modrinth = "fabric-api"
|
||||
}
|
||||
}
|
||||
|
||||
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||
if (CURSEFORGE_TOKEN != null) {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", project.minecraft_version
|
||||
}
|
||||
}
|
||||
|
||||
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||
if (MODRINTH_TOKEN != null) {
|
||||
modrinth {
|
||||
token = MODRINTH_TOKEN
|
||||
id = rootProject.modrinth_id
|
||||
version = "$project.version-$project.name"
|
||||
gameVersions.addAll project.minecraft_version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
org.gradle.jvmargs=-Xmx4096M
|
||||
|
||||
minecraft_version=1.20.5-rc2
|
||||
yarn_mappings=1.20.5-rc2+build.2
|
||||
minecraft_version=1.20.6
|
||||
yarn_mappings=1.20.6+build.1
|
||||
enabled_platforms=fabric
|
||||
|
||||
archives_base_name=midnightlib
|
||||
mod_version=1.5.4
|
||||
mod_version=1.5.5
|
||||
maven_group=eu.midnightdust
|
||||
release_type=release
|
||||
curseforge_id=488090
|
||||
modrinth_id=codAaoxh
|
||||
|
||||
fabric_loader_version=0.15.10
|
||||
fabric_api_version=0.97.4+1.20.5
|
||||
fabric_loader_version=0.15.11
|
||||
fabric_api_version=0.97.8+1.20.6
|
||||
|
||||
neoforge_version=20.4.12-beta
|
||||
neoforge_version=20.6.30-beta
|
||||
|
||||
quilt_loader_version=0.19.0-beta.18
|
||||
quilt_fabric_api_version=7.0.1+0.83.0-1.20
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -23,6 +23,6 @@ public class PlatformFunctionsImpl {
|
||||
return ModList.get().isLoaded(modid);
|
||||
}
|
||||
public static void registerCommand(LiteralArgumentBuilder<ServerCommandSource> command) {
|
||||
// Ignored here, see MidnightLibServerEvents#registerCommands
|
||||
// Ignored here, see MidnightLibNeoForge#registerCommands
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,13 +38,6 @@ public class MidnightLibNeoForge {
|
||||
});
|
||||
}
|
||||
}
|
||||
@Mod.EventBusSubscriber(modid = "midnightlib", value = Dist.CLIENT)
|
||||
public static class MidnightLibClientEvents {
|
||||
@SubscribeEvent
|
||||
public static void afterInitScreen(ScreenEvent.Init.Post event) {
|
||||
MidnightConfigOverviewScreen.addButtonToOptionsScreen(event.getScreen(), event.getScreen().getMinecraft());
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = "midnightlib", value = Dist.DEDICATED_SERVER)
|
||||
public static class MidnightLibServerEvents {
|
||||
|
||||
Reference in New Issue
Block a user