From a7a4d2914b07c164a98af6dbf3a8350edb129e6e Mon Sep 17 00:00:00 2001 From: emd4600 Date: Tue, 15 Oct 2024 16:53:08 +0200 Subject: [PATCH] Display git info dialog for existing installations --- src/sporemodder/GitHubManager.java | 12 ++++++++++-- src/sporemodder/MainApp.java | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sporemodder/GitHubManager.java b/src/sporemodder/GitHubManager.java index acbc0d5..3ecc664 100644 --- a/src/sporemodder/GitHubManager.java +++ b/src/sporemodder/GitHubManager.java @@ -35,13 +35,14 @@ public class GitHubManager extends AbstractManager { private static final String PROPERTY_gitUsername = "gitUsername"; private static final String PROPERTY_gitEmail = "gitEmail"; + private static final String PROPERTY_hasShowGitDialog = "hasShowGitDialog"; private String clientId; private String username; private String emailAddress; private String userAccessToken; private String lastDeviceLoginCode; - private boolean hasAskedForGitUser; + private boolean hasShowGitDialog; /** * Returns the current instance of the GitHubManager class. @@ -67,6 +68,8 @@ public void initialize(Properties properties) { emailAddress = properties.getProperty(PROPERTY_gitEmail); if (username != null) username = username.trim(); if (emailAddress != null) emailAddress = emailAddress.trim(); + + hasShowGitDialog = properties.getProperty(PROPERTY_hasShowGitDialog, "false").equals("true"); } @Override public void saveSettings(Properties properties) { @@ -76,6 +79,7 @@ public void initialize(Properties properties) { if (emailAddress != null && !emailAddress.isBlank()) { properties.put(PROPERTY_gitEmail, emailAddress); } + properties.put(PROPERTY_hasShowGitDialog, hasShowGitDialog ? "true" : "false"); } public boolean hasUsernameAndEmail() { @@ -557,6 +561,10 @@ public void setRepositoryTopics(String repositoryName, List topics) thro * After the dialog is shown, it will not be shown again. */ public void showFirstTimeDialog() { - SetGitUserUI.show(); + if (!hasShowGitDialog) { + SetGitUserUI.show(); + hasShowGitDialog = true; + MainApp.get().saveSettings(); + } } } diff --git a/src/sporemodder/MainApp.java b/src/sporemodder/MainApp.java index 50e5a8a..b4a9f3a 100644 --- a/src/sporemodder/MainApp.java +++ b/src/sporemodder/MainApp.java @@ -271,11 +271,11 @@ public void start(Stage primaryStage) { } uiManager.showInitializationError(); + + gitHubManager.showFirstTimeDialog(); if (uiManager.isFirstTime()) { gameManager.showFirstTimeDialog(); - - gitHubManager.showFirstTimeDialog(); projectManager.showFirstTimeDialog();