-
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
9 changed files
with
196 additions
and
62 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/dummy/java/cc/polyfrost/oneconfig/internal/hud/HudCore.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,7 @@ | ||
package cc.polyfrost.oneconfig.internal.hud; | ||
|
||
public class HudCore { | ||
|
||
public static boolean editing; | ||
|
||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/org/polyfrost/chatting/mixin/GuiIngameForgeMixin.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,24 @@ | ||
package org.polyfrost.chatting.mixin; | ||
|
||
import net.minecraftforge.client.GuiIngameForge; | ||
import org.polyfrost.chatting.config.ChattingConfig; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.ModifyArgs; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args; | ||
|
||
@Mixin(GuiIngameForge.class) | ||
public class GuiIngameForgeMixin { | ||
|
||
@ModifyArgs(method = "renderChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V")) | ||
private void cancelTranslate(Args args) { | ||
args.set(1, 0f); | ||
} | ||
|
||
@Inject(method = "renderChat", at = @At(value = "HEAD"), cancellable = true, remap = false) | ||
private void cancelChat(int width, int height, CallbackInfo ci) { | ||
if (!ChattingConfig.INSTANCE.getChatWindow().isEnabled()) ci.cancel(); | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_Movable.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,48 @@ | ||
package org.polyfrost.chatting.mixin; | ||
|
||
import cc.polyfrost.oneconfig.hud.Position; | ||
import cc.polyfrost.oneconfig.internal.hud.HudCore; | ||
import net.minecraft.client.gui.GuiNewChat; | ||
import net.minecraft.util.MathHelper; | ||
import org.polyfrost.chatting.chat.ChatWindow; | ||
import org.polyfrost.chatting.config.ChattingConfig; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.*; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args; | ||
|
||
@Mixin(GuiNewChat.class) | ||
public abstract class GuiNewChatMixin_Movable { | ||
|
||
@Shadow public abstract int getChatWidth(); | ||
|
||
@ModifyArgs(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V", ordinal = 0)) | ||
private void translate(Args args) { | ||
ChatWindow hud = ChattingConfig.INSTANCE.getChatWindow(); | ||
Position position = hud.position; | ||
args.set(0, position.getX()); | ||
args.set(1, position.getBottomY()); | ||
} | ||
|
||
@ModifyVariable(method = "drawChat", at = @At(value = "STORE", ordinal = 0), ordinal = 4) | ||
private int width(int value) { | ||
return MathHelper.ceiling_float_int((float)this.getChatWidth()); | ||
} | ||
|
||
@ModifyConstant(method = "drawChat", constant = @Constant(intValue = 9, ordinal = 0)) | ||
private int chatMode(int constant) { | ||
return constant; | ||
} | ||
|
||
@Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;getChatScale()F")) | ||
private float scale(GuiNewChat instance) { | ||
return ChattingConfig.INSTANCE.getChatWindow().getScale(); | ||
} | ||
|
||
@Inject(method = "drawChat", at = @At(value = "HEAD"), cancellable = true) | ||
private void exampleChat(int updateCounter, CallbackInfo ci) { | ||
if (HudCore.editing) ci.cancel(); | ||
} | ||
|
||
} |
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,49 @@ | ||
package org.polyfrost.chatting.chat | ||
|
||
import cc.polyfrost.oneconfig.config.annotations.DualOption | ||
import cc.polyfrost.oneconfig.config.annotations.Exclude | ||
import cc.polyfrost.oneconfig.hud.Hud | ||
import cc.polyfrost.oneconfig.libs.universal.UMatrixStack | ||
import cc.polyfrost.oneconfig.renderer.TextRenderer | ||
import cc.polyfrost.oneconfig.utils.dsl.* | ||
import org.polyfrost.chatting.config.ChattingConfig | ||
|
||
class ChatWindow : Hud(true) { | ||
|
||
@Exclude | ||
private val exampleChat = listOf( | ||
"Chatting by PolyFrost Team", | ||
"----------------------------------------", | ||
"This is a movable chat", | ||
"Drag me around!", | ||
"Click to drag" | ||
) | ||
|
||
@DualOption( | ||
name = "Type", | ||
left = "Left", | ||
right = "Right" | ||
) | ||
var chatType = false | ||
|
||
override fun draw(matrices: UMatrixStack?, x: Float, y: Float, scale: Float, example: Boolean) { | ||
if (!example) return | ||
nanoVG(true) { | ||
drawRect(x, y, position.width, position.height, ChattingConfig.chatBackgroundColor.rgb, false) | ||
} | ||
var textY = y | ||
for (text in exampleChat) { | ||
TextRenderer.drawScaledString(text, x, textY, 16777215, TextRenderer.TextType.toType(ChattingConfig.textRenderType), scale) | ||
textY += 9 * scale | ||
} | ||
} | ||
|
||
override fun getWidth(scale: Float, example: Boolean): Float { | ||
return 240f * scale | ||
} | ||
|
||
override fun getHeight(scale: Float, example: Boolean): Float { | ||
return 9f * 5 * scale | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
{ | ||
"compatibilityLevel": "JAVA_8", | ||
"minVersion": "0.7", | ||
"package": "org.polyfrost.chatting.mixin", | ||
"refmap": "mixins.${id}.refmap.json", | ||
"verbose": true, | ||
"client": [ | ||
"ChatLineMixin", | ||
"ClientCommandHandlerMixin", | ||
"EntityPlayerSPMixin", | ||
"GuiChatMixin", | ||
"GuiNewChatAccessor", | ||
"GuiNewChatMapMixin", | ||
"GuiNewChatMixin", | ||
"GuiNewChatMixin_ChatHeight", | ||
"GuiNewChatMixin_ChatSearching", | ||
"GuiNewChatMixin_ChatTabs", | ||
"GuiNewChatMixin_Scrolling", | ||
"GuiNewChatMixin_SmoothMessages", | ||
"GuiNewChatMixin_TextRendering", | ||
"GuiUtilsMixin" | ||
] | ||
"compatibilityLevel": "JAVA_8", | ||
"minVersion": "0.7", | ||
"package": "org.polyfrost.chatting.mixin", | ||
"refmap": "mixins.${id}.refmap.json", | ||
"verbose": true, | ||
"client": [ | ||
"ChatLineMixin", | ||
"ClientCommandHandlerMixin", | ||
"EntityPlayerSPMixin", | ||
"GuiChatMixin", | ||
"GuiIngameForgeMixin", | ||
"GuiNewChatAccessor", | ||
"GuiNewChatMapMixin", | ||
"GuiNewChatMixin", | ||
"GuiNewChatMixin_ChatHeight", | ||
"GuiNewChatMixin_ChatSearching", | ||
"GuiNewChatMixin_ChatTabs", | ||
"GuiNewChatMixin_Movable", | ||
"GuiNewChatMixin_Scrolling", | ||
"GuiNewChatMixin_SmoothMessages", | ||
"GuiNewChatMixin_TextRendering", | ||
"GuiUtilsMixin" | ||
] | ||
} |