Adding spotless
This commit is contained in:
1 parent
a726886ee7
commit
200574fd56
29 files changed
+1030
-1511
No files matched your search
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) $YEAR DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
@@ -44,6 +44,12 @@ Many features to completely change the way how to message in Minecraft.
|
||||
- Show amount of unread messages
|
||||
- Easily export and share tabs with others
|
||||
|
||||
## Development
|
||||
|
||||
To develop, all dependencies should automatically be processed through gradle. To ensure code consistency the hook pre-commit.sh can be used. To install the pre-commit hook run:
|
||||
|
||||
`ln -s ../../pre-commit.sh .git/hooks/pre-commit`
|
||||
|
||||
## Credits n' more
|
||||
|
||||
Code & Mastermind: DarkKronicle
|
||||
|
||||
+57
-51
@@ -1,7 +1,8 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '0.8-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id "io.freefair.lombok" version "6.0.0-m2"
|
||||
id 'fabric-loom' version '0.8-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id "io.freefair.lombok" version "6.0.0-m2"
|
||||
id "com.diffplug.spotless" version "5.17.1"
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_16
|
||||
@@ -15,76 +16,81 @@ minecraft {
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://masa.dy.fi/maven' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
mavenCentral()
|
||||
maven { url 'https://masa.dy.fi/maven' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
//Fabric api
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
|
||||
modImplementation "fi.dy.masa.malilib:malilib-fabric-1.17.0:${project.malilib_version}"
|
||||
|
||||
modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}"
|
||||
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
modImplementation "fi.dy.masa.malilib:malilib-fabric-1.17.1:${project.malilib_version}"
|
||||
modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
// If Javadoc is generated, this must be specified in that task too.
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
// Minecraft 1.17 (21w19a) upwards uses Java 16.
|
||||
it.options.release = 16
|
||||
it.options.encoding = "UTF-8"
|
||||
it.options.release = 16
|
||||
}
|
||||
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this task, sources will not be generated.
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = "sources"
|
||||
from sourceSets.main.allSource
|
||||
classifier = "sources"
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
jar {
|
||||
from "LICENSE"
|
||||
from "LICENSE.txt"
|
||||
}
|
||||
|
||||
spotless {
|
||||
ratchetFrom 'origin/main'
|
||||
format 'misc', {
|
||||
// define the files to apply `misc` to
|
||||
target '*.gradle', '*.md', '.gitignore'
|
||||
|
||||
// define the steps to apply to those files
|
||||
trimTrailingWhitespace()
|
||||
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
|
||||
endWithNewline()
|
||||
}
|
||||
java {
|
||||
target 'src/*/java/**/*.java'
|
||||
googleJavaFormat('1.12.0').aosp().reflowLongStrings()
|
||||
removeUnusedImports()
|
||||
licenseHeaderFile "HEADER.txt"
|
||||
}
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// select the repositories you want to publish to
|
||||
repositories {
|
||||
// uncomment to publish to the local maven
|
||||
// mavenLocal()
|
||||
}
|
||||
// select the repositories you want to publish to
|
||||
repositories {
|
||||
// uncomment to publish to the local maven
|
||||
// mavenLocal()
|
||||
}
|
||||
}
|
||||
+9
-11
@@ -1,16 +1,14 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version=1.17.1
|
||||
yarn_mappings=1.17.1+build.37
|
||||
loader_version=0.11.6
|
||||
# Mod Properties
|
||||
yarn_mappings=1.17.1+build.40
|
||||
loader_version=0.12.3
|
||||
mod_version=1.0.0
|
||||
maven_group=io.github.darkkronicle
|
||||
archives_base_name=AdvancedChatHUD
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
fabric_api_version=0.37.2+1.17
|
||||
malilib_version = 0.10.0-dev.22+beta.1
|
||||
fabric_api_version=0.41.0+1.17
|
||||
malilib_version = 0.10.0-dev.26
|
||||
org.gradle.jvmargs=-Xmx1G --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
advancedchat_version=1.1.0-beta1
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
./gradlew spotlessApply
|
||||
+8
-8
@@ -1,10 +1,10 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud;
|
||||
|
||||
import fi.dy.masa.malilib.MaLiLib;
|
||||
import fi.dy.masa.malilib.event.InitializationHandler;
|
||||
import io.github.darkkronicle.advancedchathud.tabs.MainChatTab;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
@@ -19,8 +25,6 @@ public class AdvancedChatHud implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// This will run after AdvancedChatCore's because of load order
|
||||
InitializationHandler
|
||||
.getInstance()
|
||||
.registerInitializationHandler(new HudInitHandler());
|
||||
InitializationHandler.getInstance().registerInitializationHandler(new HudInitHandler());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud;
|
||||
|
||||
import io.github.darkkronicle.advancedchatcore.chat.ChatMessage;
|
||||
@@ -13,12 +20,9 @@ import net.fabricmc.api.Environment;
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class HudChatMessage {
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private List<AbstractChatTab> tabs;
|
||||
@Setter @Getter private List<AbstractChatTab> tabs;
|
||||
|
||||
@Getter
|
||||
private final ChatMessage message;
|
||||
@Getter private final ChatMessage message;
|
||||
|
||||
public HudChatMessage(ChatMessage message) {
|
||||
this(message, new ArrayList<>());
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud;
|
||||
|
||||
import io.github.darkkronicle.advancedchatcore.chat.ChatMessage;
|
||||
@@ -13,8 +20,7 @@ import net.fabricmc.api.Environment;
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class HudChatMessageHolder implements IChatMessageProcessor {
|
||||
|
||||
@Getter
|
||||
private final List<HudChatMessage> messages = new ArrayList<>();
|
||||
@Getter private final List<HudChatMessage> messages = new ArrayList<>();
|
||||
|
||||
private static final HudChatMessageHolder INSTANCE = new HudChatMessageHolder();
|
||||
|
||||
@@ -41,10 +47,7 @@ public class HudChatMessageHolder implements IChatMessageProcessor {
|
||||
public void addMessage(HudChatMessage message) {
|
||||
messages.add(0, message);
|
||||
WindowManager.getInstance().onNewMessage(message);
|
||||
while (
|
||||
messages.size() >
|
||||
HudConfigStorage.General.STORED_LINES.config.getIntegerValue()
|
||||
) {
|
||||
while (messages.size() > HudConfigStorage.General.STORED_LINES.config.getIntegerValue()) {
|
||||
messages.remove(messages.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud;
|
||||
|
||||
import fi.dy.masa.malilib.config.ConfigManager;
|
||||
@@ -8,7 +15,6 @@ import io.github.darkkronicle.advancedchatcore.AdvancedChatCore;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.ChatHistory;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.ChatScreenSectionHolder;
|
||||
import io.github.darkkronicle.advancedchatcore.config.gui.GuiConfigHandler;
|
||||
import io.github.darkkronicle.advancedchatcore.interfaces.IChatMessageProcessor;
|
||||
import io.github.darkkronicle.advancedchathud.config.GuiTabManager;
|
||||
import io.github.darkkronicle.advancedchathud.config.HudConfigStorage;
|
||||
import io.github.darkkronicle.advancedchathud.gui.HudSection;
|
||||
@@ -25,56 +31,33 @@ public class HudInitHandler implements IInitializationHandler {
|
||||
@Override
|
||||
public void registerModHandlers() {
|
||||
AdvancedChatCore.FORWARD_TO_HUD = false;
|
||||
ConfigManager
|
||||
.getInstance()
|
||||
.registerConfigHandler(
|
||||
AdvancedChatHud.MOD_ID,
|
||||
new HudConfigStorage()
|
||||
);
|
||||
GuiConfigHandler
|
||||
.getInstance()
|
||||
.addGuiSection(
|
||||
GuiConfigHandler.createGuiConfigSection(
|
||||
StringUtils.translate("advancedchathud.tab.general"),
|
||||
HudConfigStorage.General.OPTIONS
|
||||
)
|
||||
);
|
||||
GuiConfigHandler
|
||||
.getInstance()
|
||||
.addGuiSection(
|
||||
new GuiConfigHandler.Tab() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return StringUtils.translate(
|
||||
"advancedchathud.tab.tabs"
|
||||
);
|
||||
}
|
||||
ConfigManager.getInstance()
|
||||
.registerConfigHandler(AdvancedChatHud.MOD_ID, new HudConfigStorage());
|
||||
GuiConfigHandler.getInstance()
|
||||
.addGuiSection(
|
||||
GuiConfigHandler.createGuiConfigSection(
|
||||
StringUtils.translate("advancedchathud.tab.general"),
|
||||
HudConfigStorage.General.OPTIONS));
|
||||
GuiConfigHandler.getInstance()
|
||||
.addGuiSection(
|
||||
new GuiConfigHandler.Tab() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return StringUtils.translate("advancedchathud.tab.tabs");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Screen getScreen(
|
||||
List<GuiConfigHandler.TabButton> buttons
|
||||
) {
|
||||
return new GuiTabManager(buttons);
|
||||
}
|
||||
}
|
||||
);
|
||||
@Override
|
||||
public Screen getScreen(List<GuiConfigHandler.TabButton> buttons) {
|
||||
return new GuiTabManager(buttons);
|
||||
}
|
||||
});
|
||||
AdvancedChatHud.MAIN_CHAT_TAB = new MainChatTab();
|
||||
|
||||
// Register on the clear
|
||||
ChatScreenSectionHolder
|
||||
.getInstance()
|
||||
.addSectionSupplier(HudSection::new);
|
||||
ChatHistory
|
||||
.getInstance()
|
||||
.addOnClear(() -> WindowManager.getInstance().clear());
|
||||
ChatHistory
|
||||
.getInstance()
|
||||
.addOnClear(() -> HudChatMessageHolder.getInstance().clear());
|
||||
ChatHistory
|
||||
.getInstance()
|
||||
.addOnUpdate(HudChatMessageHolder.getInstance());
|
||||
RenderEventHandler
|
||||
.getInstance()
|
||||
.registerGameOverlayRenderer(WindowManager.getInstance());
|
||||
ChatScreenSectionHolder.getInstance().addSectionSupplier(HudSection::new);
|
||||
ChatHistory.getInstance().addOnClear(() -> WindowManager.getInstance().clear());
|
||||
ChatHistory.getInstance().addOnClear(() -> HudChatMessageHolder.getInstance().clear());
|
||||
ChatHistory.getInstance().addOnUpdate(HudChatMessageHolder.getInstance());
|
||||
RenderEventHandler.getInstance().registerGameOverlayRenderer(WindowManager.getInstance());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -6,7 +13,6 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import fi.dy.masa.malilib.config.IConfigBase;
|
||||
import fi.dy.masa.malilib.config.options.ConfigBoolean;
|
||||
import fi.dy.masa.malilib.config.options.ConfigOptionList;
|
||||
import fi.dy.masa.malilib.config.options.ConfigString;
|
||||
import fi.dy.masa.malilib.util.StringUtils;
|
||||
import io.github.darkkronicle.advancedchatcore.config.ConfigStorage;
|
||||
@@ -35,141 +41,109 @@ public class ChatTab {
|
||||
|
||||
private UUID uuid = UUID.randomUUID();
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigString> name = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"name",
|
||||
new ConfigString(
|
||||
translate("name"),
|
||||
"Boring Chat Tab",
|
||||
translate("info.name")
|
||||
)
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigString> name =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"name",
|
||||
new ConfigString(translate("name"), "Boring Chat Tab", translate("info.name")));
|
||||
|
||||
private List<Match> matches = new ArrayList<>(
|
||||
Collections.singleton(
|
||||
new Match("I will match to text!", FindType.LITERAL)
|
||||
)
|
||||
);
|
||||
private List<Match> matches =
|
||||
new ArrayList<>(
|
||||
Collections.singleton(new Match("I will match to text!", FindType.LITERAL)));
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigString> startingMessage = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"startingMessage",
|
||||
new ConfigString(
|
||||
translate("startingmessage"),
|
||||
"",
|
||||
translate("info.startingmessage")
|
||||
)
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigString> startingMessage =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"startingMessage",
|
||||
new ConfigString(
|
||||
translate("startingmessage"), "", translate("info.startingmessage")));
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigBoolean> forward = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"forward",
|
||||
new ConfigBoolean(translate("forward"), true, translate("info.forward"))
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigBoolean> forward =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"forward",
|
||||
new ConfigBoolean(translate("forward"), true, translate("info.forward")));
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigString> abbreviation = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"abbreviation",
|
||||
new ConfigString(
|
||||
translate("abbreviation"),
|
||||
"BCT",
|
||||
translate("info.abbreviation")
|
||||
)
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigString> abbreviation =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"abbreviation",
|
||||
new ConfigString(
|
||||
translate("abbreviation"), "BCT", translate("info.abbreviation")));
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigSimpleColor> mainColor = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"mainColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("maincolor"),
|
||||
ColorUtil.GRAY.withAlpha(100),
|
||||
translate("info.maincolor")
|
||||
)
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigSimpleColor> mainColor =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"mainColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("maincolor"),
|
||||
ColorUtil.GRAY.withAlpha(100),
|
||||
translate("info.maincolor")));
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigSimpleColor> borderColor = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"borderColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("bordercolor"),
|
||||
ColorUtil.BLACK.withAlpha(180),
|
||||
translate("info.bordercolor")
|
||||
)
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigSimpleColor> borderColor =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"borderColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("bordercolor"),
|
||||
ColorUtil.BLACK.withAlpha(180),
|
||||
translate("info.bordercolor")));
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigSimpleColor> innerColor = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"innerColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("innercolor"),
|
||||
ColorUtil.BLACK.withAlpha(100),
|
||||
translate("info.innercolor")
|
||||
)
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigSimpleColor> innerColor =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"innerColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("innercolor"),
|
||||
ColorUtil.BLACK.withAlpha(100),
|
||||
translate("info.innercolor")));
|
||||
|
||||
private ConfigStorage.SaveableConfig<ConfigBoolean> showUnread = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"showUnread",
|
||||
new ConfigBoolean(
|
||||
translate("showunread"),
|
||||
false,
|
||||
translate("info.showunread")
|
||||
)
|
||||
);
|
||||
private ConfigStorage.SaveableConfig<ConfigBoolean> showUnread =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"showUnread",
|
||||
new ConfigBoolean(
|
||||
translate("showunread"), false, translate("info.showunread")));
|
||||
|
||||
private final ImmutableList<ConfigStorage.SaveableConfig<?>> options = ImmutableList.of(
|
||||
name,
|
||||
startingMessage,
|
||||
forward,
|
||||
abbreviation,
|
||||
mainColor,
|
||||
borderColor,
|
||||
innerColor,
|
||||
showUnread
|
||||
);
|
||||
private final ImmutableList<ConfigStorage.SaveableConfig<?>> options =
|
||||
ImmutableList.of(
|
||||
name,
|
||||
startingMessage,
|
||||
forward,
|
||||
abbreviation,
|
||||
mainColor,
|
||||
borderColor,
|
||||
innerColor,
|
||||
showUnread);
|
||||
|
||||
/**
|
||||
* Options that the main tab can use
|
||||
*/
|
||||
private final ImmutableList<ConfigStorage.SaveableConfig<?>> mainEditableOptions = ImmutableList.of(
|
||||
name,
|
||||
startingMessage,
|
||||
abbreviation,
|
||||
mainColor,
|
||||
borderColor,
|
||||
innerColor,
|
||||
showUnread
|
||||
);
|
||||
/** Options that the main tab can use */
|
||||
private final ImmutableList<ConfigStorage.SaveableConfig<?>> mainEditableOptions =
|
||||
ImmutableList.of(
|
||||
name,
|
||||
startingMessage,
|
||||
abbreviation,
|
||||
mainColor,
|
||||
borderColor,
|
||||
innerColor,
|
||||
showUnread);
|
||||
|
||||
public FindType getFind() {
|
||||
return matches.get(0).getFindType();
|
||||
}
|
||||
|
||||
public List<String> getWidgetHoverLines() {
|
||||
String translated = StringUtils.translate(
|
||||
"advancedchathud.config.tabdescription"
|
||||
);
|
||||
String translated = StringUtils.translate("advancedchathud.config.tabdescription");
|
||||
ArrayList<String> hover = new ArrayList<>();
|
||||
for (String s : translated.split("\n")) {
|
||||
hover.add(
|
||||
s
|
||||
.replaceAll(
|
||||
Pattern.quote("<name>"),
|
||||
Matcher.quoteReplacement(name.config.getStringValue())
|
||||
)
|
||||
.replaceAll(
|
||||
Pattern.quote("<starting>"),
|
||||
Matcher.quoteReplacement(
|
||||
startingMessage.config.getStringValue()
|
||||
)
|
||||
)
|
||||
.replaceAll(
|
||||
Pattern.quote("<forward>"),
|
||||
Matcher.quoteReplacement(
|
||||
forward.config.getStringValue()
|
||||
)
|
||||
)
|
||||
.replaceAll(
|
||||
Pattern.quote("<find>"),
|
||||
Matcher.quoteReplacement(matches.get(0).getPattern())
|
||||
)
|
||||
.replaceAll(
|
||||
Pattern.quote("<findtype>"),
|
||||
Matcher.quoteReplacement(getFind().getDisplayName())
|
||||
)
|
||||
);
|
||||
s.replaceAll(
|
||||
Pattern.quote("<name>"),
|
||||
Matcher.quoteReplacement(name.config.getStringValue()))
|
||||
.replaceAll(
|
||||
Pattern.quote("<starting>"),
|
||||
Matcher.quoteReplacement(
|
||||
startingMessage.config.getStringValue()))
|
||||
.replaceAll(
|
||||
Pattern.quote("<forward>"),
|
||||
Matcher.quoteReplacement(forward.config.getStringValue()))
|
||||
.replaceAll(
|
||||
Pattern.quote("<find>"),
|
||||
Matcher.quoteReplacement(matches.get(0).getPattern()))
|
||||
.replaceAll(
|
||||
Pattern.quote("<findtype>"),
|
||||
Matcher.quoteReplacement(getFind().getDisplayName())));
|
||||
}
|
||||
return hover;
|
||||
}
|
||||
@@ -204,10 +178,9 @@ public class ChatTab {
|
||||
} catch (Exception e) {
|
||||
// Failed, but a new one will happen
|
||||
AdvancedChatHud.LOGGER.warn(
|
||||
"Tab " +
|
||||
t.getName().config.getStringValue() +
|
||||
" did not have a UUID. New one will be generated."
|
||||
);
|
||||
"Tab "
|
||||
+ t.getName().config.getStringValue()
|
||||
+ " did not have a UUID. New one will be generated.");
|
||||
}
|
||||
}
|
||||
return t;
|
||||
@@ -222,9 +195,7 @@ public class ChatTab {
|
||||
}
|
||||
JsonArray find = new JsonArray();
|
||||
if (tab.getMatches().size() == 0) {
|
||||
tab
|
||||
.getMatches()
|
||||
.add(new Match("I will match to text!", FindType.LITERAL));
|
||||
tab.getMatches().add(new Match("I will match to text!", FindType.LITERAL));
|
||||
}
|
||||
for (Match m : tab.getMatches()) {
|
||||
find.add(serializer.save(m));
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import fi.dy.masa.malilib.config.IConfigBase;
|
||||
@@ -25,13 +32,7 @@ public class GuiTabEditor extends GuiConfigsBase {
|
||||
}
|
||||
|
||||
public GuiTabEditor(Screen parent, ChatTab tab, boolean main) {
|
||||
super(
|
||||
10,
|
||||
50,
|
||||
AdvancedChatHud.MOD_ID,
|
||||
parent,
|
||||
tab.getName().config.getStringValue()
|
||||
);
|
||||
super(10, 50, AdvancedChatHud.MOD_ID, parent, tab.getName().config.getStringValue());
|
||||
this.tab = tab;
|
||||
this.main = main;
|
||||
this.setParent(parent);
|
||||
@@ -47,49 +48,24 @@ public class GuiTabEditor extends GuiConfigsBase {
|
||||
String backText = ButtonListener.Type.BACK.getDisplayName();
|
||||
int backWidth = StringUtils.getStringWidth(backText) + 10;
|
||||
int topx = x;
|
||||
ButtonGeneric back = new ButtonGeneric(
|
||||
x + backWidth,
|
||||
y,
|
||||
backWidth,
|
||||
true,
|
||||
backText
|
||||
);
|
||||
this.addButton(
|
||||
back,
|
||||
new ButtonListener(ButtonListener.Type.BACK, this)
|
||||
);
|
||||
ButtonGeneric back = new ButtonGeneric(x + backWidth, y, backWidth, true, backText);
|
||||
this.addButton(back, new ButtonListener(ButtonListener.Type.BACK, this));
|
||||
topx += back.getWidth() + 2;
|
||||
|
||||
if (!main) {
|
||||
String matchesText = ButtonListener.Type.MATCHES.getDisplayName();
|
||||
int matchesWidth = StringUtils.getStringWidth(matchesText) + 10;
|
||||
ButtonGeneric match = new ButtonGeneric(
|
||||
topx + matchesWidth,
|
||||
y,
|
||||
matchesWidth,
|
||||
true,
|
||||
matchesText
|
||||
);
|
||||
this.addButton(
|
||||
match,
|
||||
new ButtonListener(ButtonListener.Type.MATCHES, this)
|
||||
);
|
||||
ButtonGeneric match =
|
||||
new ButtonGeneric(topx + matchesWidth, y, matchesWidth, true, matchesText);
|
||||
this.addButton(match, new ButtonListener(ButtonListener.Type.MATCHES, this));
|
||||
topx += match.getWidth() + 2;
|
||||
}
|
||||
|
||||
String exportText = ButtonListener.Type.EXPORT.getDisplayName();
|
||||
int exportWidth = StringUtils.getStringWidth(exportText) + 10;
|
||||
ButtonGeneric export = new ButtonGeneric(
|
||||
topx + exportWidth,
|
||||
y,
|
||||
exportWidth,
|
||||
true,
|
||||
exportText
|
||||
);
|
||||
this.addButton(
|
||||
export,
|
||||
new ButtonListener(ButtonListener.Type.EXPORT, this)
|
||||
);
|
||||
ButtonGeneric export =
|
||||
new ButtonGeneric(topx + exportWidth, y, exportWidth, true, exportText);
|
||||
this.addButton(export, new ButtonListener(ButtonListener.Type.EXPORT, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,10 +116,8 @@ public class GuiTabEditor extends GuiConfigsBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
keyCode == KeyCodes.KEY_ESCAPE &&
|
||||
this.parentScreen != GuiUtils.getCurrentScreen()
|
||||
) {
|
||||
if (keyCode == KeyCodes.KEY_ESCAPE
|
||||
&& this.parentScreen != GuiUtils.getCurrentScreen()) {
|
||||
// Make sure to save
|
||||
closeGui(true);
|
||||
return true;
|
||||
@@ -164,10 +138,7 @@ public class GuiTabEditor extends GuiConfigsBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedWithButton(
|
||||
ButtonBase button,
|
||||
int mouseButton
|
||||
) {
|
||||
public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
||||
if (this.type == ButtonListener.Type.BACK) {
|
||||
parent.back();
|
||||
} else if (this.type == ButtonListener.Type.EXPORT) {
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import fi.dy.masa.malilib.gui.GuiBase;
|
||||
@@ -11,9 +18,8 @@ import io.github.darkkronicle.advancedchatcore.config.gui.GuiConfigHandler;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GuiTabManager
|
||||
extends GuiListBase<ChatTab, WidgetTabEntry, WidgetListTabs>
|
||||
implements ISelectionListener<ChatTab> {
|
||||
public class GuiTabManager extends GuiListBase<ChatTab, WidgetTabEntry, WidgetListTabs>
|
||||
implements ISelectionListener<ChatTab> {
|
||||
|
||||
private List<GuiConfigHandler.TabButton> tabButtons;
|
||||
|
||||
@@ -26,13 +32,7 @@ public class GuiTabManager
|
||||
@Override
|
||||
protected WidgetListTabs createListWidget(int listX, int listY) {
|
||||
return new WidgetListTabs(
|
||||
listX,
|
||||
listY,
|
||||
this.getBrowserWidth(),
|
||||
this.getBrowserHeight(),
|
||||
null,
|
||||
this
|
||||
);
|
||||
listX, listY, this.getBrowserWidth(), this.getBrowserHeight(), null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,21 +68,12 @@ public class GuiTabManager
|
||||
}
|
||||
|
||||
private int createButton(GuiConfigHandler.TabButton button, int y) {
|
||||
this.addButton(
|
||||
button.getButton(),
|
||||
new ButtonListenerConfigTabs(button)
|
||||
);
|
||||
this.addButton(button.getButton(), new ButtonListenerConfigTabs(button));
|
||||
return button.getButton().getY();
|
||||
}
|
||||
|
||||
protected int addButton(int x, int y, ButtonListener.Type type) {
|
||||
ButtonGeneric button = new ButtonGeneric(
|
||||
x,
|
||||
y,
|
||||
-1,
|
||||
true,
|
||||
type.getDisplayName()
|
||||
);
|
||||
ButtonGeneric button = new ButtonGeneric(x, y, -1, true, type.getDisplayName());
|
||||
this.addButton(button, new ButtonListener(type, this));
|
||||
|
||||
return button.getWidth();
|
||||
@@ -99,10 +90,7 @@ public class GuiTabManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedWithButton(
|
||||
ButtonBase button,
|
||||
int mouseButton
|
||||
) {
|
||||
public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
||||
if (this.type == ButtonListener.Type.ADD_TAB) {
|
||||
HudConfigStorage.TABS.add(new ChatTab());
|
||||
this.gui.getListWidget().refreshEntries();
|
||||
@@ -139,8 +127,7 @@ public class GuiTabManager
|
||||
@Override
|
||||
public void onSelectionChange(@Nullable ChatTab entry) {}
|
||||
|
||||
private static class ButtonListenerConfigTabs
|
||||
implements IButtonActionListener {
|
||||
private static class ButtonListenerConfigTabs implements IButtonActionListener {
|
||||
|
||||
private final GuiConfigHandler.TabButton tabButton;
|
||||
|
||||
@@ -149,16 +136,10 @@ public class GuiTabManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedWithButton(
|
||||
ButtonBase button,
|
||||
int mouseButton
|
||||
) {
|
||||
GuiConfigHandler.getInstance().activeTab =
|
||||
this.tabButton.getTab().getName();
|
||||
public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
||||
GuiConfigHandler.getInstance().activeTab = this.tabButton.getTab().getName();
|
||||
GuiBase.openGui(
|
||||
this.tabButton.getTab()
|
||||
.getScreen(GuiConfigHandler.getInstance().getButtons())
|
||||
);
|
||||
this.tabButton.getTab().getScreen(GuiConfigHandler.getInstance().getButtons()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+181
-268
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -12,7 +19,6 @@ import fi.dy.masa.malilib.config.options.ConfigBoolean;
|
||||
import fi.dy.masa.malilib.config.options.ConfigDouble;
|
||||
import fi.dy.masa.malilib.config.options.ConfigInteger;
|
||||
import fi.dy.masa.malilib.config.options.ConfigOptionList;
|
||||
import fi.dy.masa.malilib.config.options.ConfigString;
|
||||
import fi.dy.masa.malilib.util.FileUtils;
|
||||
import fi.dy.masa.malilib.util.JsonUtils;
|
||||
import fi.dy.masa.malilib.util.StringUtils;
|
||||
@@ -32,8 +38,7 @@ import net.minecraft.util.Identifier;
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class HudConfigStorage implements IConfigHandler {
|
||||
|
||||
public static final String CONFIG_FILE_NAME =
|
||||
AdvancedChatHud.MOD_ID + ".json";
|
||||
public static final String CONFIG_FILE_NAME = AdvancedChatHud.MOD_ID + ".json";
|
||||
private static final int CONFIG_VERSION = 1;
|
||||
public static final List<ChatTab> TABS = new ArrayList<>();
|
||||
public static ChatTab MAIN_TAB = ChatTab.getMainOptions();
|
||||
@@ -43,262 +48,193 @@ public class HudConfigStorage implements IConfigHandler {
|
||||
public static final String NAME = "general";
|
||||
|
||||
public static String translate(String key) {
|
||||
return StringUtils.translate(
|
||||
"advancedchathud.config.general." + key
|
||||
);
|
||||
return StringUtils.translate("advancedchathud.config.general." + key);
|
||||
}
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> CHAT_HEADS = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"chatHeads",
|
||||
new ConfigBoolean(
|
||||
translate("chatheads"),
|
||||
false,
|
||||
translate("info.chatheads")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> CHAT_HEADS =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"chatHeads",
|
||||
new ConfigBoolean(
|
||||
translate("chatheads"), false, translate("info.chatheads")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> WIDTH = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"width",
|
||||
new ConfigInteger(
|
||||
translate("width"),
|
||||
280,
|
||||
100,
|
||||
600,
|
||||
translate("info.width")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> WIDTH =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"width",
|
||||
new ConfigInteger(
|
||||
translate("width"), 280, 100, 600, translate("info.width")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> HEIGHT = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"height",
|
||||
new ConfigInteger(
|
||||
translate("height"),
|
||||
117,
|
||||
20,
|
||||
400,
|
||||
translate("info.height")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> HEIGHT =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"height",
|
||||
new ConfigInteger(
|
||||
translate("height"), 117, 20, 400, translate("info.height")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> X = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"x",
|
||||
new ConfigInteger(translate("x"), 0, 0, 4000, translate("info.x"))
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> X =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"x", new ConfigInteger(translate("x"), 0, 0, 4000, translate("info.x")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> Y = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"y",
|
||||
new ConfigInteger(translate("y"), 30, 0, 4000, translate("info.y"))
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> Y =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"y", new ConfigInteger(translate("y"), 30, 0, 4000, translate("info.y")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> MESSAGE_SPACE = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"messageSpace",
|
||||
new ConfigInteger(
|
||||
translate("messagespace"),
|
||||
0,
|
||||
0,
|
||||
10,
|
||||
translate("info.messagespace")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> MESSAGE_SPACE =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"messageSpace",
|
||||
new ConfigInteger(
|
||||
translate("messagespace"),
|
||||
0,
|
||||
0,
|
||||
10,
|
||||
translate("info.messagespace")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> LINE_SPACE = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"lineSpace",
|
||||
new ConfigInteger(
|
||||
translate("linespace"),
|
||||
9,
|
||||
8,
|
||||
20,
|
||||
translate("info.linespace")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> LINE_SPACE =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"lineSpace",
|
||||
new ConfigInteger(
|
||||
translate("linespace"), 9, 8, 20, translate("info.linespace")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> LEFT_PAD = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"leftPad",
|
||||
new ConfigInteger(
|
||||
translate("leftpad"),
|
||||
2,
|
||||
0,
|
||||
20,
|
||||
translate("info.leftpad")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> LEFT_PAD =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"leftPad",
|
||||
new ConfigInteger(
|
||||
translate("leftpad"), 2, 0, 20, translate("info.leftpad")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> RIGHT_PAD = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"rightPad",
|
||||
new ConfigInteger(
|
||||
translate("rightpad"),
|
||||
2,
|
||||
0,
|
||||
20,
|
||||
translate("info.rightpad")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> RIGHT_PAD =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"rightPad",
|
||||
new ConfigInteger(
|
||||
translate("rightpad"), 2, 0, 20, translate("info.rightpad")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> BOTTOM_PAD = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"bottomPad",
|
||||
new ConfigInteger(
|
||||
translate("bottompad"),
|
||||
1,
|
||||
0,
|
||||
20,
|
||||
translate("info.bottompad")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> BOTTOM_PAD =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"bottomPad",
|
||||
new ConfigInteger(
|
||||
translate("bottompad"), 1, 0, 20, translate("info.bottompad")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> TOP_PAD = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"topPad",
|
||||
new ConfigInteger(
|
||||
translate("toppad"),
|
||||
0,
|
||||
0,
|
||||
20,
|
||||
translate("info.toppad")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> TOP_PAD =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"topPad",
|
||||
new ConfigInteger(translate("toppad"), 0, 0, 20, translate("info.toppad")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> SHOW_TABS = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"showTabs",
|
||||
new ConfigBoolean(
|
||||
translate("showtabs"),
|
||||
true,
|
||||
translate("info.showtabs")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> SHOW_TABS =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"showTabs",
|
||||
new ConfigBoolean(translate("showtabs"), true, translate("info.showtabs")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigOptionList> VISIBILITY = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"visibility",
|
||||
new ConfigOptionList(
|
||||
translate("visibility"),
|
||||
Visibility.VANILLA,
|
||||
translate("info.visibility")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigOptionList> VISIBILITY =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"visibility",
|
||||
new ConfigOptionList(
|
||||
translate("visibility"),
|
||||
Visibility.VANILLA,
|
||||
translate("info.visibility")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigDouble> CHAT_SCALE = ConfigStorage.SaveableConfig.fromConfig(
|
||||
translate("chatScale"),
|
||||
new ConfigDouble(
|
||||
translate("chatscale"),
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
translate("info.chatscale")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigDouble> CHAT_SCALE =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
translate("chatScale"),
|
||||
new ConfigDouble(
|
||||
translate("chatscale"), 1, 0, 1, translate("info.chatscale")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> FADE_TIME = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"fadeTime",
|
||||
new ConfigInteger(
|
||||
translate("fadetime"),
|
||||
40,
|
||||
0,
|
||||
200,
|
||||
translate("info.fadetime")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> FADE_TIME =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"fadeTime",
|
||||
new ConfigInteger(
|
||||
translate("fadetime"), 40, 0, 200, translate("info.fadetime")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> FADE_START = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"fadeStart",
|
||||
new ConfigInteger(
|
||||
translate("fadestart"),
|
||||
100,
|
||||
20,
|
||||
1000,
|
||||
translate("info.fadestart")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> FADE_START =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"fadeStart",
|
||||
new ConfigInteger(
|
||||
translate("fadestart"),
|
||||
100,
|
||||
20,
|
||||
1000,
|
||||
translate("info.fadestart")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigOptionList> FADE_TYPE = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"fadeType",
|
||||
new ConfigOptionList(
|
||||
translate("fadetype"),
|
||||
ConfigStorage.Easing.LINEAR,
|
||||
translate("info.fadetype")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigOptionList> FADE_TYPE =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"fadeType",
|
||||
new ConfigOptionList(
|
||||
translate("fadetype"),
|
||||
ConfigStorage.Easing.LINEAR,
|
||||
translate("info.fadetype")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigSimpleColor> EMPTY_TEXT_COLOR = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"emptyTextColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("emptytextcolor"),
|
||||
ColorUtil.WHITE,
|
||||
translate("info.emptytextcolor")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigSimpleColor> EMPTY_TEXT_COLOR =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"emptyTextColor",
|
||||
new ConfigSimpleColor(
|
||||
translate("emptytextcolor"),
|
||||
ColorUtil.WHITE,
|
||||
translate("info.emptytextcolor")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigOptionList> HUD_LINE_TYPE = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"hudLineType",
|
||||
new ConfigOptionList(
|
||||
translate("hudlinetype"),
|
||||
HudLineType.FULL,
|
||||
translate("info.hudlinetype")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigOptionList> HUD_LINE_TYPE =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"hudLineType",
|
||||
new ConfigOptionList(
|
||||
translate("hudlinetype"),
|
||||
HudLineType.FULL,
|
||||
translate("info.hudlinetype")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> ALTERNATE_LINES = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"alternateLines",
|
||||
new ConfigBoolean(
|
||||
translate("alternatelines"),
|
||||
false,
|
||||
translate("info.alternatelines")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> ALTERNATE_LINES =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"alternateLines",
|
||||
new ConfigBoolean(
|
||||
translate("alternatelines"),
|
||||
false,
|
||||
translate("info.alternatelines")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> SHOW_TIME = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"showTime",
|
||||
new ConfigBoolean(
|
||||
translate("showtime"),
|
||||
false,
|
||||
translate("info.showtime")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigBoolean> SHOW_TIME =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"showTime",
|
||||
new ConfigBoolean(
|
||||
translate("showtime"), false, translate("info.showtime")));
|
||||
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> STORED_LINES = ConfigStorage.SaveableConfig.fromConfig(
|
||||
"storedLines",
|
||||
new ConfigInteger(
|
||||
translate("storedlines"),
|
||||
200,
|
||||
20,
|
||||
1000,
|
||||
translate("info.storedlines")
|
||||
)
|
||||
);
|
||||
public static final ConfigStorage.SaveableConfig<ConfigInteger> STORED_LINES =
|
||||
ConfigStorage.SaveableConfig.fromConfig(
|
||||
"storedLines",
|
||||
new ConfigInteger(
|
||||
translate("storedlines"),
|
||||
200,
|
||||
20,
|
||||
1000,
|
||||
translate("info.storedlines")));
|
||||
|
||||
public static final ImmutableList<ConfigStorage.SaveableConfig<? extends IConfigBase>> OPTIONS = ImmutableList.of(
|
||||
CHAT_HEADS,
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
X,
|
||||
Y,
|
||||
MESSAGE_SPACE,
|
||||
LINE_SPACE,
|
||||
LEFT_PAD,
|
||||
RIGHT_PAD,
|
||||
BOTTOM_PAD,
|
||||
TOP_PAD,
|
||||
SHOW_TABS,
|
||||
VISIBILITY,
|
||||
CHAT_SCALE,
|
||||
FADE_TIME,
|
||||
FADE_START,
|
||||
FADE_TYPE,
|
||||
EMPTY_TEXT_COLOR,
|
||||
HUD_LINE_TYPE,
|
||||
ALTERNATE_LINES,
|
||||
SHOW_TIME,
|
||||
STORED_LINES
|
||||
);
|
||||
public static final ImmutableList<ConfigStorage.SaveableConfig<? extends IConfigBase>>
|
||||
OPTIONS =
|
||||
ImmutableList.of(
|
||||
CHAT_HEADS,
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
X,
|
||||
Y,
|
||||
MESSAGE_SPACE,
|
||||
LINE_SPACE,
|
||||
LEFT_PAD,
|
||||
RIGHT_PAD,
|
||||
BOTTOM_PAD,
|
||||
TOP_PAD,
|
||||
SHOW_TABS,
|
||||
VISIBILITY,
|
||||
CHAT_SCALE,
|
||||
FADE_TIME,
|
||||
FADE_START,
|
||||
FADE_TYPE,
|
||||
EMPTY_TEXT_COLOR,
|
||||
HUD_LINE_TYPE,
|
||||
ALTERNATE_LINES,
|
||||
SHOW_TIME,
|
||||
STORED_LINES);
|
||||
}
|
||||
|
||||
public static void loadFromFile() {
|
||||
File configFile = FileUtils
|
||||
.getConfigDirectory()
|
||||
.toPath()
|
||||
.resolve("advancedchat")
|
||||
.resolve(CONFIG_FILE_NAME)
|
||||
.toFile();
|
||||
File configFile =
|
||||
FileUtils.getConfigDirectory()
|
||||
.toPath()
|
||||
.resolve("advancedchat")
|
||||
.resolve(CONFIG_FILE_NAME)
|
||||
.toFile();
|
||||
|
||||
if (
|
||||
configFile.exists() && configFile.isFile() && configFile.canRead()
|
||||
) {
|
||||
if (configFile.exists() && configFile.isFile() && configFile.canRead()) {
|
||||
JsonElement element = ConfigStorage.parseJsonFile(configFile);
|
||||
|
||||
if (element != null && element.isJsonObject()) {
|
||||
@@ -322,44 +258,30 @@ public class HudConfigStorage implements IConfigHandler {
|
||||
|
||||
JsonElement windows = root.get("windows");
|
||||
if (windows != null && windows.isJsonArray()) {
|
||||
WindowManager
|
||||
.getInstance()
|
||||
.loadFromJson(windows.getAsJsonArray());
|
||||
WindowManager.getInstance().loadFromJson(windows.getAsJsonArray());
|
||||
} else {
|
||||
WindowManager.getInstance().loadFromJson(null);
|
||||
}
|
||||
|
||||
ConfigStorage.readOptions(
|
||||
root,
|
||||
General.NAME,
|
||||
(List<ConfigStorage.SaveableConfig<?>>) General.OPTIONS
|
||||
);
|
||||
root,
|
||||
General.NAME,
|
||||
(List<ConfigStorage.SaveableConfig<?>>) General.OPTIONS);
|
||||
|
||||
int version = JsonUtils.getIntegerOrDefault(
|
||||
root,
|
||||
"configVersion",
|
||||
0
|
||||
);
|
||||
int version = JsonUtils.getIntegerOrDefault(root, "configVersion", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveFromFile() {
|
||||
File dir = FileUtils
|
||||
.getConfigDirectory()
|
||||
.toPath()
|
||||
.resolve("advancedchat")
|
||||
.toFile();
|
||||
File dir = FileUtils.getConfigDirectory().toPath().resolve("advancedchat").toFile();
|
||||
|
||||
if ((dir.exists() && dir.isDirectory()) || dir.mkdirs()) {
|
||||
ChatTab.ChatTabJsonSave tabJson = new ChatTab.ChatTabJsonSave();
|
||||
JsonObject root = new JsonObject();
|
||||
|
||||
ConfigStorage.writeOptions(
|
||||
root,
|
||||
General.NAME,
|
||||
(List<ConfigStorage.SaveableConfig<?>>) General.OPTIONS
|
||||
);
|
||||
root, General.NAME, (List<ConfigStorage.SaveableConfig<?>>) General.OPTIONS);
|
||||
|
||||
root.add("maintab", tabJson.save(MAIN_TAB));
|
||||
|
||||
@@ -371,10 +293,7 @@ public class HudConfigStorage implements IConfigHandler {
|
||||
root.add("windows", WindowManager.getInstance().saveJson());
|
||||
root.add("config_version", new JsonPrimitive(CONFIG_VERSION));
|
||||
|
||||
ConfigStorage.writeJsonToFile(
|
||||
root,
|
||||
new File(dir, CONFIG_FILE_NAME)
|
||||
);
|
||||
ConfigStorage.writeJsonToFile(root, new File(dir, CONFIG_FILE_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,9 +314,7 @@ public class HudConfigStorage implements IConfigHandler {
|
||||
public final String configString;
|
||||
|
||||
private static String translate(String key) {
|
||||
return StringUtils.translate(
|
||||
"advancedchathud.config.hudlinetype." + key
|
||||
);
|
||||
return StringUtils.translate("advancedchathud.config.hudlinetype." + key);
|
||||
}
|
||||
|
||||
HudLineType(String configString) {
|
||||
@@ -452,21 +369,17 @@ public class HudConfigStorage implements IConfigHandler {
|
||||
|
||||
private final String configString;
|
||||
|
||||
@Getter
|
||||
private final Identifier texture;
|
||||
@Getter private final Identifier texture;
|
||||
|
||||
private static String translate(String key) {
|
||||
return StringUtils.translate(
|
||||
"advancedchathud.config.visibility." + key
|
||||
);
|
||||
return StringUtils.translate("advancedchathud.config.visibility." + key);
|
||||
}
|
||||
|
||||
Visibility(String configString) {
|
||||
this.texture =
|
||||
new Identifier(
|
||||
AdvancedChatHud.MOD_ID,
|
||||
"textures/gui/chatwindow/" + configString + ".png"
|
||||
);
|
||||
new Identifier(
|
||||
AdvancedChatHud.MOD_ID,
|
||||
"textures/gui/chatwindow/" + configString + ".png");
|
||||
this.configString = configString;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import fi.dy.masa.malilib.gui.GuiListBase;
|
||||
@@ -9,8 +16,7 @@ import io.github.darkkronicle.advancedchatcore.util.FindType;
|
||||
import io.github.darkkronicle.advancedchathud.AdvancedChatHud;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
public class MatchesEditor
|
||||
extends GuiListBase<Match, WidgetMatchEntry, WidgetListMatches> {
|
||||
public class MatchesEditor extends GuiListBase<Match, WidgetMatchEntry, WidgetListMatches> {
|
||||
|
||||
private final ChatTab tab;
|
||||
|
||||
@@ -32,25 +38,13 @@ public class MatchesEditor
|
||||
|
||||
protected MatchesEditor(Screen parent, ChatTab tab) {
|
||||
super(10, 60);
|
||||
this.title =
|
||||
StringUtils.translate("advancedchathud.config.match.screen.name");
|
||||
this.title = StringUtils.translate("advancedchathud.config.match.screen.name");
|
||||
this.tab = tab;
|
||||
this.setParent(parent);
|
||||
}
|
||||
|
||||
protected int addButton(
|
||||
int x,
|
||||
int y,
|
||||
ButtonListener.Type type,
|
||||
boolean rightAlign
|
||||
) {
|
||||
ButtonGeneric button = new ButtonGeneric(
|
||||
x,
|
||||
y,
|
||||
-1,
|
||||
rightAlign,
|
||||
type.getDisplayName()
|
||||
);
|
||||
protected int addButton(int x, int y, ButtonListener.Type type, boolean rightAlign) {
|
||||
ButtonGeneric button = new ButtonGeneric(x, y, -1, rightAlign, type.getDisplayName());
|
||||
this.addButton(button, new ButtonListener(type, this));
|
||||
|
||||
return button.getWidth();
|
||||
@@ -59,14 +53,7 @@ public class MatchesEditor
|
||||
@Override
|
||||
protected WidgetListMatches createListWidget(int listX, int listY) {
|
||||
return new WidgetListMatches(
|
||||
listX,
|
||||
listY,
|
||||
this.getBrowserWidth(),
|
||||
this.getBrowserHeight(),
|
||||
null,
|
||||
tab,
|
||||
this
|
||||
);
|
||||
listX, listY, this.getBrowserWidth(), this.getBrowserHeight(), null, tab, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,9 +67,7 @@ public class MatchesEditor
|
||||
}
|
||||
|
||||
public void addMatch() {
|
||||
tab
|
||||
.getMatches()
|
||||
.add(new Match("I will match to text!", FindType.LITERAL));
|
||||
tab.getMatches().add(new Match("I will match to text!", FindType.LITERAL));
|
||||
getListWidget().refreshEntries();
|
||||
}
|
||||
|
||||
@@ -101,10 +86,7 @@ public class MatchesEditor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedWithButton(
|
||||
ButtonBase button,
|
||||
int mouseButton
|
||||
) {
|
||||
public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
||||
if (this.type == ButtonListener.Type.ADD_MATCH) {
|
||||
this.gui.addMatch();
|
||||
} else if (this.type == ButtonListener.Type.BACK) {
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -13,9 +20,7 @@ import fi.dy.masa.malilib.util.StringUtils;
|
||||
import io.github.darkkronicle.advancedchathud.AdvancedChatHud;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
/**
|
||||
* Screen for importing and exporting {@link ChatTab}.
|
||||
*/
|
||||
/** Screen for importing and exporting {@link ChatTab}. */
|
||||
public class SharingScreen extends GuiBase {
|
||||
|
||||
private final String starting;
|
||||
@@ -28,9 +33,7 @@ public class SharingScreen extends GuiBase {
|
||||
this.starting = starting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SharingScreen from a tab
|
||||
*/
|
||||
/** Creates a SharingScreen from a tab */
|
||||
public static SharingScreen fromTab(ChatTab tab, Screen parent) {
|
||||
ChatTab.ChatTabJsonSave tabJsonSave = new ChatTab.ChatTabJsonSave();
|
||||
return new SharingScreen(GSON.toJson(tabJsonSave.save(tab)), parent);
|
||||
@@ -56,8 +59,7 @@ public class SharingScreen extends GuiBase {
|
||||
int tabWidth = StringUtils.getStringWidth(tabName) + 10;
|
||||
this.addButton(
|
||||
new ButtonGeneric(x, y, tabWidth, 20, tabName),
|
||||
new ButtonListener(ButtonListener.Type.IMPORT_TAB, this)
|
||||
);
|
||||
new ButtonListener(ButtonListener.Type.IMPORT_TAB, this));
|
||||
}
|
||||
|
||||
private static class ButtonListener implements IButtonActionListener {
|
||||
@@ -89,42 +91,35 @@ public class SharingScreen extends GuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedWithButton(
|
||||
ButtonBase button,
|
||||
int mouseButton
|
||||
) {
|
||||
public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
||||
try {
|
||||
if (parent.text.getText().equals("")) {
|
||||
throw new NullPointerException("Message can't be blank!");
|
||||
}
|
||||
if (type == Type.IMPORT_TAB) {
|
||||
ChatTab.ChatTabJsonSave tabSave = new ChatTab.ChatTabJsonSave();
|
||||
ChatTab tab = tabSave.load(
|
||||
new JsonParser()
|
||||
.parse(parent.text.getText())
|
||||
.getAsJsonObject()
|
||||
);
|
||||
ChatTab tab =
|
||||
tabSave.load(
|
||||
new JsonParser()
|
||||
.parse(parent.text.getText())
|
||||
.getAsJsonObject());
|
||||
if (tab == null) {
|
||||
throw new NullPointerException("Filter is null!");
|
||||
}
|
||||
HudConfigStorage.TABS.add(tab);
|
||||
AdvancedChatHud.MAIN_CHAT_TAB.setUpTabs();
|
||||
parent.addGuiMessage(
|
||||
Message.MessageType.SUCCESS,
|
||||
5000,
|
||||
StringUtils.translate(
|
||||
"advancedchat.gui.message.successful"
|
||||
)
|
||||
);
|
||||
Message.MessageType.SUCCESS,
|
||||
5000,
|
||||
StringUtils.translate("advancedchat.gui.message.successful"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
parent.addGuiMessage(
|
||||
Message.MessageType.ERROR,
|
||||
10000,
|
||||
StringUtils.translate("advancedchat.gui.message.error") +
|
||||
": " +
|
||||
e.getMessage()
|
||||
);
|
||||
Message.MessageType.ERROR,
|
||||
10000,
|
||||
StringUtils.translate("advancedchat.gui.message.error")
|
||||
+ ": "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-23
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import fi.dy.masa.malilib.gui.GuiTextFieldGeneric;
|
||||
@@ -52,14 +59,13 @@ public class WidgetListMatches extends WidgetListBase<Match, WidgetMatchEntry> {
|
||||
}
|
||||
|
||||
public WidgetListMatches(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ISelectionListener<Match> selectionListener,
|
||||
ChatTab parent,
|
||||
Screen screen
|
||||
) {
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ISelectionListener<Match> selectionListener,
|
||||
ChatTab parent,
|
||||
Screen screen) {
|
||||
super(x, y, width, height, selectionListener);
|
||||
this.browserEntryHeight = 22;
|
||||
this.tab = parent;
|
||||
@@ -68,22 +74,16 @@ public class WidgetListMatches extends WidgetListBase<Match, WidgetMatchEntry> {
|
||||
|
||||
@Override
|
||||
protected WidgetMatchEntry createListEntryWidget(
|
||||
int x,
|
||||
int y,
|
||||
int listIndex,
|
||||
boolean isOdd,
|
||||
Match entry
|
||||
) {
|
||||
int x, int y, int listIndex, boolean isOdd, Match entry) {
|
||||
return new WidgetMatchEntry(
|
||||
x,
|
||||
y,
|
||||
this.browserEntryWidth,
|
||||
this.getBrowserEntryHeightFor(entry),
|
||||
isOdd,
|
||||
entry,
|
||||
listIndex,
|
||||
this
|
||||
);
|
||||
x,
|
||||
y,
|
||||
this.browserEntryWidth,
|
||||
this.getBrowserEntryHeightFor(entry),
|
||||
isOdd,
|
||||
entry,
|
||||
listIndex,
|
||||
this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import fi.dy.masa.malilib.gui.interfaces.ISelectionListener;
|
||||
import fi.dy.masa.malilib.gui.widgets.WidgetListBase;
|
||||
import io.github.darkkronicle.advancedchathud.AdvancedChatHud;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -12,13 +18,12 @@ import net.minecraft.client.gui.screen.Screen;
|
||||
public class WidgetListTabs extends WidgetListBase<ChatTab, WidgetTabEntry> {
|
||||
|
||||
public WidgetListTabs(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
@Nullable ISelectionListener<ChatTab> selectionListener,
|
||||
Screen parent
|
||||
) {
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
@Nullable ISelectionListener<ChatTab> selectionListener,
|
||||
Screen parent) {
|
||||
super(x, y, width, height, selectionListener);
|
||||
this.browserEntryHeight = 22;
|
||||
this.setParent(parent);
|
||||
@@ -26,29 +31,21 @@ public class WidgetListTabs extends WidgetListBase<ChatTab, WidgetTabEntry> {
|
||||
|
||||
@Override
|
||||
protected WidgetTabEntry createListEntryWidget(
|
||||
int x,
|
||||
int y,
|
||||
int listIndex,
|
||||
boolean isOdd,
|
||||
ChatTab entry
|
||||
) {
|
||||
int x, int y, int listIndex, boolean isOdd, ChatTab entry) {
|
||||
return new WidgetTabEntry(
|
||||
x,
|
||||
y,
|
||||
this.browserEntryWidth,
|
||||
this.getBrowserEntryHeightFor(entry),
|
||||
isOdd,
|
||||
entry,
|
||||
listIndex,
|
||||
this
|
||||
);
|
||||
x,
|
||||
y,
|
||||
this.browserEntryWidth,
|
||||
this.getBrowserEntryHeightFor(entry),
|
||||
isOdd,
|
||||
entry,
|
||||
listIndex,
|
||||
this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ChatTab> getAllEntries() {
|
||||
ArrayList<ChatTab> tabs = new ArrayList<>(
|
||||
Collections.singleton(HudConfigStorage.MAIN_TAB)
|
||||
);
|
||||
ArrayList<ChatTab> tabs = new ArrayList<>(Collections.singleton(HudConfigStorage.MAIN_TAB));
|
||||
tabs.addAll(HudConfigStorage.TABS);
|
||||
return tabs;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -26,22 +33,21 @@ public class WidgetMatchEntry extends WidgetListEntryBase<Match> {
|
||||
private final WidgetListMatches parent;
|
||||
private final boolean isOdd;
|
||||
private TextFieldWrapper<GuiTextFieldGeneric> name;
|
||||
private ConfigOptionList findType = new ConfigOptionList(
|
||||
"advancedchathud.config.match.findtype",
|
||||
FindType.LITERAL,
|
||||
"advancedchathud.config.match.info.findtype"
|
||||
);
|
||||
private ConfigOptionList findType =
|
||||
new ConfigOptionList(
|
||||
"advancedchathud.config.match.findtype",
|
||||
FindType.LITERAL,
|
||||
"advancedchathud.config.match.info.findtype");
|
||||
|
||||
public WidgetMatchEntry(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
boolean isOdd,
|
||||
Match entry,
|
||||
int listIndex,
|
||||
WidgetListMatches parent
|
||||
) {
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
boolean isOdd,
|
||||
Match entry,
|
||||
int listIndex,
|
||||
WidgetListMatches parent) {
|
||||
super(x, y, width, height, entry, listIndex);
|
||||
this.isOdd = isOdd;
|
||||
this.parent = parent;
|
||||
@@ -57,38 +63,29 @@ public class WidgetMatchEntry extends WidgetListEntryBase<Match> {
|
||||
int replaceWidth = 100;
|
||||
int nameWidth = width - replaceWidth - removeWidth;
|
||||
this.findType.setOptionListValue(entry.getFindType());
|
||||
ConfigButtonOptionList findType = new ConfigButtonOptionList(
|
||||
pos - replaceWidth,
|
||||
y,
|
||||
replaceWidth,
|
||||
20,
|
||||
this.findType
|
||||
);
|
||||
ConfigButtonOptionList findType =
|
||||
new ConfigButtonOptionList(pos - replaceWidth, y, replaceWidth, 20, this.findType);
|
||||
this.addButton(
|
||||
findType,
|
||||
(button, mouseButton) -> {
|
||||
entry.setFindType(
|
||||
(FindType) this.findType.getOptionListValue()
|
||||
);
|
||||
}
|
||||
);
|
||||
entry.setFindType((FindType) this.findType.getOptionListValue());
|
||||
});
|
||||
|
||||
pos -= replaceWidth + 1;
|
||||
GuiTextFieldGeneric nameField = new GuiTextFieldGeneric(
|
||||
pos - nameWidth,
|
||||
y,
|
||||
nameWidth,
|
||||
20,
|
||||
MinecraftClient.getInstance().textRenderer
|
||||
);
|
||||
GuiTextFieldGeneric nameField =
|
||||
new GuiTextFieldGeneric(
|
||||
pos - nameWidth,
|
||||
y,
|
||||
nameWidth,
|
||||
20,
|
||||
MinecraftClient.getInstance().textRenderer);
|
||||
nameField.setMaxLength(64000);
|
||||
nameField.setText(entry.getPattern());
|
||||
name = new TextFieldWrapper<>(nameField, new SaveListener(this));
|
||||
parent.addTextField(name);
|
||||
}
|
||||
|
||||
private static class SaveListener
|
||||
implements ITextFieldListener<GuiTextFieldGeneric> {
|
||||
private static class SaveListener implements ITextFieldListener<GuiTextFieldGeneric> {
|
||||
|
||||
private final WidgetMatchEntry parent;
|
||||
|
||||
@@ -104,13 +101,7 @@ public class WidgetMatchEntry extends WidgetListEntryBase<Match> {
|
||||
}
|
||||
|
||||
protected int addButton(int x, int y, ButtonListener.Type type) {
|
||||
ButtonGeneric button = new ButtonGeneric(
|
||||
x,
|
||||
y,
|
||||
-1,
|
||||
true,
|
||||
type.getDisplayName()
|
||||
);
|
||||
ButtonGeneric button = new ButtonGeneric(x, y, -1, true, type.getDisplayName());
|
||||
this.addButton(button, new ButtonListener(type, this));
|
||||
|
||||
return button.getWidth() + 1;
|
||||
@@ -134,11 +125,7 @@ public class WidgetMatchEntry extends WidgetListEntryBase<Match> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onMouseClickedImpl(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
int mouseButton
|
||||
) {
|
||||
protected boolean onMouseClickedImpl(int mouseX, int mouseY, int mouseButton) {
|
||||
if (super.onMouseClickedImpl(mouseX, mouseY, mouseButton)) {
|
||||
return true;
|
||||
}
|
||||
@@ -146,27 +133,21 @@ public class WidgetMatchEntry extends WidgetListEntryBase<Match> {
|
||||
boolean ret = false;
|
||||
|
||||
if (this.name != null) {
|
||||
ret =
|
||||
this.name.getTextField()
|
||||
.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
ret = this.name.getTextField().mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
if (!this.subWidgets.isEmpty()) {
|
||||
for (WidgetBase widget : this.subWidgets) {
|
||||
ret |=
|
||||
widget.isMouseOver(mouseX, mouseY) &&
|
||||
widget.onMouseClicked(mouseX, mouseY, mouseButton);
|
||||
widget.isMouseOver(mouseX, mouseY)
|
||||
&& widget.onMouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected void drawTextFields(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
MatrixStack matrixStack
|
||||
) {
|
||||
protected void drawTextFields(int mouseX, int mouseY, MatrixStack matrixStack) {
|
||||
if (this.name != null) {
|
||||
this.name.getTextField().render(matrixStack, mouseX, mouseY, 0f);
|
||||
}
|
||||
@@ -177,19 +158,13 @@ public class WidgetMatchEntry extends WidgetListEntryBase<Match> {
|
||||
private final ButtonListener.Type type;
|
||||
private final WidgetMatchEntry parent;
|
||||
|
||||
public ButtonListener(
|
||||
ButtonListener.Type type,
|
||||
WidgetMatchEntry parent
|
||||
) {
|
||||
public ButtonListener(ButtonListener.Type type, WidgetMatchEntry parent) {
|
||||
this.parent = parent;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedWithButton(
|
||||
ButtonBase button,
|
||||
int mouseButton
|
||||
) {
|
||||
public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
||||
if (type == ButtonListener.Type.REMOVE) {
|
||||
parent.parent.tab.getMatches().remove(parent.entry);
|
||||
parent.parent.refreshEntries();
|
||||
@@ -216,39 +191,23 @@ public class WidgetMatchEntry extends WidgetListEntryBase<Match> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
boolean selected,
|
||||
MatrixStack matrixStack
|
||||
) {
|
||||
public void render(int mouseX, int mouseY, boolean selected, MatrixStack matrixStack) {
|
||||
RenderUtils.color(1f, 1f, 1f, 1f);
|
||||
|
||||
// Draw a lighter background for the hovered and the selected entry
|
||||
if (selected || this.isMouseOver(mouseX, mouseY)) {
|
||||
RenderUtils.drawRect(
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(150).color()
|
||||
);
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(150).color());
|
||||
} else if (this.isOdd) {
|
||||
RenderUtils.drawRect(
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(70).color()
|
||||
);
|
||||
this.x, this.y, this.width, this.height, ColorUtil.WHITE.withAlpha(70).color());
|
||||
} else {
|
||||
RenderUtils.drawRect(
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(50).color()
|
||||
);
|
||||
this.x, this.y, this.width, this.height, ColorUtil.WHITE.withAlpha(50).color());
|
||||
}
|
||||
|
||||
RenderUtils.color(1f, 1f, 1f, 1f);
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.config;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -16,8 +23,8 @@ import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
/*
|
||||
This class is based heavily off of https://github.com/maruohon/minihud/blob/d565d39c68bdcd3ed1e1cf2007491e03d9659f34/src/main/java/fi/dy/masa/minihud/gui/widgets/WidgetShapeEntry.java#L19 which is off the GNU LGPL
|
||||
*/
|
||||
This class is based heavily off of https://github.com/maruohon/minihud/blob/d565d39c68bdcd3ed1e1cf2007491e03d9659f34/src/main/java/fi/dy/masa/minihud/gui/widgets/WidgetShapeEntry.java#L19 which is off the GNU LGPL
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class WidgetTabEntry extends WidgetListEntryBase<ChatTab> {
|
||||
|
||||
@@ -29,15 +36,14 @@ public class WidgetTabEntry extends WidgetListEntryBase<ChatTab> {
|
||||
private boolean main = true;
|
||||
|
||||
public WidgetTabEntry(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
boolean isOdd,
|
||||
ChatTab tab,
|
||||
int listIndex,
|
||||
WidgetListTabs parent
|
||||
) {
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
boolean isOdd,
|
||||
ChatTab tab,
|
||||
int listIndex,
|
||||
WidgetListTabs parent) {
|
||||
super(x, y, width, height, tab, listIndex);
|
||||
this.parent = parent;
|
||||
this.isOdd = isOdd;
|
||||
@@ -58,61 +64,33 @@ public class WidgetTabEntry extends WidgetListEntryBase<ChatTab> {
|
||||
}
|
||||
|
||||
protected int addButton(int x, int y, ButtonListener.Type type) {
|
||||
ButtonGeneric button = new ButtonGeneric(
|
||||
x,
|
||||
y,
|
||||
-1,
|
||||
true,
|
||||
type.getDisplayName()
|
||||
);
|
||||
ButtonGeneric button = new ButtonGeneric(x, y, -1, true, type.getDisplayName());
|
||||
this.addButton(button, new ButtonListener(type, this));
|
||||
|
||||
return button.getWidth() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
boolean selected,
|
||||
MatrixStack matrixStack
|
||||
) {
|
||||
public void render(int mouseX, int mouseY, boolean selected, MatrixStack matrixStack) {
|
||||
RenderUtils.color(1f, 1f, 1f, 1f);
|
||||
|
||||
// Draw a lighter background for the hovered and the selected entry
|
||||
if (selected || this.isMouseOver(mouseX, mouseY)) {
|
||||
RenderUtils.drawRect(
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(150).color()
|
||||
);
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(150).color());
|
||||
} else if (this.isOdd) {
|
||||
RenderUtils.drawRect(
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(70).color()
|
||||
);
|
||||
this.x, this.y, this.width, this.height, ColorUtil.WHITE.withAlpha(70).color());
|
||||
} else {
|
||||
RenderUtils.drawRect(
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorUtil.WHITE.withAlpha(50).color()
|
||||
);
|
||||
this.x, this.y, this.width, this.height, ColorUtil.WHITE.withAlpha(50).color());
|
||||
}
|
||||
String name = this.tab.getName().config.getStringValue();
|
||||
this.drawString(
|
||||
this.x + 4,
|
||||
this.y + 7,
|
||||
ColorUtil.WHITE.color(),
|
||||
name,
|
||||
matrixStack
|
||||
);
|
||||
this.drawString(this.x + 4, this.y + 7, ColorUtil.WHITE.color(), name, matrixStack);
|
||||
|
||||
RenderUtils.color(1f, 1f, 1f, 1f);
|
||||
RenderSystem.disableBlend();
|
||||
@@ -124,25 +102,14 @@ public class WidgetTabEntry extends WidgetListEntryBase<ChatTab> {
|
||||
|
||||
@Override
|
||||
public void postRenderHovered(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
boolean selected,
|
||||
MatrixStack matrixStack
|
||||
) {
|
||||
int mouseX, int mouseY, boolean selected, MatrixStack matrixStack) {
|
||||
super.postRenderHovered(mouseX, mouseY, selected, matrixStack);
|
||||
|
||||
if (
|
||||
mouseX >= this.x &&
|
||||
mouseX < this.buttonStartX &&
|
||||
mouseY >= this.y &&
|
||||
mouseY <= this.y + this.height
|
||||
) {
|
||||
RenderUtils.drawHoverText(
|
||||
mouseX,
|
||||
mouseY,
|
||||
this.hoverLines,
|
||||
matrixStack
|
||||
);
|
||||
if (mouseX >= this.x
|
||||
&& mouseX < this.buttonStartX
|
||||
&& mouseY >= this.y
|
||||
&& mouseY <= this.y + this.height) {
|
||||
RenderUtils.drawHoverText(mouseX, mouseY, this.hoverLines, matrixStack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +124,7 @@ public class WidgetTabEntry extends WidgetListEntryBase<ChatTab> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedWithButton(
|
||||
ButtonBase button,
|
||||
int mouseButton
|
||||
) {
|
||||
public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
||||
if (type == Type.REMOVE) {
|
||||
HudConfigStorage.TABS.remove(parent.tab);
|
||||
parent.parent.refreshEntries();
|
||||
@@ -168,12 +132,7 @@ public class WidgetTabEntry extends WidgetListEntryBase<ChatTab> {
|
||||
}
|
||||
if (type == Type.CONFIGURE) {
|
||||
GuiBase.openGui(
|
||||
new GuiTabEditor(
|
||||
parent.parent.getParent(),
|
||||
parent.tab,
|
||||
parent.main
|
||||
)
|
||||
);
|
||||
new GuiTabEditor(parent.parent.getParent(), parent.tab, parent.main));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.gui;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -18,7 +25,6 @@ import io.github.darkkronicle.advancedchathud.HudChatMessageHolder;
|
||||
import io.github.darkkronicle.advancedchathud.config.HudConfigStorage;
|
||||
import io.github.darkkronicle.advancedchathud.tabs.AbstractChatTab;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
@@ -40,48 +46,38 @@ public class ChatWindow {
|
||||
|
||||
private int scrolledLines = 0;
|
||||
|
||||
@Getter
|
||||
private int y;
|
||||
@Getter private int y;
|
||||
|
||||
@Getter
|
||||
private int x;
|
||||
@Getter private int x;
|
||||
|
||||
@Getter
|
||||
private int width;
|
||||
@Getter private int width;
|
||||
|
||||
@Getter
|
||||
private int height;
|
||||
@Getter private int height;
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private HudConfigStorage.Visibility visibility = (HudConfigStorage.Visibility) HudConfigStorage.General.VISIBILITY.config.getOptionListValue();
|
||||
@Setter @Getter
|
||||
private HudConfigStorage.Visibility visibility =
|
||||
(HudConfigStorage.Visibility)
|
||||
HudConfigStorage.General.VISIBILITY.config.getOptionListValue();
|
||||
|
||||
private List<ChatMessage> lines;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean selected;
|
||||
@Getter @Setter private boolean selected;
|
||||
|
||||
@Getter
|
||||
private AbstractChatTab tab;
|
||||
@Getter private AbstractChatTab tab;
|
||||
|
||||
private static final Identifier X_ICON = new Identifier(
|
||||
AdvancedChatHud.MOD_ID,
|
||||
"textures/gui/chatwindow/x_icon.png"
|
||||
);
|
||||
private static final Identifier X_ICON =
|
||||
new Identifier(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/x_icon.png");
|
||||
|
||||
private static final Identifier RESIZE_ICON = new Identifier(
|
||||
AdvancedChatHud.MOD_ID,
|
||||
"textures/gui/chatwindow/resize_icon.png"
|
||||
);
|
||||
private static final Identifier RESIZE_ICON =
|
||||
new Identifier(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/resize_icon.png");
|
||||
|
||||
public ChatWindow(AbstractChatTab tab) {
|
||||
this.client = MinecraftClient.getInstance();
|
||||
this.y =
|
||||
client.getWindow().getScaledHeight() -
|
||||
HudConfigStorage.General.Y.config.getIntegerValue();
|
||||
client.getWindow().getScaledHeight()
|
||||
- HudConfigStorage.General.Y.config.getIntegerValue();
|
||||
this.x = HudConfigStorage.General.X.config.getIntegerValue();
|
||||
this.width = HudConfigStorage.General.WIDTH.config.getIntegerValue();
|
||||
this.height = HudConfigStorage.General.HEIGHT.config.getIntegerValue();
|
||||
@@ -96,9 +92,7 @@ public class ChatWindow {
|
||||
public void setTab(AbstractChatTab tab) {
|
||||
this.tab = tab;
|
||||
this.lines = new ArrayList<>();
|
||||
List<HudChatMessage> messages = HudChatMessageHolder
|
||||
.getInstance()
|
||||
.getMessages();
|
||||
List<HudChatMessage> messages = HudChatMessageHolder.getInstance().getMessages();
|
||||
for (int i = messages.size() - 1; i >= 0; i--) {
|
||||
addMessage(messages.get(i), false, false);
|
||||
}
|
||||
@@ -108,25 +102,18 @@ public class ChatWindow {
|
||||
this.addMessage(message, false, true);
|
||||
}
|
||||
|
||||
public void addMessage(
|
||||
HudChatMessage message,
|
||||
boolean force,
|
||||
boolean setTicks
|
||||
) {
|
||||
public void addMessage(HudChatMessage message, boolean force, boolean setTicks) {
|
||||
if (force || message.getTabs().contains(tab)) {
|
||||
ChatMessage newMessage = message
|
||||
.getMessage()
|
||||
.shallowClone(getPaddedWidth());
|
||||
ChatMessage newMessage = message.getMessage().shallowClone(getPaddedWidth());
|
||||
if (setTicks) {
|
||||
newMessage.setCreationTick(
|
||||
MinecraftClient.getInstance().inGameHud.getTicks()
|
||||
);
|
||||
newMessage.setCreationTick(MinecraftClient.getInstance().inGameHud.getTicks());
|
||||
}
|
||||
this.lines.add(0, newMessage);
|
||||
if (scrolledLines > 0) {
|
||||
scrolledLines++;
|
||||
}
|
||||
int visibleMessagesMaxSize = HudConfigStorage.General.STORED_LINES.config.getIntegerValue();
|
||||
int visibleMessagesMaxSize =
|
||||
HudConfigStorage.General.STORED_LINES.config.getIntegerValue();
|
||||
while (this.lines.size() > visibleMessagesMaxSize) {
|
||||
this.lines.remove(this.lines.size() - 1);
|
||||
}
|
||||
@@ -154,35 +141,16 @@ public class ChatWindow {
|
||||
}
|
||||
|
||||
private static void drawRect(
|
||||
MatrixStack stack,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color
|
||||
) {
|
||||
MatrixStack stack, int x, int y, int width, int height, int color) {
|
||||
DrawableHelper.fill(stack, x, y, x + width, y + height, color);
|
||||
}
|
||||
|
||||
private static void fill(
|
||||
MatrixStack stack,
|
||||
int x,
|
||||
int y,
|
||||
int x2,
|
||||
int y2,
|
||||
int color
|
||||
) {
|
||||
private static void fill(MatrixStack stack, int x, int y, int x2, int y2, int color) {
|
||||
DrawableHelper.fill(stack, x, y, x2, y2, color);
|
||||
}
|
||||
|
||||
private static void drawOutline(
|
||||
MatrixStack stack,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color
|
||||
) {
|
||||
MatrixStack stack, int x, int y, int width, int height, int color) {
|
||||
drawRect(stack, x, y, 1, height, color);
|
||||
drawRect(stack, x + width - 1, y, 1, height, color);
|
||||
drawRect(stack, x + 1, y, width - 2, 1, color);
|
||||
@@ -194,18 +162,14 @@ public class ChatWindow {
|
||||
}
|
||||
|
||||
public int getPaddedWidth() {
|
||||
return (
|
||||
getScaledWidth() -
|
||||
HudConfigStorage.General.LEFT_PAD.config.getIntegerValue() -
|
||||
HudConfigStorage.General.RIGHT_PAD.config.getIntegerValue() -
|
||||
headOffset()
|
||||
);
|
||||
return (getScaledWidth()
|
||||
- HudConfigStorage.General.LEFT_PAD.config.getIntegerValue()
|
||||
- HudConfigStorage.General.RIGHT_PAD.config.getIntegerValue()
|
||||
- headOffset());
|
||||
}
|
||||
|
||||
private int headOffset() {
|
||||
return HudConfigStorage.General.CHAT_HEADS.config.getBooleanValue()
|
||||
? 10
|
||||
: 0;
|
||||
return HudConfigStorage.General.CHAT_HEADS.config.getBooleanValue() ? 10 : 0;
|
||||
}
|
||||
|
||||
private int getActualY(int y) {
|
||||
@@ -217,13 +181,11 @@ public class ChatWindow {
|
||||
}
|
||||
|
||||
private int getPaddedLeftX() {
|
||||
return (
|
||||
getLeftX() +
|
||||
(int) Math.ceil(
|
||||
HudConfigStorage.General.LEFT_PAD.config.getIntegerValue() +
|
||||
headOffset()
|
||||
)
|
||||
);
|
||||
return (getLeftX()
|
||||
+ (int)
|
||||
Math.ceil(
|
||||
HudConfigStorage.General.LEFT_PAD.config.getIntegerValue()
|
||||
+ headOffset()));
|
||||
}
|
||||
|
||||
private double getScale() {
|
||||
@@ -235,10 +197,7 @@ public class ChatWindow {
|
||||
}
|
||||
|
||||
private int getPaddedRightX() {
|
||||
return (
|
||||
getRightX() -
|
||||
HudConfigStorage.General.RIGHT_PAD.config.getIntegerValue()
|
||||
);
|
||||
return (getRightX() - HudConfigStorage.General.RIGHT_PAD.config.getIntegerValue());
|
||||
}
|
||||
|
||||
public int getActualHeight() {
|
||||
@@ -262,12 +221,10 @@ public class ChatWindow {
|
||||
}
|
||||
|
||||
public boolean isMouseOver(double mouseX, double mouseY) {
|
||||
return (
|
||||
x <= mouseX &&
|
||||
x + width >= mouseX &&
|
||||
y >= mouseY &&
|
||||
y - getActualHeight() <= mouseY
|
||||
);
|
||||
return (x <= mouseX
|
||||
&& x + width >= mouseX
|
||||
&& y >= mouseY
|
||||
&& y - getActualHeight() <= mouseY);
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrixStack, int ticks, boolean focused) {
|
||||
@@ -278,8 +235,7 @@ public class ChatWindow {
|
||||
int lineCount = lines.size();
|
||||
int totalLines = getTotalLines();
|
||||
|
||||
boolean chatFocused =
|
||||
visibility == HudConfigStorage.Visibility.ALWAYS || focused;
|
||||
boolean chatFocused = visibility == HudConfigStorage.Visibility.ALWAYS || focused;
|
||||
|
||||
if (scrolledLines > totalLines) {
|
||||
scrolledLines = totalLines;
|
||||
@@ -296,11 +252,11 @@ public class ChatWindow {
|
||||
int padLX = getPaddedLeftX();
|
||||
int rightX = getRightX();
|
||||
int padRX = getPaddedRightX();
|
||||
LimitedInteger y = new LimitedInteger(
|
||||
getScaledHeight() -
|
||||
HudConfigStorage.General.TOP_PAD.config.getIntegerValue(),
|
||||
HudConfigStorage.General.BOTTOM_PAD.config.getIntegerValue()
|
||||
);
|
||||
LimitedInteger y =
|
||||
new LimitedInteger(
|
||||
getScaledHeight()
|
||||
- HudConfigStorage.General.TOP_PAD.config.getIntegerValue(),
|
||||
HudConfigStorage.General.BOTTOM_PAD.config.getIntegerValue());
|
||||
|
||||
for (int j = 0; j < this.lines.size(); j++) {
|
||||
ChatMessage message = this.lines.get(j);
|
||||
@@ -311,42 +267,35 @@ public class ChatWindow {
|
||||
if (lines < scrolledLines) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
!y.incrementIfPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue()
|
||||
)
|
||||
) {
|
||||
if (!y.incrementIfPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue())) {
|
||||
break;
|
||||
}
|
||||
ChatMessage.AdvancedChatLine line = message.getLines().get(i);
|
||||
drawLine(
|
||||
matrixStack,
|
||||
line,
|
||||
leftX,
|
||||
y.getValue(),
|
||||
padLX,
|
||||
padRX,
|
||||
lineIndex,
|
||||
j,
|
||||
renderedLines,
|
||||
chatFocused,
|
||||
ticks
|
||||
);
|
||||
matrixStack,
|
||||
line,
|
||||
leftX,
|
||||
y.getValue(),
|
||||
padLX,
|
||||
padRX,
|
||||
lineIndex,
|
||||
j,
|
||||
renderedLines,
|
||||
chatFocused,
|
||||
ticks);
|
||||
renderedLines++;
|
||||
}
|
||||
if (lines >= scrolledLines) {
|
||||
if (lines == lineCount) {
|
||||
break;
|
||||
}
|
||||
if (
|
||||
!y.isPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue() +
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue()
|
||||
) ||
|
||||
!y.incrementIfPossible(
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue()
|
||||
)
|
||||
) {
|
||||
if (!y.isPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue()
|
||||
+ HudConfigStorage.General.MESSAGE_SPACE.config
|
||||
.getIntegerValue())
|
||||
|| !y.incrementIfPossible(
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -360,206 +309,185 @@ public class ChatWindow {
|
||||
tab.resetUnread();
|
||||
}
|
||||
drawOutline(
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(0) - scaledHeight - 1,
|
||||
scaledWidth,
|
||||
scaledHeight + 1,
|
||||
tab.getBorderColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(0) - scaledHeight - 1,
|
||||
scaledWidth,
|
||||
scaledHeight + 1,
|
||||
tab.getBorderColor().color());
|
||||
int scaledBar = getBarHeight();
|
||||
int newY = getScaledHeight() + scaledBar;
|
||||
String label = tab.getAbreviation();
|
||||
int labelWidth = StringUtils.getStringWidth(label) + 8;
|
||||
drawRect(
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(newY),
|
||||
labelWidth,
|
||||
scaledBar,
|
||||
tab.getMainColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(newY),
|
||||
labelWidth,
|
||||
scaledBar,
|
||||
tab.getMainColor().color());
|
||||
drawOutline(
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(newY),
|
||||
labelWidth,
|
||||
scaledBar,
|
||||
tab.getBorderColor().withAlpha(180).color()
|
||||
);
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(newY),
|
||||
labelWidth,
|
||||
scaledBar,
|
||||
tab.getBorderColor().withAlpha(180).color());
|
||||
DrawableHelper.drawCenteredText(
|
||||
matrixStack,
|
||||
MinecraftClient.getInstance().textRenderer,
|
||||
tab.getAbreviation(),
|
||||
leftX + (labelWidth) / 2,
|
||||
getActualY(newY - 3),
|
||||
ColorUtil.WHITE.color()
|
||||
);
|
||||
matrixStack,
|
||||
MinecraftClient.getInstance().textRenderer,
|
||||
tab.getAbreviation(),
|
||||
leftX + (labelWidth) / 2,
|
||||
getActualY(newY - 3),
|
||||
ColorUtil.WHITE.color());
|
||||
drawRect(
|
||||
matrixStack,
|
||||
leftX + labelWidth,
|
||||
getActualY(newY),
|
||||
getScaledWidth() - labelWidth,
|
||||
scaledBar,
|
||||
selected
|
||||
? tab.getMainColor().color()
|
||||
: tab.getInnerColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
leftX + labelWidth,
|
||||
getActualY(newY),
|
||||
getScaledWidth() - labelWidth,
|
||||
scaledBar,
|
||||
selected ? tab.getMainColor().color() : tab.getInnerColor().color());
|
||||
drawOutline(
|
||||
matrixStack,
|
||||
leftX + labelWidth,
|
||||
getActualY(newY),
|
||||
getScaledWidth() - labelWidth,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
leftX + labelWidth,
|
||||
getActualY(newY),
|
||||
getScaledWidth() - labelWidth,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color());
|
||||
|
||||
drawOutline(
|
||||
matrixStack,
|
||||
rightX - scaledBar,
|
||||
getActualY(newY),
|
||||
scaledBar,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
rightX - scaledBar,
|
||||
getActualY(newY),
|
||||
scaledBar,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color());
|
||||
drawOutline(
|
||||
matrixStack,
|
||||
rightX - scaledBar * 2 + 1,
|
||||
getActualY(newY),
|
||||
scaledBar,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
rightX - scaledBar * 2 + 1,
|
||||
getActualY(newY),
|
||||
scaledBar,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color());
|
||||
drawOutline(
|
||||
matrixStack,
|
||||
rightX - scaledBar * 3 + 2,
|
||||
getActualY(newY),
|
||||
scaledBar,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
rightX - scaledBar * 3 + 2,
|
||||
getActualY(newY),
|
||||
scaledBar,
|
||||
scaledBar,
|
||||
tab.getBorderColor().color());
|
||||
|
||||
// Close
|
||||
RenderUtils.color(1, 1, 1, 1);
|
||||
RenderUtils.bindTexture(X_ICON);
|
||||
DrawableHelper.drawTexture(
|
||||
matrixStack,
|
||||
rightX - scaledBar + 1,
|
||||
getActualY(newY - 1),
|
||||
scaledBar - 2,
|
||||
scaledBar - 2,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32,
|
||||
32,
|
||||
32
|
||||
);
|
||||
matrixStack,
|
||||
rightX - scaledBar + 1,
|
||||
getActualY(newY - 1),
|
||||
scaledBar - 2,
|
||||
scaledBar - 2,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32,
|
||||
32,
|
||||
32);
|
||||
|
||||
// Resize
|
||||
RenderUtils.color(1, 1, 1, 1);
|
||||
RenderUtils.bindTexture(RESIZE_ICON);
|
||||
DrawableHelper.drawTexture(
|
||||
matrixStack,
|
||||
rightX - scaledBar * 2 + 2,
|
||||
getActualY(newY - 1),
|
||||
scaledBar - 2,
|
||||
scaledBar - 2,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32,
|
||||
32,
|
||||
32
|
||||
);
|
||||
matrixStack,
|
||||
rightX - scaledBar * 2 + 2,
|
||||
getActualY(newY - 1),
|
||||
scaledBar - 2,
|
||||
scaledBar - 2,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32,
|
||||
32,
|
||||
32);
|
||||
|
||||
// Visibility
|
||||
RenderUtils.bindTexture(visibility.getTexture());
|
||||
DrawableHelper.drawTexture(
|
||||
matrixStack,
|
||||
rightX - scaledBar * 3 + 3,
|
||||
getActualY(newY - 1),
|
||||
scaledBar - 2,
|
||||
scaledBar - 2,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32,
|
||||
32,
|
||||
32
|
||||
);
|
||||
matrixStack,
|
||||
rightX - scaledBar * 3 + 3,
|
||||
getActualY(newY - 1),
|
||||
scaledBar - 2,
|
||||
scaledBar - 2,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32,
|
||||
32,
|
||||
32);
|
||||
|
||||
double mouseX = client.mouse.getX() / 2;
|
||||
double mouseY = client.mouse.getY() / 2;
|
||||
if (isMouseOverVisibility(mouseX, mouseY)) {
|
||||
DrawableHelper.drawStringWithShadow(
|
||||
matrixStack,
|
||||
client.textRenderer,
|
||||
visibility.getDisplayName(),
|
||||
(int) (mouseX / getScale() + 4),
|
||||
(int) (mouseY / getScale() - 16),
|
||||
ColorUtil.WHITE.color()
|
||||
);
|
||||
matrixStack,
|
||||
client.textRenderer,
|
||||
visibility.getDisplayName(),
|
||||
(int) (mouseX / getScale() + 4),
|
||||
(int) (mouseY / getScale() - 16),
|
||||
ColorUtil.WHITE.color());
|
||||
}
|
||||
}
|
||||
|
||||
if (chatFocused) {
|
||||
fill(
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(y.getValue()),
|
||||
rightX,
|
||||
getActualY(getScaledHeight()),
|
||||
tab.getInnerColor().color()
|
||||
);
|
||||
matrixStack,
|
||||
leftX,
|
||||
getActualY(y.getValue()),
|
||||
rightX,
|
||||
getActualY(getScaledHeight()),
|
||||
tab.getInnerColor().color());
|
||||
// Scroll bar
|
||||
float add = (float) (scrolledLines) / (totalLines + 1);
|
||||
int scrollHeight = (int) (add * getScaledHeight());
|
||||
drawRect(
|
||||
matrixStack,
|
||||
getScaledWidth() + leftX - 1,
|
||||
getActualY(scrollHeight + 10),
|
||||
1,
|
||||
10,
|
||||
ColorUtil.WHITE.color()
|
||||
);
|
||||
matrixStack,
|
||||
getScaledWidth() + leftX - 1,
|
||||
getActualY(scrollHeight + 10),
|
||||
1,
|
||||
10,
|
||||
ColorUtil.WHITE.color());
|
||||
}
|
||||
matrixStack.pop();
|
||||
}
|
||||
|
||||
private void drawLine(
|
||||
MatrixStack matrixStack,
|
||||
ChatMessage.AdvancedChatLine line,
|
||||
int x,
|
||||
int y,
|
||||
int pLX,
|
||||
int pRX,
|
||||
int lineIndex,
|
||||
int messageIndex,
|
||||
int renderedLines,
|
||||
boolean focused,
|
||||
int ticks
|
||||
) {
|
||||
MatrixStack matrixStack,
|
||||
ChatMessage.AdvancedChatLine line,
|
||||
int x,
|
||||
int y,
|
||||
int pLX,
|
||||
int pRX,
|
||||
int lineIndex,
|
||||
int messageIndex,
|
||||
int renderedLines,
|
||||
boolean focused,
|
||||
int ticks) {
|
||||
int height = HudConfigStorage.General.LINE_SPACE.config.getIntegerValue();
|
||||
if (renderedLines == 0) {
|
||||
if (focused) {
|
||||
height +=
|
||||
HudConfigStorage.General.BOTTOM_PAD.config.getIntegerValue();
|
||||
height += HudConfigStorage.General.BOTTOM_PAD.config.getIntegerValue();
|
||||
}
|
||||
} else if (lineIndex == 0) {
|
||||
height +=
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue();
|
||||
height += HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue();
|
||||
// Start of a line
|
||||
}
|
||||
ColorUtil.SimpleColor background = line.getParent().getBackground();
|
||||
ColorUtil.SimpleColor text = HudConfigStorage.General.EMPTY_TEXT_COLOR.config.getSimpleColor();
|
||||
ColorUtil.SimpleColor text =
|
||||
HudConfigStorage.General.EMPTY_TEXT_COLOR.config.getSimpleColor();
|
||||
if (background == null) {
|
||||
background = tab.getInnerColor();
|
||||
}
|
||||
if (
|
||||
messageIndex % 2 == 0 &&
|
||||
HudConfigStorage.General.ALTERNATE_LINES.config.getBooleanValue()
|
||||
) {
|
||||
if (messageIndex % 2 == 0
|
||||
&& HudConfigStorage.General.ALTERNATE_LINES.config.getBooleanValue()) {
|
||||
if (background.alpha() <= 215) {
|
||||
background = background.withAlpha(background.alpha() + 40);
|
||||
} else {
|
||||
@@ -570,20 +498,21 @@ public class ChatWindow {
|
||||
if (!focused) {
|
||||
// Find fade percentage
|
||||
int fadeStart = HudConfigStorage.General.FADE_START.config.getIntegerValue();
|
||||
int fadeStop =
|
||||
fadeStart +
|
||||
HudConfigStorage.General.FADE_TIME.config.getIntegerValue();
|
||||
int fadeStop = fadeStart + HudConfigStorage.General.FADE_TIME.config.getIntegerValue();
|
||||
int timeAlive = ticks - line.getParent().getCreationTick();
|
||||
float percent = (float) Math.min(
|
||||
1,
|
||||
(double) (timeAlive - fadeStart) /
|
||||
(double) (fadeStop - fadeStart)
|
||||
);
|
||||
float percent =
|
||||
(float)
|
||||
Math.min(
|
||||
1,
|
||||
(double) (timeAlive - fadeStart)
|
||||
/ (double) (fadeStop - fadeStart));
|
||||
applied =
|
||||
1 -
|
||||
(float) (
|
||||
(EasingMethod) HudConfigStorage.General.FADE_TYPE.config.getOptionListValue()
|
||||
).apply(percent);
|
||||
1
|
||||
- (float)
|
||||
((EasingMethod)
|
||||
HudConfigStorage.General.FADE_TYPE.config
|
||||
.getOptionListValue())
|
||||
.apply(percent);
|
||||
applied = Math.max(0, applied);
|
||||
if (applied <= 0) {
|
||||
return;
|
||||
@@ -602,85 +531,37 @@ public class ChatWindow {
|
||||
Style style = Style.EMPTY;
|
||||
TextColor color = TextColor.fromRgb(ColorUtil.GRAY.color());
|
||||
style = style.withColor(color);
|
||||
toPrint
|
||||
.getRawTexts()
|
||||
.add(
|
||||
new RawText(
|
||||
" (" + (line.getParent().getStacks() + 1) + ")",
|
||||
style
|
||||
)
|
||||
);
|
||||
toPrint.getRawTexts()
|
||||
.add(new RawText(" (" + (line.getParent().getStacks() + 1) + ")", style));
|
||||
render = toPrint;
|
||||
}
|
||||
|
||||
int backgroundWidth;
|
||||
|
||||
if (
|
||||
!focused &&
|
||||
HudConfigStorage.General.HUD_LINE_TYPE.config.getOptionListValue() ==
|
||||
HudConfigStorage.HudLineType.COMPACT
|
||||
) {
|
||||
backgroundWidth =
|
||||
client.textRenderer.getWidth(render) + 4 + headOffset();
|
||||
if (!focused
|
||||
&& HudConfigStorage.General.HUD_LINE_TYPE.config.getOptionListValue()
|
||||
== HudConfigStorage.HudLineType.COMPACT) {
|
||||
backgroundWidth = client.textRenderer.getWidth(render) + 4 + headOffset();
|
||||
} else {
|
||||
backgroundWidth = getScaledWidth();
|
||||
}
|
||||
|
||||
// Draw background
|
||||
drawRect(
|
||||
matrixStack,
|
||||
x,
|
||||
getActualY(y),
|
||||
backgroundWidth,
|
||||
height,
|
||||
background.color()
|
||||
);
|
||||
if (
|
||||
lineIndex == line.getParent().getLineCount() - 1 &&
|
||||
line.getParent().getOwner() != null &&
|
||||
HudConfigStorage.General.CHAT_HEADS.config.getBooleanValue()
|
||||
) {
|
||||
drawRect(matrixStack, x, getActualY(y), backgroundWidth, height, background.color());
|
||||
if (lineIndex == line.getParent().getLineCount() - 1
|
||||
&& line.getParent().getOwner() != null
|
||||
&& HudConfigStorage.General.CHAT_HEADS.config.getBooleanValue()) {
|
||||
RenderSystem.setShaderColor(1, 1, 1, applied);
|
||||
RenderSystem.setShaderTexture(
|
||||
0,
|
||||
line.getParent().getOwner().getTexture()
|
||||
);
|
||||
RenderSystem.setShaderTexture(0, line.getParent().getOwner().getTexture());
|
||||
DrawableHelper.drawTexture(
|
||||
matrixStack,
|
||||
pLX - 10,
|
||||
getActualY(y),
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
64,
|
||||
64
|
||||
);
|
||||
matrixStack, pLX - 10, getActualY(y), 8, 8, 8, 8, 8, 8, 64, 64);
|
||||
DrawableHelper.drawTexture(
|
||||
matrixStack,
|
||||
pLX - 10,
|
||||
getActualY(y),
|
||||
8,
|
||||
8,
|
||||
40,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
64,
|
||||
64
|
||||
);
|
||||
matrixStack, pLX - 10, getActualY(y), 8, 8, 40, 8, 8, 8, 64, 64);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
client.textRenderer.drawWithShadow(
|
||||
matrixStack,
|
||||
render.asOrderedText(),
|
||||
pLX,
|
||||
getActualY(y) + 1,
|
||||
text.color()
|
||||
);
|
||||
matrixStack, render.asOrderedText(), pLX, getActualY(y) + 1, text.color());
|
||||
}
|
||||
|
||||
public Style getText(double mouseX, double mouseY) {
|
||||
@@ -701,10 +582,10 @@ public class ChatWindow {
|
||||
|
||||
int lines = 0;
|
||||
int lineCount = this.lines.size();
|
||||
LimitedInteger y = new LimitedInteger(
|
||||
getScaledHeight(),
|
||||
HudConfigStorage.General.BOTTOM_PAD.config.getIntegerValue()
|
||||
);
|
||||
LimitedInteger y =
|
||||
new LimitedInteger(
|
||||
getScaledHeight(),
|
||||
HudConfigStorage.General.BOTTOM_PAD.config.getIntegerValue());
|
||||
for (ChatMessage message : this.lines) {
|
||||
// To get the proper index of reversed
|
||||
for (int i = message.getLineCount() - 1; i >= 0; i--) {
|
||||
@@ -712,39 +593,32 @@ public class ChatWindow {
|
||||
if (lines < scrolledLines) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
!y.incrementIfPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue()
|
||||
)
|
||||
) {
|
||||
if (!y.incrementIfPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue())) {
|
||||
break;
|
||||
}
|
||||
if (
|
||||
trueY <= y.getValue() &&
|
||||
trueY >=
|
||||
y.getValue() -
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue()
|
||||
) {
|
||||
ChatMessage.AdvancedChatLine line = message
|
||||
.getLines()
|
||||
.get(i);
|
||||
return this.client.textRenderer.getTextHandler()
|
||||
.getStyleAt(line.getText(), (int) trueX);
|
||||
if (trueY <= y.getValue()
|
||||
&& trueY
|
||||
>= y.getValue()
|
||||
- HudConfigStorage.General.LINE_SPACE.config
|
||||
.getIntegerValue()) {
|
||||
ChatMessage.AdvancedChatLine line = message.getLines().get(i);
|
||||
return this.client
|
||||
.textRenderer
|
||||
.getTextHandler()
|
||||
.getStyleAt(line.getText(), (int) trueX);
|
||||
}
|
||||
}
|
||||
if (lines >= scrolledLines) {
|
||||
if (lines == lineCount) {
|
||||
break;
|
||||
}
|
||||
if (
|
||||
!y.isPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue() +
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue()
|
||||
) ||
|
||||
!y.incrementIfPossible(
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue()
|
||||
)
|
||||
) {
|
||||
if (!y.isPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue()
|
||||
+ HudConfigStorage.General.MESSAGE_SPACE.config
|
||||
.getIntegerValue())
|
||||
|| !y.incrementIfPossible(
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -753,17 +627,15 @@ public class ChatWindow {
|
||||
}
|
||||
|
||||
public boolean isMouseOverDragBar(double mouseX, double mouseY) {
|
||||
return (
|
||||
isMouseOver(mouseX, mouseY) &&
|
||||
mouseX <= x + width - (getScaledBarHeight() * 3) &&
|
||||
mouseY <= y - height
|
||||
);
|
||||
return (isMouseOver(mouseX, mouseY)
|
||||
&& mouseX <= x + width - (getScaledBarHeight() * 3)
|
||||
&& mouseY <= y - height);
|
||||
}
|
||||
|
||||
public boolean onMouseClicked(double mouseX, double mouseY, int button) {
|
||||
boolean onButtons =
|
||||
isMouseOverDragBar(mouseX - (getScaledBarHeight() * 3), mouseY) &&
|
||||
mouseX >= x + width - getScaledBarHeight() * 3;
|
||||
isMouseOverDragBar(mouseX - (getScaledBarHeight() * 3), mouseY)
|
||||
&& mouseX >= x + width - getScaledBarHeight() * 3;
|
||||
if (!onButtons) {
|
||||
return false;
|
||||
}
|
||||
@@ -776,32 +648,24 @@ public class ChatWindow {
|
||||
// Visibility
|
||||
visibility = visibility.cycle(true);
|
||||
}
|
||||
this.client.getSoundManager()
|
||||
.play(
|
||||
PositionedSoundInstance.master(
|
||||
SoundEvents.UI_BUTTON_CLICK,
|
||||
1.0F
|
||||
)
|
||||
);
|
||||
this.client
|
||||
.getSoundManager()
|
||||
.play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isMouseOverResize(double mouseX, double mouseY) {
|
||||
return (
|
||||
isMouseOver(mouseX, mouseY) &&
|
||||
mouseX >= x + width - (getScaledBarHeight() * 2) &&
|
||||
mouseX <= x + width - (getScaledBarHeight()) &&
|
||||
mouseY <= y - height
|
||||
);
|
||||
return (isMouseOver(mouseX, mouseY)
|
||||
&& mouseX >= x + width - (getScaledBarHeight() * 2)
|
||||
&& mouseX <= x + width - (getScaledBarHeight())
|
||||
&& mouseY <= y - height);
|
||||
}
|
||||
|
||||
public boolean isMouseOverVisibility(double mouseX, double mouseY) {
|
||||
return (
|
||||
isMouseOver(mouseX, mouseY) &&
|
||||
mouseX >= x + width - (getScaledBarHeight() * 3) &&
|
||||
mouseX <= x + width - (getScaledBarHeight() * 2) &&
|
||||
mouseY <= y - height
|
||||
);
|
||||
return (isMouseOver(mouseX, mouseY)
|
||||
&& mouseX >= x + width - (getScaledBarHeight() * 3)
|
||||
&& mouseX <= x + width - (getScaledBarHeight() * 2)
|
||||
&& mouseY <= y - height);
|
||||
}
|
||||
|
||||
public void setDimensions(int width, int height) {
|
||||
@@ -816,9 +680,7 @@ public class ChatWindow {
|
||||
ChatMessage toRemove = null;
|
||||
for (ChatMessage line : lines) {
|
||||
if (message.getMessage().isSimilar(line)) {
|
||||
if (
|
||||
!ConfigStorage.General.CHAT_STACK_UPDATE.config.getBooleanValue()
|
||||
) {
|
||||
if (!ConfigStorage.General.CHAT_STACK_UPDATE.config.getBooleanValue()) {
|
||||
// Just update the message and don't resend it
|
||||
line.setStacks(message.getMessage().getStacks());
|
||||
return;
|
||||
@@ -849,26 +711,16 @@ public class ChatWindow {
|
||||
UUID uuid = UUID.fromString(uuidEl);
|
||||
AbstractChatTab tab = AdvancedChatHud.MAIN_CHAT_TAB.fromUUID(uuid);
|
||||
if (tab == null) {
|
||||
AdvancedChatHud.LOGGER.warn(
|
||||
"Tab with UUID " + uuidEl + " could not be found!"
|
||||
);
|
||||
AdvancedChatHud.LOGGER.warn("Tab with UUID " + uuidEl + " could not be found!");
|
||||
return null;
|
||||
}
|
||||
ChatWindow window = new ChatWindow(tab);
|
||||
window.setSelected(obj.get("selected").getAsBoolean());
|
||||
window.setPosition(
|
||||
obj.get("x").getAsInt(),
|
||||
obj.get("y").getAsInt()
|
||||
);
|
||||
window.setPosition(obj.get("x").getAsInt(), obj.get("y").getAsInt());
|
||||
window.setVisibility(
|
||||
HudConfigStorage.Visibility.fromVisibilityString(
|
||||
obj.get("visibility").getAsString()
|
||||
)
|
||||
);
|
||||
window.setDimensions(
|
||||
obj.get("width").getAsInt(),
|
||||
obj.get("height").getAsInt()
|
||||
);
|
||||
HudConfigStorage.Visibility.fromVisibilityString(
|
||||
obj.get("visibility").getAsString()));
|
||||
window.setDimensions(obj.get("width").getAsInt(), obj.get("height").getAsInt());
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -879,14 +731,8 @@ public class ChatWindow {
|
||||
obj.addProperty("y", chatWindow.getY());
|
||||
obj.addProperty("width", chatWindow.getWidth());
|
||||
obj.addProperty("height", chatWindow.getHeight());
|
||||
obj.addProperty(
|
||||
"visibility",
|
||||
chatWindow.getVisibility().getStringValue()
|
||||
);
|
||||
obj.addProperty(
|
||||
"tabuuid",
|
||||
chatWindow.getTab().getUuid().toString()
|
||||
);
|
||||
obj.addProperty("visibility", chatWindow.getVisibility().getStringValue());
|
||||
obj.addProperty("tabuuid", chatWindow.getTab().getUuid().toString());
|
||||
obj.addProperty("selected", chatWindow.isSelected());
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.gui;
|
||||
|
||||
import io.github.darkkronicle.advancedchatcore.chat.AdvancedChatScreen;
|
||||
@@ -22,10 +29,7 @@ public class HudSection extends AdvancedChatScreenSection {
|
||||
ColorUtil.SimpleColor baseColor;
|
||||
ChatWindow sel = WindowManager.getInstance().getSelected();
|
||||
if (sel == null) {
|
||||
baseColor =
|
||||
HudConfigStorage.MAIN_TAB
|
||||
.getInnerColor()
|
||||
.config.getSimpleColor();
|
||||
baseColor = HudConfigStorage.MAIN_TAB.getInnerColor().config.getSimpleColor();
|
||||
} else {
|
||||
baseColor = sel.getTab().getInnerColor();
|
||||
}
|
||||
@@ -36,10 +40,7 @@ public class HudSection extends AdvancedChatScreenSection {
|
||||
public void initGui() {
|
||||
int x = 2;
|
||||
int space = 2;
|
||||
int y =
|
||||
MinecraftClient.getInstance().getWindow().getScaledHeight() -
|
||||
15 -
|
||||
11;
|
||||
int y = MinecraftClient.getInstance().getWindow().getScaledHeight() - 15 - 11;
|
||||
for (AbstractChatTab tab : AdvancedChatHud.MAIN_CHAT_TAB.getAllChatTabs()) {
|
||||
TabButton button = TabButton.fromTab(tab, x, y);
|
||||
getScreen().addButton(button, null);
|
||||
@@ -49,33 +50,18 @@ public class HudSection extends AdvancedChatScreenSection {
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
return WindowManager
|
||||
.getInstance()
|
||||
.mouseClicked(getScreen(), mouseX, mouseY, button);
|
||||
return WindowManager.getInstance().mouseClicked(getScreen(), mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(
|
||||
double mouseX,
|
||||
double mouseY,
|
||||
int mouseButton
|
||||
) {
|
||||
return WindowManager
|
||||
.getInstance()
|
||||
.mouseReleased(mouseX, mouseY, mouseButton);
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) {
|
||||
return WindowManager.getInstance().mouseReleased(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(
|
||||
double mouseX,
|
||||
double mouseY,
|
||||
int button,
|
||||
double deltaX,
|
||||
double deltaY
|
||||
) {
|
||||
return WindowManager
|
||||
.getInstance()
|
||||
.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
||||
double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||
return WindowManager.getInstance().mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.gui;
|
||||
|
||||
import fi.dy.masa.malilib.render.RenderUtils;
|
||||
@@ -13,24 +20,13 @@ public class TabButton extends CleanButton {
|
||||
|
||||
private final AbstractChatTab tab;
|
||||
|
||||
private TabButton(
|
||||
AbstractChatTab tab,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height
|
||||
) {
|
||||
private TabButton(AbstractChatTab tab, int x, int y, int width, int height) {
|
||||
super(x, y, width, height, tab.getMainColor(), tab.getAbreviation());
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
boolean selected,
|
||||
MatrixStack matrixStack
|
||||
) {
|
||||
public void render(int mouseX, int mouseY, boolean selected, MatrixStack matrixStack) {
|
||||
int relMX = mouseX - x;
|
||||
int relMY = mouseY - y;
|
||||
hovered = relMX >= 0 && relMX <= width && relMY >= 0 && relMY <= height;
|
||||
@@ -45,52 +41,29 @@ public class TabButton extends CleanButton {
|
||||
}
|
||||
RenderUtils.drawRect(x, y, width - height, height, color.color());
|
||||
RenderUtils.drawOutline(
|
||||
x,
|
||||
y,
|
||||
width - height + 1,
|
||||
height,
|
||||
ColorUtil.BLACK.withAlpha(180).color()
|
||||
);
|
||||
RenderUtils.drawRect(
|
||||
x + width - height,
|
||||
y,
|
||||
height,
|
||||
height,
|
||||
plusBack.color()
|
||||
);
|
||||
ColorUtil.SimpleColor crossColor = ColorUtil.WHITE.withAlpha(
|
||||
plusBack.alpha()
|
||||
);
|
||||
x, y, width - height + 1, height, ColorUtil.BLACK.withAlpha(180).color());
|
||||
RenderUtils.drawRect(x + width - height, y, height, height, plusBack.color());
|
||||
ColorUtil.SimpleColor crossColor = ColorUtil.WHITE.withAlpha(plusBack.alpha());
|
||||
RenderUtils.drawVerticalLine(
|
||||
x + width - (int) Math.floor((float) height / 2) - 1,
|
||||
y + 1,
|
||||
height - 2,
|
||||
crossColor.color()
|
||||
);
|
||||
x + width - (int) Math.floor((float) height / 2) - 1,
|
||||
y + 1,
|
||||
height - 2,
|
||||
crossColor.color());
|
||||
RenderUtils.drawHorizontalLine(
|
||||
x + width - height + 1,
|
||||
y + (int) Math.floor((float) height / 2),
|
||||
height - 2,
|
||||
crossColor.color()
|
||||
);
|
||||
x + width - height + 1,
|
||||
y + (int) Math.floor((float) height / 2),
|
||||
height - 2,
|
||||
crossColor.color());
|
||||
RenderUtils.drawOutline(
|
||||
x + width - height,
|
||||
y,
|
||||
height,
|
||||
height,
|
||||
ColorUtil.BLACK.withAlpha(180).color()
|
||||
);
|
||||
x + width - height, y, height, height, ColorUtil.BLACK.withAlpha(180).color());
|
||||
|
||||
int center = tab.isShowUnread()
|
||||
? ((width - 20 - height) / 2)
|
||||
: ((width - height) / 2);
|
||||
int center = tab.isShowUnread() ? ((width - 20 - height) / 2) : ((width - height) / 2);
|
||||
drawCenteredString(
|
||||
x + center,
|
||||
(y + (height / 2) - 3),
|
||||
ColorUtil.WHITE.color(),
|
||||
displayString,
|
||||
matrixStack
|
||||
);
|
||||
x + center,
|
||||
(y + (height / 2) - 3),
|
||||
ColorUtil.WHITE.color(),
|
||||
displayString,
|
||||
matrixStack);
|
||||
if (tab.isShowUnread() && tab.getUnread() > 0) {
|
||||
String unread;
|
||||
if (tab.getUnread() <= 99) {
|
||||
@@ -99,28 +72,19 @@ public class TabButton extends CleanButton {
|
||||
unread = "99+";
|
||||
}
|
||||
drawString(
|
||||
x + width - height - 16,
|
||||
(y + (height / 2) - 3),
|
||||
ColorUtil.WHITE.color(),
|
||||
unread,
|
||||
matrixStack
|
||||
);
|
||||
x + width - height - 16,
|
||||
(y + (height / 2) - 3),
|
||||
ColorUtil.WHITE.color(),
|
||||
unread,
|
||||
matrixStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onMouseClickedImpl(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
int mouseButton
|
||||
) {
|
||||
this.mc.getSoundManager()
|
||||
.play(
|
||||
PositionedSoundInstance.master(
|
||||
SoundEvents.UI_BUTTON_CLICK,
|
||||
1.0F
|
||||
)
|
||||
);
|
||||
protected boolean onMouseClickedImpl(int mouseX, int mouseY, int mouseButton) {
|
||||
this.mc
|
||||
.getSoundManager()
|
||||
.play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
if (mouseX - x >= width - height) {
|
||||
// Plus button
|
||||
WindowManager.getInstance().onTabAddButton(tab);
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.gui;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import fi.dy.masa.malilib.interfaces.IRenderer;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.AdvancedChatScreen;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.ChatMessage;
|
||||
import io.github.darkkronicle.advancedchathud.AdvancedChatHud;
|
||||
import io.github.darkkronicle.advancedchathud.HudChatMessage;
|
||||
import io.github.darkkronicle.advancedchathud.tabs.AbstractChatTab;
|
||||
@@ -59,10 +65,7 @@ public class WindowManager implements IRenderer {
|
||||
continue;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
AdvancedChatHud.LOGGER.error(
|
||||
"Error while loading in ChatWindow ",
|
||||
err
|
||||
);
|
||||
AdvancedChatHud.LOGGER.error("Error while loading in ChatWindow ", err);
|
||||
continue;
|
||||
}
|
||||
windows.add(w);
|
||||
@@ -81,13 +84,7 @@ public class WindowManager implements IRenderer {
|
||||
@Override
|
||||
public void onRenderGameOverlayPost(MatrixStack matrixStack) {
|
||||
for (int i = windows.size() - 1; i >= 0; i--) {
|
||||
windows
|
||||
.get(i)
|
||||
.render(
|
||||
matrixStack,
|
||||
client.inGameHud.getTicks(),
|
||||
isChatFocused()
|
||||
);
|
||||
windows.get(i).render(matrixStack, client.inGameHud.getTicks(), isChatFocused());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,12 +140,7 @@ public class WindowManager implements IRenderer {
|
||||
windows.addFirst(window);
|
||||
}
|
||||
|
||||
public boolean mouseClicked(
|
||||
Screen screen,
|
||||
double mouseX,
|
||||
double mouseY,
|
||||
int button
|
||||
) {
|
||||
public boolean mouseClicked(Screen screen, double mouseX, double mouseY, int button) {
|
||||
ChatWindow over = null;
|
||||
for (ChatWindow w : windows) {
|
||||
if (w.isMouseOver(mouseX, mouseY)) {
|
||||
@@ -184,20 +176,11 @@ public class WindowManager implements IRenderer {
|
||||
}
|
||||
|
||||
public boolean mouseDragged(
|
||||
double mouseX,
|
||||
double mouseY,
|
||||
int button,
|
||||
double deltaX,
|
||||
double deltaY
|
||||
) {
|
||||
double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||
if (drag != null && !resize) {
|
||||
int x = Math.max((int) mouseX - dragX, 0);
|
||||
int y = Math.max((int) mouseY - dragY, drag.getActualHeight());
|
||||
x =
|
||||
Math.min(
|
||||
x,
|
||||
client.getWindow().getScaledWidth() - drag.getWidth()
|
||||
);
|
||||
x = Math.min(x, client.getWindow().getScaledWidth() - drag.getWidth());
|
||||
y = Math.min(y, client.getWindow().getScaledHeight());
|
||||
drag.setPosition(x, y);
|
||||
return true;
|
||||
@@ -210,11 +193,7 @@ public class WindowManager implements IRenderer {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean mouseReleased(
|
||||
double mouseX,
|
||||
double mouseY,
|
||||
int mouseButton
|
||||
) {
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) {
|
||||
if (drag != null) {
|
||||
drag = null;
|
||||
return true;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.mixin;
|
||||
|
||||
import io.github.darkkronicle.advancedchathud.gui.WindowManager;
|
||||
@@ -17,11 +24,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinChatHud {
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "getText", cancellable = true)
|
||||
private void getTextAt(
|
||||
double X,
|
||||
double Y,
|
||||
CallbackInfoReturnable<Style> ci
|
||||
) {
|
||||
private void getTextAt(double X, double Y, CallbackInfoReturnable<Style> ci) {
|
||||
ci.setReturnValue(WindowManager.getInstance().getText(X, Y));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.tabs;
|
||||
|
||||
import io.github.darkkronicle.advancedchatcore.util.ColorUtil;
|
||||
@@ -7,9 +14,7 @@ import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
/**
|
||||
* Base ChatTab that allows for custom chat tabs in AdvancedChatHud.
|
||||
*/
|
||||
/** Base ChatTab that allows for custom chat tabs in AdvancedChatHud. */
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Data
|
||||
public abstract class AbstractChatTab {
|
||||
@@ -25,14 +30,13 @@ public abstract class AbstractChatTab {
|
||||
protected boolean showUnread;
|
||||
|
||||
public AbstractChatTab(
|
||||
String name,
|
||||
String abreviation,
|
||||
ColorUtil.SimpleColor mainColor,
|
||||
ColorUtil.SimpleColor borderColor,
|
||||
ColorUtil.SimpleColor innerColor,
|
||||
boolean showUnread,
|
||||
UUID uuid
|
||||
) {
|
||||
String name,
|
||||
String abreviation,
|
||||
ColorUtil.SimpleColor mainColor,
|
||||
ColorUtil.SimpleColor borderColor,
|
||||
ColorUtil.SimpleColor innerColor,
|
||||
boolean showUnread,
|
||||
UUID uuid) {
|
||||
this.name = name;
|
||||
this.abreviation = abreviation;
|
||||
this.mainColor = mainColor;
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.tabs;
|
||||
|
||||
import io.github.darkkronicle.advancedchatcore.util.FindType;
|
||||
import io.github.darkkronicle.advancedchatcore.util.FluidText;
|
||||
import io.github.darkkronicle.advancedchatcore.util.SearchUtils;
|
||||
import io.github.darkkronicle.advancedchathud.config.ChatTab;
|
||||
@@ -10,42 +16,32 @@ import java.util.List;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
/**
|
||||
* ChatTab that loads from {@link ChatTab}.
|
||||
* Easy to customize.
|
||||
*/
|
||||
/** ChatTab that loads from {@link ChatTab}. Easy to customize. */
|
||||
public class CustomChatTab extends AbstractChatTab {
|
||||
|
||||
@Getter
|
||||
private String name;
|
||||
@Getter private String name;
|
||||
|
||||
@Getter
|
||||
private List<Match> matches;
|
||||
@Getter private List<Match> matches;
|
||||
|
||||
@Getter
|
||||
private boolean forward;
|
||||
@Getter private boolean forward;
|
||||
|
||||
@Getter
|
||||
private String startingMessage;
|
||||
@Getter private String startingMessage;
|
||||
|
||||
@Getter
|
||||
private ChatTab storage;
|
||||
@Getter private ChatTab storage;
|
||||
|
||||
public CustomChatTab(ChatTab storage) {
|
||||
super(
|
||||
storage.getName().config.getStringValue(),
|
||||
storage.getAbbreviation().config.getStringValue(),
|
||||
storage.getMainColor().config.getSimpleColor(),
|
||||
storage.getBorderColor().config.getSimpleColor(),
|
||||
storage.getInnerColor().config.getSimpleColor(),
|
||||
storage.getShowUnread().config.getBooleanValue(),
|
||||
storage.getUuid()
|
||||
);
|
||||
storage.getName().config.getStringValue(),
|
||||
storage.getAbbreviation().config.getStringValue(),
|
||||
storage.getMainColor().config.getSimpleColor(),
|
||||
storage.getBorderColor().config.getSimpleColor(),
|
||||
storage.getInnerColor().config.getSimpleColor(),
|
||||
storage.getShowUnread().config.getBooleanValue(),
|
||||
storage.getUuid());
|
||||
this.storage = storage;
|
||||
this.matches = new ArrayList<>(storage.getMatches());
|
||||
this.forward = storage.getForward().config.getBooleanValue();
|
||||
this.startingMessage =
|
||||
storage.getStartingMessage().config.getStringValue();
|
||||
this.startingMessage = storage.getStartingMessage().config.getStringValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2021 DarkKronicle
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package io.github.darkkronicle.advancedchathud.tabs;
|
||||
|
||||
import io.github.darkkronicle.advancedchathud.HudChatMessage;
|
||||
@@ -9,41 +16,31 @@ import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
/**
|
||||
* Main chat tab that manages other chat tabs.
|
||||
*/
|
||||
/** Main chat tab that manages other chat tabs. */
|
||||
public class MainChatTab extends AbstractChatTab {
|
||||
|
||||
@Getter
|
||||
private ArrayList<AbstractChatTab> allChatTabs = new ArrayList<>();
|
||||
@Getter private ArrayList<AbstractChatTab> allChatTabs = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private ArrayList<CustomChatTab> customChatTabs = new ArrayList<>();
|
||||
@Getter private ArrayList<CustomChatTab> customChatTabs = new ArrayList<>();
|
||||
|
||||
public MainChatTab() {
|
||||
super(
|
||||
"Main",
|
||||
HudConfigStorage.MAIN_TAB.getAbbreviation().config.getStringValue(),
|
||||
HudConfigStorage.MAIN_TAB.getMainColor().config.getSimpleColor(),
|
||||
HudConfigStorage.MAIN_TAB.getBorderColor().config.getSimpleColor(),
|
||||
HudConfigStorage.MAIN_TAB.getInnerColor().config.getSimpleColor(),
|
||||
HudConfigStorage.MAIN_TAB.getShowUnread().config.getBooleanValue(),
|
||||
HudConfigStorage.MAIN_TAB.getUuid()
|
||||
);
|
||||
"Main",
|
||||
HudConfigStorage.MAIN_TAB.getAbbreviation().config.getStringValue(),
|
||||
HudConfigStorage.MAIN_TAB.getMainColor().config.getSimpleColor(),
|
||||
HudConfigStorage.MAIN_TAB.getBorderColor().config.getSimpleColor(),
|
||||
HudConfigStorage.MAIN_TAB.getInnerColor().config.getSimpleColor(),
|
||||
HudConfigStorage.MAIN_TAB.getShowUnread().config.getBooleanValue(),
|
||||
HudConfigStorage.MAIN_TAB.getUuid());
|
||||
setUpTabs();
|
||||
}
|
||||
|
||||
public void refreshOptions() {
|
||||
this.abreviation =
|
||||
HudConfigStorage.MAIN_TAB.getAbbreviation().config.getStringValue();
|
||||
this.mainColor =
|
||||
HudConfigStorage.MAIN_TAB.getMainColor().config.getSimpleColor();
|
||||
this.innerColor =
|
||||
HudConfigStorage.MAIN_TAB.getInnerColor().config.getSimpleColor();
|
||||
this.borderColor =
|
||||
HudConfigStorage.MAIN_TAB.getBorderColor().config.getSimpleColor();
|
||||
this.showUnread =
|
||||
HudConfigStorage.MAIN_TAB.getShowUnread().config.getBooleanValue();
|
||||
this.abreviation = HudConfigStorage.MAIN_TAB.getAbbreviation().config.getStringValue();
|
||||
this.mainColor = HudConfigStorage.MAIN_TAB.getMainColor().config.getSimpleColor();
|
||||
this.innerColor = HudConfigStorage.MAIN_TAB.getInnerColor().config.getSimpleColor();
|
||||
this.borderColor = HudConfigStorage.MAIN_TAB.getBorderColor().config.getSimpleColor();
|
||||
this.showUnread = HudConfigStorage.MAIN_TAB.getShowUnread().config.getBooleanValue();
|
||||
this.uuid = HudConfigStorage.MAIN_TAB.getUuid();
|
||||
}
|
||||
|
||||
@@ -52,9 +49,7 @@ public class MainChatTab extends AbstractChatTab {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used for loading in tabs from the config.
|
||||
*/
|
||||
/** Method used for loading in tabs from the config. */
|
||||
public void setUpTabs() {
|
||||
customChatTabs = new ArrayList<>();
|
||||
allChatTabs = new ArrayList<>();
|
||||
@@ -64,9 +59,7 @@ public class MainChatTab extends AbstractChatTab {
|
||||
customChatTabs.add(customTab);
|
||||
allChatTabs.add(customTab);
|
||||
}
|
||||
for (HudChatMessage message : HudChatMessageHolder
|
||||
.getInstance()
|
||||
.getMessages()) {
|
||||
for (HudChatMessage message : HudChatMessageHolder.getInstance().getMessages()) {
|
||||
ArrayList<AbstractChatTab> tabs = new ArrayList<>();
|
||||
for (AbstractChatTab t : allChatTabs) {
|
||||
if (t.shouldAdd(message.getMessage().getOriginalText())) {
|
||||
|
||||
Reference in new issue
Block a user