Skip to content

Commit

Permalink
feat(discord): change main menu state
Browse files Browse the repository at this point in the history
Change main menu state from "In Lobby" to "In Main Menu"
  • Loading branch information
iHDeveloper committed Nov 25, 2020
1 parent 3a9d34d commit 7cbe17b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void initialise(GameEngine engine, Context rootContext) {
public void postInitialise(Context context) {
config = context.get(Config.class);
config.getPlayer().subscribe(this);
setState("In Lobby");
setState("In Main Menu", false, false);
}

@Override
Expand Down Expand Up @@ -233,17 +233,21 @@ public static void setState(String state) {
}

public static void setState(String state, boolean timestamp) {
setState(state, timestamp, true);
}

public static void setState(String state, boolean timestamp, boolean showDetails) {
if (instance == null) {
return;
}
RichPresence.Builder builder = new RichPresence.Builder();
if (state != null) {
builder.setState(state);
if (getInstance().lastState == null || (getInstance().lastState != null && !getInstance().lastState.equals(state))) {
if (getInstance().lastState == null || !getInstance().lastState.equals(state)) {
getInstance().lastState = state;
}
}
if (getInstance().config != null) {
if (showDetails && getInstance().config != null) {
String playerName = getInstance().config.getPlayer().getName();
builder.setDetails("Name: " + playerName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public void postBegin() {

@Override
public void shutdown() {
DiscordRPCSubSystem.setState("In Lobby");
DiscordRPCSubSystem.setState("In Main Menu", false, false);
}
}

0 comments on commit 7cbe17b

Please sign in to comment.