mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-02 02:38:30 +02:00
ModSettings can now have a description
This commit is contained in:
parent
c511f7bb86
commit
5f5dc6bfbc
7 changed files with 65 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
/.idea/
|
||||
/.cache/
|
||||
/.pytest_cache/
|
||||
/option.json
|
||||
/error.log
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
"en": "Mode",
|
||||
"fr": "Mode"
|
||||
},
|
||||
"description": {
|
||||
"en": "Special mod's configuration.",
|
||||
"fr": "Configuration spécial du mod."
|
||||
},
|
||||
"type": "choices",
|
||||
"choices": [
|
||||
"normal",
|
||||
|
@ -38,6 +42,10 @@
|
|||
"en": "Highlight if",
|
||||
"fr": "Surligner si"
|
||||
},
|
||||
"description": {
|
||||
"en": "all the tracks selected by this condition will be colored in blue.",
|
||||
"fr": "toutes les courses sélectionné par cette condition seront coloré en bleu."
|
||||
},
|
||||
"type": "string",
|
||||
"default": "'v' + track.since_version == mod_config.version",
|
||||
"preview": "track_selecting"
|
||||
|
@ -47,6 +55,10 @@
|
|||
"en": "Balancing *",
|
||||
"fr": "Équilibrage *"
|
||||
},
|
||||
"description": {
|
||||
"en": "Should the mod balancing (fake item box, blooper) be enabled ?",
|
||||
"fr": "Est-ce que l'équilibrage du mod (fausse boite d'objet, bloops) devrait être activé ?"
|
||||
},
|
||||
"type": "check",
|
||||
"default": true
|
||||
}
|
||||
|
|
|
@ -35,6 +35,15 @@ class Window(tkinter.Toplevel):
|
|||
self.mod_config.specific_settings
|
||||
)
|
||||
|
||||
# add at the end a message from the mod creator where he can put some additional note about the settings.
|
||||
if text := translate_external(
|
||||
self.mod_config,
|
||||
self.root.options.language.get(),
|
||||
self.mod_config.messages.get("settings_description", {}).get("text", {})
|
||||
):
|
||||
self.label_description = ttk.Label(self, text="\n" + text, foreground="gray")
|
||||
self.label_description.grid(row=2, column=1)
|
||||
|
||||
|
||||
class NotebookSettings(ttk.Notebook):
|
||||
def __init__(self, master):
|
||||
|
@ -55,37 +64,29 @@ class FrameSettings(ttk.Frame):
|
|||
self.root = self.master.root
|
||||
|
||||
self.columnconfigure(1, weight=1)
|
||||
|
||||
def get_event_checkbox(enabled_variable: tkinter.BooleanVar):
|
||||
"""
|
||||
Return the event for any child of a frmae when clicked
|
||||
"""
|
||||
return lambda event: enabled_variable.set(True)
|
||||
language = self.root.options.language.get()
|
||||
|
||||
index: int = 0
|
||||
for index, (settings_name, settings_data) in enumerate(settings.items()):
|
||||
text = translate_external(
|
||||
self.master.master.mod_config,
|
||||
self.root.options.language.get(),
|
||||
settings_data.text,
|
||||
)
|
||||
text = translate_external(self.master.master.mod_config, language, settings_data.text)
|
||||
description = translate_external(self.master.master.mod_config, language, settings_data.description)
|
||||
|
||||
enabled_variable = tkinter.BooleanVar(value=False)
|
||||
checkbox = ttk.Checkbutton(self, text=text, variable=enabled_variable)
|
||||
|
||||
frame = ttk.LabelFrame(self, labelwidget=checkbox)
|
||||
frame.grid(row=index, column=1, sticky="NEWS")
|
||||
frame.columnconfigure(1, weight=1)
|
||||
|
||||
settings_data.tkinter_show(frame, enabled_variable)
|
||||
action_frame = ttk.Frame(frame)
|
||||
action_frame.grid(row=1, column=1, sticky="NEWS")
|
||||
settings_data.tkinter_show(action_frame, enabled_variable)
|
||||
|
||||
if description:
|
||||
description_label = ttk.Label(frame, text=description, wraplength=450,
|
||||
foreground="gray", justify=tkinter.CENTER)
|
||||
description_label.grid(row=2, column=1)
|
||||
|
||||
# if any of the label child are clicked, automatically enable the option
|
||||
for child in frame.winfo_children():
|
||||
child.bind("<Button-1>", get_event_checkbox(enabled_variable))
|
||||
|
||||
# add at the end a message from the mod creator where he can put some additional note about the settings.
|
||||
if text := translate_external(
|
||||
self.master.master.mod_config,
|
||||
self.root.options.language.get(),
|
||||
self.master.master.mod_config.messages.get("settings_description", {}).get("text", {})
|
||||
):
|
||||
self.label_description = ttk.Label(self, text="\n"+text, foreground="gray")
|
||||
self.label_description.grid(row=index+1, column=1)
|
||||
child.bind("<Button-1>", (lambda variable: (lambda event: variable.set(True)))(enabled_variable))
|
||||
|
|
|
@ -30,6 +30,11 @@ default_global_settings: dict[str, dict[str, str]] = {
|
|||
"en": "Replace random new tracks by",
|
||||
"fr": "Remplacer les courses aléatoires nouvelle par"
|
||||
},
|
||||
"description": {
|
||||
"en": "The \"Random: New track\" option in the game will select any track respecting this condition.",
|
||||
"fr": "L'option \"Aléatoire: Nouvelle course\" dans le jeu va sélectionner n'importe quel course qui "
|
||||
"respecte cette condition."
|
||||
},
|
||||
"type": "string",
|
||||
"preview": "track_selecting"
|
||||
},
|
||||
|
@ -38,6 +43,10 @@ default_global_settings: dict[str, dict[str, str]] = {
|
|||
"en": "Include track if",
|
||||
"fr": "Inclure la course si"
|
||||
},
|
||||
"description": {
|
||||
"en": "Only the tracks respecting the condition will be in the patched game.",
|
||||
"fr": "Seulement les courses respectant la condition seront présente dans le jeu patché."
|
||||
},
|
||||
"type": "string",
|
||||
"preview": "track_selecting"
|
||||
},
|
||||
|
@ -46,6 +55,10 @@ default_global_settings: dict[str, dict[str, str]] = {
|
|||
"en": "Sort tracks by",
|
||||
"fr": "Trier les courses par"
|
||||
},
|
||||
"description": {
|
||||
"en": "Define how the tracks should be sorted in the mod.",
|
||||
"fr": "Défini comment les courses devrait être trié dans le mod."
|
||||
},
|
||||
"type": "string",
|
||||
"preview": "track_sorting"
|
||||
}
|
||||
|
|
|
@ -14,14 +14,15 @@ class Choices(AbstractModSettings):
|
|||
type = "check"
|
||||
|
||||
def __init__(self, enabled: bool = False,
|
||||
default: bool | None = None, text: dict[str] = None):
|
||||
default: bool | None = None, text: dict[str, str] = None, description: dict[str, str] = None):
|
||||
self._value = default if default is not None else False
|
||||
self.default = default
|
||||
self.description = description if description is not None else {}
|
||||
self.enabled = enabled
|
||||
|
||||
self.text = text if text is not None else {}
|
||||
|
||||
def tkinter_show(self, master: ttk.LabelFrame, checkbox) -> None:
|
||||
def tkinter_show(self, master, checkbox) -> None:
|
||||
super().tkinter_show(master, checkbox)
|
||||
|
||||
value_variable = tkinter.BooleanVar(master, value=self._value)
|
||||
|
|
|
@ -13,16 +13,18 @@ class Choices(AbstractModSettings):
|
|||
type = "choices"
|
||||
|
||||
def __init__(self, choices: list[str], enabled: bool = False,
|
||||
default: str | None = None, text: dict[str] = None):
|
||||
default: str | None = None, text: dict[str, str] = None, description: dict[str, str] = None):
|
||||
self._value = default if default is not None else choices[0]
|
||||
self.default = default
|
||||
self.enabled = enabled
|
||||
|
||||
self.text = text if text is not None else {}
|
||||
self.description = description if description is not None else {}
|
||||
self.choices = choices
|
||||
|
||||
def tkinter_show(self, master: ttk.LabelFrame, checkbox) -> None:
|
||||
def tkinter_show(self, master, checkbox) -> None:
|
||||
super().tkinter_show(master, checkbox)
|
||||
|
||||
master.grid_rowconfigure(1, weight=1)
|
||||
master.grid_columnconfigure(1, weight=1)
|
||||
|
||||
|
@ -31,3 +33,4 @@ class Choices(AbstractModSettings):
|
|||
|
||||
combobox = ttk.Combobox(master, values=self.choices, textvariable=value_variable)
|
||||
combobox.grid(row=1, column=1, sticky="EW")
|
||||
|
||||
|
|
|
@ -14,16 +14,18 @@ class String(AbstractModSettings):
|
|||
type = "string"
|
||||
|
||||
def __init__(self, preview: str = None, enabled: bool = False,
|
||||
default: str | None = None, text: dict[str] = None):
|
||||
default: str | None = None, text: dict[str, str] = None, description: dict[str, str] = None):
|
||||
self._value: str = default if default is not None else ""
|
||||
self.default = default
|
||||
self.enabled = enabled
|
||||
|
||||
self.text = text if text is not None else {}
|
||||
self.description = description if description is not None else {}
|
||||
self.preview: str | None = preview
|
||||
|
||||
def tkinter_show(self, master: ttk.LabelFrame, checkbox) -> None:
|
||||
def tkinter_show(self, master, checkbox) -> None:
|
||||
super().tkinter_show(master, checkbox)
|
||||
|
||||
master.grid_rowconfigure(1, weight=1)
|
||||
master.grid_columnconfigure(1, weight=1)
|
||||
|
||||
|
@ -36,8 +38,9 @@ class String(AbstractModSettings):
|
|||
if self.preview is not None:
|
||||
button = ttk.Button(
|
||||
master, text="...", width=3,
|
||||
command=lambda: AbstractPreviewWindow.get(
|
||||
self.preview
|
||||
)(master.master.master.master.mod_config, value_variable)
|
||||
command=lambda: AbstractPreviewWindow.get(self.preview)(
|
||||
master.master.master.master.mod_config, value_variable
|
||||
)
|
||||
)
|
||||
button.grid(row=1, column=2, sticky="EW")
|
||||
|
||||
|
|
Loading…
Reference in a new issue