Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Commit

Permalink
The debug screen is now sorted.
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyAreAllTheseTaken committed Dec 4, 2019
1 parent 1f4ecd8 commit f95c330
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions RPGOnline2/src/io/github/tomaso2468/rpgonline/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

import java.lang.management.ManagementFactory;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand Down Expand Up @@ -531,14 +535,28 @@ public void postRender(Game game, Renderer renderer) throws RenderException {
DebugFrame render = lastFrame;
if (render != null) {
y = drawDebugTitle(g, "Render Thread", y, false);
for (Entry<String, Long> t : render.getTimes()) {
List<Entry<String,Long>> times = new ArrayList<>(render.getTimes());
Collections.sort(times, new Comparator<Entry<String,Long>>() {
@Override
public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
return o1.getKey().compareToIgnoreCase(o2.getKey());
}
});
for (Entry<String, Long> t : times) {
y = drawDebugLineLabel(g, t.getKey(), (t.getValue() / 1000) + "", y, false);
}
}

if (lastUpdate != null) {
y = drawDebugTitle(g, "Main Thread Updates", y, false);
for (Entry<String, Long> t : lastUpdate.getTimes()) {
List<Entry<String,Long>> times = new ArrayList<>(lastUpdate.getTimes());
Collections.sort(times, new Comparator<Entry<String,Long>>() {
@Override
public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
return o1.getKey().compareToIgnoreCase(o2.getKey());
}
});
for (Entry<String, Long> t : times) {
y = drawDebugLineLabel(g, t.getKey(), (t.getValue() / 1000) + "", y, false);
}
}
Expand All @@ -547,7 +565,14 @@ public void postRender(Game game, Renderer renderer) throws RenderException {
DebugFrame client = ServerManager.getClient().getDebugFrame();
if (client != null) {
y = drawDebugTitle(g, "Client Thread", y, false);
for (Entry<String, Long> t : client.getTimes()) {
List<Entry<String,Long>> times = new ArrayList<>(client.getTimes());
Collections.sort(times, new Comparator<Entry<String,Long>>() {
@Override
public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
return o1.getKey().compareToIgnoreCase(o2.getKey());
}
});
for (Entry<String, Long> t : times) {
y = drawDebugLineLabel(g, t.getKey(), (t.getValue() / 1000) + "", y, false);
}
}
Expand All @@ -557,7 +582,14 @@ public void postRender(Game game, Renderer renderer) throws RenderException {
DebugFrame server = ServerManager.getServer().getDebugFrame();
if (server != null) {
y = drawDebugTitle(g, "Server Thread", y, false);
for (Entry<String, Long> t : server.getTimes()) {
List<Entry<String,Long>> times = new ArrayList<>(server.getTimes());
Collections.sort(times, new Comparator<Entry<String,Long>>() {
@Override
public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
return o1.getKey().compareToIgnoreCase(o2.getKey());
}
});
for (Entry<String, Long> t : times) {
y = drawDebugLineLabel(g, t.getKey(), (t.getValue() / 1000) + "", y, false);
}
}
Expand Down

0 comments on commit f95c330

Please sign in to comment.