Skip to content

Commit

Permalink
Tidied Phasmo actions architecture. Needs sorting for GUI UX
Browse files Browse the repository at this point in the history
  • Loading branch information
howroyd committed Nov 13, 2023
1 parent b9a99db commit ebcacd7
Show file tree
Hide file tree
Showing 22 changed files with 1,310 additions and 1,164 deletions.
1 change: 1 addition & 0 deletions src/simonsays_drgreengiant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __post_init__(self):
actions.update(randomaction)

self.config.update(randomconfig)

self.actions = actions

def find_tag_by_command(self, command: str) -> str | None:
Expand Down
9 changes: 9 additions & 0 deletions src/simonsays_drgreengiant/gameactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ def run(self, *, force: bool = False) -> errorcodes.ErrorSet:

#####################################################################

@dataclasses.dataclass(slots=True, frozen=True)
class ActionConfigPair:
"""A pair of an action and config"""
action: Action
config: ActionConfig


ActionConfigFp = tuple[GenericAction, ActionConfig]


@dataclasses.dataclass(slots=True)
class ActionAndConfig:
Expand Down
2 changes: 1 addition & 1 deletion src/simonsays_drgreengiant/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def make_selection_frame(where, cfg: config.Config) -> tuple[tk.Frame, tk.String
selection.set(next(iter(cfg.config)))

tk.Label(frame, text="Select action:").pack(side=tk.LEFT, anchor=tk.W, padx=10)
tk.OptionMenu(frame, selection, *list(cfg.config.keys())).pack(side=tk.RIGHT, anchor=tk.E, padx=10)
tk.OptionMenu(frame, selection, *sorted(list(cfg.config.keys()))).pack(side=tk.RIGHT, anchor=tk.E, padx=10)

return frame, selection

Expand Down
Loading

0 comments on commit ebcacd7

Please sign in to comment.