Skip to content

Commit

Permalink
refactor: rename ScriptConfig.overrideIsGuiEnabled to ScriptConfig.gu…
Browse files Browse the repository at this point in the history
…iEnabled
  • Loading branch information
Ellet committed Jul 6, 2024
1 parent 080ebfc commit ef6c383
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions sync-script/src/main/kotlin/config/models/ScriptConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import syncInfo.models.SyncInfo
data class ScriptConfig(
/**
* The public download url for the [SyncInfo] json file
* it's needed so the script can fetch the [SyncInfo] from it as it's containing the server data
* it's needed so the script can fetch the [SyncInfo] from it as it contains the server data
* to get the latest info about the mods and other resources in addition to another server customization
* */
val syncInfoUrl: String,
Expand All @@ -38,7 +38,7 @@ data class ScriptConfig(
* it should be automatically disabled.
*
* */
val overrideIsGuiEnabled: Boolean? = null,
val guiEnabled: Boolean? = null,
/**
* The theme mode for the GUI, this only take effect if the GUI mode is enabled.
* */
Expand All @@ -62,7 +62,7 @@ data class ScriptConfig(
* The accepted values are `client` or `server`
*
* If you are using [Environment.Server] and the server doesn't support graphical interface
* then consider passing false to [overrideIsGuiEnabled]
* then consider passing false to [guiEnabled]
* */
val environment: Environment = Environment.Client,
/**
Expand Down
6 changes: 3 additions & 3 deletions sync-script/src/main/kotlin/gui/GuiState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import java.awt.GraphicsEnvironment
object GuiState {
/**
* By default, will load it from the program arguments by [Constants.DISABLE_GUI_ARG_NAME]
* the value can be overridden using [ScriptConfig.overrideIsGuiEnabled] when the [ScriptConfig] is initialized
* the value can be overridden using [ScriptConfig.guiEnabled] when the [ScriptConfig] is initialized
* */
var isGuiEnabled: Boolean = Constants.GUI_ENABLED_WHEN_AVAILABLE_DEFAULT
private set

/**
* A function to update the value of the [isGuiEnabled] based on [ScriptConfig.overrideIsGuiEnabled] and the [passedArgs]
* A function to update the value of the [isGuiEnabled] based on [ScriptConfig.guiEnabled] and the [passedArgs]
* if any of those changes, this function should be called
*
* */
fun updateIsGuiEnabled() {
// Check if the user overrides the default value in the config file
ScriptConfig.instance?.overrideIsGuiEnabled?.let {
ScriptConfig.instance?.guiEnabled?.let {
isGuiEnabled = it
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class QuickPreferencesDialog : JDialog() {
return ScriptConfig.getInstanceOrThrow().copy(
theme = themeComboBox.getSelectedItemOrThrow(),
themeMode = themeModeComboBox.getSelectedItemOrThrow(),
overrideIsGuiEnabled = getOverrideIsGuiEnabled(),
guiEnabled = getOverrideIsGuiEnabled(),
)
}

Expand Down
4 changes: 2 additions & 2 deletions sync-script/src/main/kotlin/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import java.awt.Component
import kotlin.system.exitProcess

/**
* If [ScriptConfig.overrideIsGuiEnabled] is true, will use [GuiUtils.showErrorMessage]
* If [ScriptConfig.guiEnabled] is true, will use [GuiUtils.showErrorMessage]
* otherwise will just print an error message to the log
*
* @param guiParentComponent The Java Swing parent component that created/showed this error message
* the [terminateWithOrWithoutError] will decide to exit with error or as normal exit
*
*
* Whatever if it should use GUI to show error or not, will use [ScriptConfig.overrideIsGuiEnabled],
* Whatever if it should use GUI to show error or not, will use [ScriptConfig.guiEnabled],
* we might call [showErrorMessageAndTerminate] when having error while loading the [ScriptConfig]
* (for example), which is why we can't [ScriptConfig.getInstanceOrThrow] because we will get not initialized error
* while showing an error message
Expand Down

0 comments on commit ef6c383

Please sign in to comment.