From 54aae3c9972a9936bee80697713cecd7aafe7a67 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Thu, 4 Jul 2024 01:33:24 +0530 Subject: [PATCH] ping 2 --- src/gui/PlayGui.hx | 28 +++++++++++++++++++++++++--- src/net/ClientConnection.hx | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index 837694cb..faa0b95f 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -572,10 +572,22 @@ class PlayGui { playerListContainer.horizSizing = Right; playerListContainer.vertSizing = Height; playerListContainer.position = new Vector(20, 100); - playerListContainer.extent = new Vector(300, 380); + playerListContainer.extent = new Vector(380, 380); this.playGuiCtrl.addChild(playerListContainer); var imgLoader = (s:String) -> { + switch (s) { + case "high": + return ResourceLoader.getResource("data/ui/mp/play/connection-high.png", ResourceLoader.getImage, this.imageResources).toTile(); + case "medium": + return ResourceLoader.getResource("data/ui/mp/play/connection-medium.png", ResourceLoader.getImage, this.imageResources).toTile(); + case "low": + return ResourceLoader.getResource("data/ui/mp/play/connection-low.png", ResourceLoader.getImage, this.imageResources).toTile(); + case "matanny": + return ResourceLoader.getResource("data/ui/mp/play/connection-matanny.png", ResourceLoader.getImage, this.imageResources).toTile(); + case "unknown": + return ResourceLoader.getResource("data/ui/mp/play/connection-unknown.png", ResourceLoader.getImage, this.imageResources).toTile(); + } return null; } @@ -600,7 +612,7 @@ class PlayGui { }); playerListScoresCtrl.position = new Vector(233, 3); - playerListScoresCtrl.extent = new Vector(210, 271); + playerListScoresCtrl.extent = new Vector(280, 271); playerListScoresCtrl.scrollable = true; playerListScoresCtrl.onSelectedFunc = (sel) -> {} playerListContainer.addChild(playerListScoresCtrl); @@ -627,7 +639,17 @@ class PlayGui { col3; }; pl.push('${i + 1}. ${Util.rightPad(item.name, 25, 3)}'); - plScores.push('${item.score}'); + var connPing = item.us ? (Net.isHost ? 0 : Net.clientConnection.pingTicks) : (item.id == 0 ? 0 : Net.clientIdMap[item.id].pingTicks); + var pingStatus = "unknown"; + if (connPing <= 5) + pingStatus = "high"; + else if (connPing <= 8) + pingStatus = "medium"; + else if (connPing <= 16) + pingStatus = "low"; + else if (connPing < 32) + pingStatus = "matanny"; + plScores.push('${item.score}'); } playerListCtrl.setTexts(pl); playerListScoresCtrl.setTexts(plScores); diff --git a/src/net/ClientConnection.hx b/src/net/ClientConnection.hx index a9ad1e08..c3ca4691 100644 --- a/src/net/ClientConnection.hx +++ b/src/net/ClientConnection.hx @@ -78,6 +78,7 @@ abstract class GameConnection { var marbleId:Int; var marbleCatId:Int; var spectator:Bool; + var pingTicks:Int; function new(id:Int) { this.id = id;