From a0795caa13d79921f361ae76e60e00e84e66153c Mon Sep 17 00:00:00 2001 From: austin Date: Wed, 28 May 2025 12:44:37 -0400 Subject: [PATCH] loading state work --- docs/src/progress/renderertodo.md | 1 + .../character/ClientCharacterManager.java | 24 +++++++++++++++++++ .../engine/loadingthreads/ClientLoading.java | 17 +++++++++++++ .../client/protocol/CharacterProtocol.java | 1 + 4 files changed, 43 insertions(+) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 7528b4be..5140f6e2 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2016,6 +2016,7 @@ Fix memory leaks (05/28/2025) Server entities without collidables deactivate gravity trees Fix texture map for lod human model +Properly show loading state when waiting on character list diff --git a/src/main/java/electrosphere/client/entity/character/ClientCharacterManager.java b/src/main/java/electrosphere/client/entity/character/ClientCharacterManager.java index 14b2e971..5d60fc84 100644 --- a/src/main/java/electrosphere/client/entity/character/ClientCharacterManager.java +++ b/src/main/java/electrosphere/client/entity/character/ClientCharacterManager.java @@ -10,6 +10,11 @@ public class ClientCharacterManager { */ ClientCharacterListDTO characterList; + /** + * Tracks whether we're waiting on the character list or not + */ + private boolean waitingOnList = true; + /** * Gets the character list * @return The character list @@ -25,6 +30,25 @@ public class ClientCharacterManager { public void setCharacterList(ClientCharacterListDTO characterList) { this.characterList = characterList; } + + /** + * Checks whether we're waiting on the character list or not + * @return true if we're waiting, false otherwise + */ + public boolean isWaitingOnList() { + return waitingOnList; + } + + /** + * Sets whether we're waiting on the character list or not + * @param waitingOnList true if we're waiting, false otherwise + */ + public void setWaitingOnList(boolean waitingOnList) { + this.waitingOnList = waitingOnList; + } + + + } diff --git a/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java b/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java index 47c775f2..efa80fca 100644 --- a/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java +++ b/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java @@ -90,6 +90,20 @@ public class ClientLoading { } catch (InterruptedException ex) {} framesWaited++; } + WindowUtils.updateLoadingWindow("Waiting on characters"); + framesWaited = 0; + while(Globals.clientState.clientCharacterManager.isWaitingOnList()){ + if(framesWaited % LORE_RESEND_FRAMES == (LORE_RESEND_FRAMES - 1)){ + //request playable races + Globals.clientState.clientConnection.queueOutgoingMessage(LoreMessage.constructRequestRacesMessage()); + //request characters available to this player + Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCharacterListMessage()); + } + try { + TimeUnit.MILLISECONDS.sleep(5); + } catch (InterruptedException ex) {} + framesWaited++; + } //once we have them, bring up the character creation interface //init character creation window //eventually should replace with at ui to select an already created character or create a new one @@ -107,6 +121,9 @@ public class ClientLoading { } + /** + * Loads the client's world data + */ protected static void loadClientWorld(Object[] params){ Globals.engineState.signalSystem.post(SignalType.UI_MODIFICATION, () -> { WindowUtils.closeWindow(WindowStrings.WINDOW_MENU_MAIN); diff --git a/src/main/java/electrosphere/net/client/protocol/CharacterProtocol.java b/src/main/java/electrosphere/net/client/protocol/CharacterProtocol.java index 50a724a2..817ffea4 100644 --- a/src/main/java/electrosphere/net/client/protocol/CharacterProtocol.java +++ b/src/main/java/electrosphere/net/client/protocol/CharacterProtocol.java @@ -35,6 +35,7 @@ public class CharacterProtocol implements ClientProtocolTemplate { WindowUtils.replaceMainMenuContents(MenuCharacterCreation.createCharacterSelectionWindow()); });