Skip to content

Commit

Permalink
fixbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Snirozu committed Nov 16, 2024
1 parent 33b94a6 commit 6bf7386
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
10 changes: 8 additions & 2 deletions source/online/gui/sidebar/MainTab.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class MainTab extends TabSprite {
static var messages:Array<TextField> = [];
var msgSprite:Sprite;

override function create() {
var chatInputPlaceholder:TextField;

public function new(tabWidth:Float) {
super(tabWidth);

msgSprite = new Sprite();
addChild(msgSprite);

Expand Down Expand Up @@ -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;
Expand All @@ -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;
});
Expand Down
11 changes: 7 additions & 4 deletions source/online/objects/ProfileBox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(() -> {
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion source/online/states/RoomState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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: <p>" + player.ping + "ms<p>\n\n" +
player.status + "\n" +
(!player.isReady ? "NOT " : "") + "READY" +
Expand Down

0 comments on commit 6bf7386

Please sign in to comment.