From 2692c7158f2e9832bc05a505ff8d359de27284ce Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:36:12 +0530 Subject: [PATCH] better chat display --- src/gui/PlayGui.hx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index 07fe48fa..32d32820 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -117,6 +117,8 @@ class PlayGui { var chatHud:GuiMLText; var chatHudBg:GuiMLText; var chatHudInput:GuiTextInput; + var chatInputBg:GuiImage; + var chatInputBgText:GuiText; var chats:Array; var chatFocused:Bool = false; @@ -636,19 +638,38 @@ class PlayGui { this.chatHud.extent = new Vector(200, 250); this.chatHudCtrl.addChild(chatHud); + this.chatInputBg = new GuiImage(ResourceLoader.getResource('data/ui/xbox/fade_black.png', ResourceLoader.getImage, this.imageResources).toTile()); + this.chatInputBg.position = new Vector(0, 0); + this.chatInputBg.extent = new Vector(200, 20); + this.chatHudCtrl.addChild(chatInputBg); + + this.chatInputBgText = new GuiText(arial14); + this.chatInputBgText.position = new Vector(0, 0); + this.chatInputBgText.extent = new Vector(200, 20); + this.chatInputBg.addChild(chatInputBgText); + this.chatInputBgText.text.textColor = 0xF29515; + this.chatInputBgText.text.text = "Chat:"; + this.chatHudInput = new GuiTextInput(arial14); - this.chatHudInput.position = new Vector(0, 0); - this.chatHudInput.extent = new Vector(200, 20); + this.chatHudInput.position = new Vector(40, 0); + this.chatHudInput.extent = new Vector(160, 20); @:privateAccess this.chatHudInput.text.interactive.forceAnywherefocus = true; this.chatHudCtrl.addChild(chatHudInput); + this.chatInputBgText.text.visible = false; + this.chatInputBg.bmp.visible = false; + var sendText = ""; this.chatHudInput.text.onFocus = (e) -> { + this.chatInputBgText.text.visible = true; + this.chatInputBg.bmp.visible = true; chatFocused = true; } this.chatHudInput.text.onFocusLost = (e) -> { + this.chatInputBgText.text.visible = false; + this.chatInputBg.bmp.visible = false; sendText = ""; chatFocused = false; } @@ -663,10 +684,14 @@ class PlayGui { NetCommands.sendServerChatMessage(StringTools.htmlEscape(sendText)); } this.chatHudInput.text.text = ""; + this.chatInputBgText.text.visible = false; + this.chatInputBg.bmp.visible = false; chatFocused = false; } if (e.keyCode == Key.ESCAPE) { this.chatHudInput.text.text = ""; + this.chatInputBgText.text.visible = false; + this.chatInputBg.bmp.visible = false; chatFocused = false; @:privateAccess Key.keyPressed[Key.ESCAPE] = 0; // consume escape }