-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
202 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/org/polyfrost/chatting/mixin/HudUtilsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.polyfrost.chatting.mixin; | ||
|
||
import cc.polyfrost.oneconfig.config.Config; | ||
import cc.polyfrost.oneconfig.config.elements.BasicOption; | ||
import cc.polyfrost.oneconfig.hud.HUDUtils; | ||
import cc.polyfrost.oneconfig.hud.Hud; | ||
import org.polyfrost.chatting.chat.ChatHooks; | ||
import org.polyfrost.chatting.config.ChattingConfig; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
@Mixin(HUDUtils.class) | ||
public class HudUtilsMixin { | ||
|
||
@Unique | ||
private static boolean isChatWindow, isInputBox; | ||
|
||
@Redirect(method = "addHudOptions", at = @At(value = "INVOKE", target = "Lcc/polyfrost/oneconfig/hud/Hud;setConfig(Lcc/polyfrost/oneconfig/config/Config;)V"), remap = false) | ||
private static void detect(Hud instance, Config config) { | ||
isChatWindow = instance.equals(ChattingConfig.INSTANCE.getChatWindow()); | ||
isInputBox = instance.equals(ChattingConfig.INSTANCE.getChatInput()); | ||
instance.setConfig(config); | ||
} | ||
|
||
@Redirect(method = "addHudOptions", at = @At(value = "INVOKE", target = "Ljava/util/ArrayList;add(Ljava/lang/Object;)Z"), remap = false) | ||
private static boolean paddingY(ArrayList instance, Object e) { | ||
BasicOption option = (BasicOption) e; | ||
if (isChatWindow || isInputBox) { | ||
ArrayList<BasicOption> removeQueue = new ArrayList<>(); | ||
for (Object object : instance) { | ||
BasicOption basicOption = (BasicOption) object; | ||
List<String> shows = Arrays.asList("Show in F3 (Debug)", "Show in GUIs", "Enabled", "Position Alignment"); | ||
if (basicOption.name.equals("Show in Chat") || (isInputBox && shows.contains(basicOption.name))) { | ||
removeQueue.add(basicOption); | ||
} | ||
if (basicOption.name.equals("Input Field Draft")) { | ||
basicOption.addListener(ChatHooks.INSTANCE::resetDraft); | ||
} | ||
} | ||
instance.removeAll(removeQueue); | ||
} | ||
List<String> paddings = Arrays.asList("X-Padding", "Y-Padding"); | ||
if (isInputBox && paddings.contains(option.name)) return false; | ||
return instance.add(option); | ||
} | ||
|
||
@Redirect(method = "addHudOptions", at = @At(value = "INVOKE", target = "Lcc/polyfrost/oneconfig/config/elements/BasicOption;addDependency(Ljava/lang/String;Ljava/util/function/Supplier;)V", ordinal = 5), remap = false) | ||
private static void no(BasicOption instance, String optionName, Supplier<Boolean> supplier) { | ||
if (isInputBox) return; | ||
instance.addDependency(optionName, supplier); | ||
} | ||
|
||
@Redirect(method = "addHudOptions", at = @At(value = "INVOKE", target = "Lcc/polyfrost/oneconfig/config/elements/BasicOption;addDependency(Ljava/lang/String;Ljava/util/function/Supplier;)V", ordinal = 6), remap = false) | ||
private static void no1(BasicOption instance, String optionName, Supplier<Boolean> supplier) { | ||
if (isInputBox) return; | ||
instance.addDependency(optionName, supplier); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/org/polyfrost/chatting/chat/ChatInputBox.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.polyfrost.chatting.chat | ||
|
||
import cc.polyfrost.oneconfig.config.annotations.Exclude | ||
import cc.polyfrost.oneconfig.config.annotations.Switch | ||
import cc.polyfrost.oneconfig.hud.BasicHud | ||
import cc.polyfrost.oneconfig.libs.universal.UMatrixStack | ||
import cc.polyfrost.oneconfig.utils.dsl.nanoVG | ||
import net.minecraft.client.renderer.GlStateManager | ||
import org.polyfrost.chatting.utils.ModCompatHooks | ||
|
||
class ChatInputBox: BasicHud(true, -100f, -100f) { | ||
|
||
init { | ||
paddingX = 0f | ||
paddingY = 0f | ||
} | ||
|
||
@Switch( | ||
name = "Compact Input Box", category = "Input Box", | ||
description = "Make the chat input box the same width as the chat box." | ||
) | ||
var compactInputBox = false | ||
|
||
@Switch( | ||
name = "Input Field Draft", category = "Input Box", | ||
description = "Drafts the text you wrote in the input field after closing the chat and back it up when opening the chat again." | ||
) | ||
var inputFieldDraft = false | ||
|
||
@Exclude | ||
var bgTop = 0f | ||
|
||
fun drawBG(x: Float, y: Float, width: Float, height: Float) { | ||
bgTop = y / scale + height + 2 | ||
if (!ModCompatHooks.shouldDrawInputBox) return | ||
GlStateManager.enableAlpha() | ||
GlStateManager.enableBlend() | ||
nanoVG(true) { | ||
drawBackground(x, y, width * scale, height * scale, scale) | ||
} | ||
GlStateManager.disableBlend() | ||
GlStateManager.disableAlpha() | ||
} | ||
|
||
override fun isEnabled(): Boolean { | ||
return true | ||
} | ||
|
||
override fun draw(matrices: UMatrixStack?, x: Float, y: Float, scale: Float, example: Boolean) { | ||
} | ||
|
||
override fun shouldShow(): Boolean { | ||
return false | ||
} | ||
|
||
override fun getWidth(scale: Float, example: Boolean): Float { | ||
return 0f | ||
} | ||
|
||
override fun getHeight(scale: Float, example: Boolean): Float { | ||
return 0f | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.