mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-06 12:48:22 +02:00
mod settings name can now be translated in the settings window
This commit is contained in:
parent
6b001709c5
commit
13bf66c94e
6 changed files with 42 additions and 11 deletions
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
"specific_settings": {
|
"specific_settings": {
|
||||||
"mode": {
|
"mode": {
|
||||||
|
"text": {
|
||||||
|
"en": "Mode",
|
||||||
|
"fr": "Mode"
|
||||||
|
},
|
||||||
"type": "choices",
|
"type": "choices",
|
||||||
"choices": [
|
"choices": [
|
||||||
"normal",
|
"normal",
|
||||||
|
@ -13,6 +17,10 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"highlight_if": {
|
"highlight_if": {
|
||||||
|
"text": {
|
||||||
|
"en": "Highlight if",
|
||||||
|
"fr": "Surligner si"
|
||||||
|
},
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"preview": "track_formatting"
|
"preview": "track_formatting"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ AbstractModSettings: any
|
||||||
class Window(tkinter.Toplevel):
|
class Window(tkinter.Toplevel):
|
||||||
def __init__(self, mod_config: "ModConfig"):
|
def __init__(self, mod_config: "ModConfig"):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.root = self.master.root
|
||||||
self.resizable(False, False)
|
self.resizable(False, False)
|
||||||
self.grab_set()
|
self.grab_set()
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ class Window(tkinter.Toplevel):
|
||||||
|
|
||||||
self.mod_config = mod_config
|
self.mod_config = mod_config
|
||||||
|
|
||||||
self.panel_window = ttk.Notebook(self)
|
self.panel_window = NotebookSettings(self)
|
||||||
self.panel_window.grid(row=1, column=1, sticky="NEWS")
|
self.panel_window.grid(row=1, column=1, sticky="NEWS")
|
||||||
|
|
||||||
self.frame_global_settings = FrameSettings(
|
self.frame_global_settings = FrameSettings(
|
||||||
|
@ -33,8 +34,14 @@ class Window(tkinter.Toplevel):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class NotebookSettings(ttk.Notebook):
|
||||||
|
def __init__(self, master):
|
||||||
|
super().__init__(master)
|
||||||
|
self.root = self.master.root
|
||||||
|
|
||||||
|
|
||||||
class FrameSettings(ttk.Frame):
|
class FrameSettings(ttk.Frame):
|
||||||
def __init__(self, master: ttk.Notebook, text: str, settings: dict[str, "AbstractModSettings"]):
|
def __init__(self, master, text: str, settings: dict[str, "AbstractModSettings"]):
|
||||||
"""
|
"""
|
||||||
Create a frame where settings will be displayed
|
Create a frame where settings will be displayed
|
||||||
:param master: master window
|
:param master: master window
|
||||||
|
@ -43,11 +50,16 @@ class FrameSettings(ttk.Frame):
|
||||||
"""
|
"""
|
||||||
super().__init__(master)
|
super().__init__(master)
|
||||||
master.add(self, text=text)
|
master.add(self, text=text)
|
||||||
|
self.root = self.master.root
|
||||||
|
|
||||||
self.columnconfigure(1, weight=1)
|
self.columnconfigure(1, weight=1)
|
||||||
|
|
||||||
for index, (settings_name, settings_data) in enumerate(settings.items()):
|
for index, (settings_name, settings_data) in enumerate(settings.items()):
|
||||||
checkbox = ttk.Checkbutton(self, text=settings_name)
|
text = settings_data.text.get(self.root.options["language"])
|
||||||
|
if text is None: text = settings_data.text.get("*")
|
||||||
|
if text is None: text = settings_name
|
||||||
|
|
||||||
|
checkbox = ttk.Checkbutton(self, text=text)
|
||||||
frame = ttk.LabelFrame(self, labelwidget=checkbox)
|
frame = ttk.LabelFrame(self, labelwidget=checkbox)
|
||||||
frame.grid(row=index, column=1, sticky="NEWS")
|
frame.grid(row=index, column=1, sticky="NEWS")
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,27 @@ Thread: any
|
||||||
|
|
||||||
|
|
||||||
global_settings = {
|
global_settings = {
|
||||||
"override_random_new": {
|
"force_random_new": {
|
||||||
|
"text": {
|
||||||
|
"en": "Force random new tracks",
|
||||||
|
"fr": "Forcer les courses aléatoires nouvelle"
|
||||||
|
},
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"preview": "track_selecting"
|
"preview": "track_selecting"
|
||||||
},
|
},
|
||||||
"remove_track_if": {
|
"remove_track_if": {
|
||||||
|
"text": {
|
||||||
|
"en": "Remove track if",
|
||||||
|
"fr": "Retirer la course si"
|
||||||
|
},
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"preview": "track_selecting"
|
"preview": "track_selecting"
|
||||||
},
|
},
|
||||||
"sort_track_by": {
|
"sort_tracks_by": {
|
||||||
|
"text": {
|
||||||
|
"en": "Sort tracks by",
|
||||||
|
"fr": "Trier les courses par"
|
||||||
|
},
|
||||||
"type": "choices",
|
"type": "choices",
|
||||||
"choices": [
|
"choices": [
|
||||||
"test1",
|
"test1",
|
||||||
|
|
|
@ -12,8 +12,9 @@ class Choices(AbstractModSettings):
|
||||||
|
|
||||||
type = "choices"
|
type = "choices"
|
||||||
|
|
||||||
def __init__(self, choices: list[str], value: str = None, enabled: bool = False):
|
def __init__(self, choices: list[str], value: str = None, enabled: bool = False, text: dict[str] = None):
|
||||||
self._value = value if value is not None else choices[0]
|
self._value = value if value is not None else choices[0]
|
||||||
|
self.text = text if text is not None else {}
|
||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
self.choices = choices
|
self.choices = choices
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,9 @@ class String(AbstractModSettings):
|
||||||
|
|
||||||
type = "string"
|
type = "string"
|
||||||
|
|
||||||
def __init__(self, value: str = None, preview: str = None, enabled: bool = False):
|
def __init__(self, value: str = None, preview: str = None, enabled: bool = False, text: dict[str] = None):
|
||||||
self._value: str = value if value is not None else ""
|
self._value: str = value if value is not None else ""
|
||||||
|
self.text = text if text is not None else {}
|
||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
self.preview: str | None = preview
|
self.preview: str | None = preview
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,10 @@ class AbstractModSettings(ABC):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type: str # type name of the settings
|
type: str # type name of the settings
|
||||||
|
text: dict[str] # text to display in the settings window depending on the language
|
||||||
enabled: bool # is the settings enabled
|
enabled: bool # is the settings enabled
|
||||||
_value: str # value for the settings
|
_value: str # value for the settings
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __init__(self, value: str = None, preview: str = None, enabled: bool = False):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self) -> "any | None":
|
def value(self) -> "any | None":
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue