Skip to content

Commit 427ae8f

Browse files
committed
feature: Show configuration writable message
1 parent 200899f commit 427ae8f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/main/java/com/bobrust/main/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static void main(String[] args) {
2525
LOGGER.info(" Lwjgl : {}", hasLwjgl);
2626
LOGGER.info("");
2727

28+
// TODO: Make sure logs and properties can be saved without admin rights.
2829
// TODO: Do not draw outside the image region +- the radius of the largest shape.
2930
// TODO: Maybe remove the monitor button and only make it choose the screen you
3031
// expanded the window on?

src/main/java/com/bobrust/settings/RustSettingsImpl.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.util.Objects;
66
import java.util.Properties;
77

8+
import javax.swing.JOptionPane;
9+
810
import org.apache.logging.log4j.LogManager;
911
import org.apache.logging.log4j.Logger;
1012

@@ -76,7 +78,7 @@ protected void loadSettings() {
7678
setSettingsAutosaveInterval(getSettingInteger(Settings.SETTINGS_AUTOSAVE_INTERVAL));
7779

7880
allowSaving = true;
79-
saveSettings();
81+
saveSettings(true);
8082
}
8183

8284
private Integer getSettingInteger(Settings key) {
@@ -105,11 +107,25 @@ private String getSettingsProperty(Settings key) {
105107
}
106108

107109
private void saveSettings() {
110+
saveSettings(false);
111+
}
112+
113+
private void saveSettings(boolean giveMessage) {
108114
if(!allowSaving) return;
109115

110116
try(FileOutputStream stream = new FileOutputStream(CONFIG_FILE)) {
111117
properties.store(stream, "");
112118
} catch(IOException e) {
119+
if (giveMessage) {
120+
JOptionPane.showMessageDialog(
121+
null,
122+
"This tool does not have the permission to update the config file\n" +
123+
"Try run the application as an Administrator if you want to fix this",
124+
"Importaint",
125+
JOptionPane.WARNING_MESSAGE
126+
);
127+
}
128+
113129
LOGGER.error("Error saving config file: {}", e);
114130
LOGGER.throwing(e);
115131
e.printStackTrace();

version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#Sat Nov 13 00:10:45 CET 2021
2-
build_id=41
1+
#Thu Jan 13 19:31:44 CET 2022
2+
build_id=45

0 commit comments

Comments
 (0)