From 6bf7386a0ad867dac3dbdf8ecd1019de32e505aa Mon Sep 17 00:00:00 2001 From: Snirozu <72814880+Snirozu@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:19:07 +0100 Subject: [PATCH] fixbox --- source/online/gui/sidebar/MainTab.hx | 10 ++++++++-- source/online/objects/ProfileBox.hx | 11 +++++++---- source/online/states/RoomState.hx | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/source/online/gui/sidebar/MainTab.hx b/source/online/gui/sidebar/MainTab.hx index eadf92c9..1cbb817a 100644 --- a/source/online/gui/sidebar/MainTab.hx +++ b/source/online/gui/sidebar/MainTab.hx @@ -19,7 +19,11 @@ class MainTab extends TabSprite { static var messages:Array = []; var msgSprite:Sprite; - override function create() { + var chatInputPlaceholder:TextField; + + public function new(tabWidth:Float) { + super(tabWidth); + msgSprite = new Sprite(); addChild(msgSprite); @@ -53,7 +57,7 @@ class MainTab extends TabSprite { chatInput.type = INPUT; chatInput.width = Std.int(widthTab); - var chatInputPlaceholder:TextField = new TextField(); + chatInputPlaceholder = new TextField(); chatInputPlaceholder.defaultTextFormat = TabSprite.getDefaultFormat(); chatInputPlaceholder.text = "(Click here to chat)"; chatInputPlaceholder.selectable = false; @@ -67,7 +71,9 @@ class MainTab extends TabSprite { addChild(chatBg); addChild(chatInputPlaceholder); addChild(chatInput); + } + override function create() { chatInput.addEventListener(Event.CHANGE, _ -> { chatInputPlaceholder.visible = chatInput.text.length <= 0; }); diff --git a/source/online/objects/ProfileBox.hx b/source/online/objects/ProfileBox.hx index 26233c3a..890cbbc4 100644 --- a/source/online/objects/ProfileBox.hx +++ b/source/online/objects/ProfileBox.hx @@ -19,10 +19,13 @@ class ProfileBox extends FlxSpriteGroup { public var desc:FlxText; public var autoUpdateThings:Bool = true; + public var sizeAdd:Int = 0; public function new(leUser:String, leVerified:Bool, ?leCardHeight:Int = 100, ?sizeAdd:Int = 0) { super(); + this.sizeAdd = sizeAdd; + bg = new FlxSprite(); bg.alpha = 0.7; add(bg); @@ -85,8 +88,8 @@ class ProfileBox extends FlxSpriteGroup { text.text = "Welcome, " + user + "!"; else text.text = user; - desc.text = "Points: " + (profileData?.points ?? 0); - desc.text += "\nAvg. Accuracy: " + FlxMath.roundDecimal(((profileData?.avgAccuracy ?? 0) * 100), 2) + "%"; + desc.text = "Points: " + (profileData.points ?? 0); + desc.text += "\nAvg. Accuracy: " + FlxMath.roundDecimal((profileData.avgAccuracy * 100), 2) + "%"; } Thread.run(() -> { @@ -121,9 +124,9 @@ class ProfileBox extends FlxSpriteGroup { public function drawBG() { var profileHue = profileData?.profileHue ?? 230; - bg.makeGraphic(300, cardHeight, FlxColor.TRANSPARENT); + bg.makeGraphic(320 + 10 * sizeAdd, cardHeight, FlxColor.TRANSPARENT); // later concept for detailed cards, fill a tall round rectangle with darker color and then draw the normal card - FlxSpriteUtil.drawRoundRect(bg, 0, 0, 300, cardHeight, 40, 40, FlxColor.fromHSL(profileHue, 0.25, 0.25)); + FlxSpriteUtil.drawRoundRect(bg, 0, 0, 320 + 10 * sizeAdd, cardHeight, 40, 40, FlxColor.fromHSL(profileHue, 0.25, 0.25)); bg.updateHitbox(); fitAvatar(); diff --git a/source/online/states/RoomState.hx b/source/online/states/RoomState.hx index 60beb473..6ae78b02 100644 --- a/source/online/states/RoomState.hx +++ b/source/online/states/RoomState.hx @@ -1089,7 +1089,7 @@ class RoomState extends MusicBeatState { box.desc.applyMarkup( "Points: " + player.points + "\n" + - (player.verified && box.profileData != null ? "Avg. Accuracy: " + FlxMath.roundDecimal(((box.profileData?.avgAccuracy ?? 0) * 100), 2) + "%\n" : "") + + (player.verified && box.profileData != null ? "Avg. Accuracy: " + FlxMath.roundDecimal((box.profileData.avgAccuracy * 100), 2) + "%\n" : "") + "Ping:

" + player.ping + "ms

\n\n" + player.status + "\n" + (!player.isReady ? "NOT " : "") + "READY" +