Skip to content

Commit

Permalink
toggle radius in new view menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ego-lay-atman-bay committed Jul 6, 2024
1 parent 0824466 commit 55c2b93
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def updateObject(self, obj : wmwpy.classes.Object):
tags = ('object', 'foreground', id)
)

if obj.Type is not None:
if self.settings.get('visualization.radius', True) and obj.Type is not None:
properties = deepcopy(obj.defaultProperties)
properties.update(obj.properties)
for property in properties:
Expand Down Expand Up @@ -1737,7 +1737,7 @@ def createMenubar(self):
self.menubar = tk.Menu(self)
self.config(menu = self.menubar)

self.file_menu = tk.Menu(self.menubar, tearoff=0)
self.file_menu = tk.Menu(self.menubar, tearoff = 0)

self.file_menu.add_command(label = 'Open', command = self.openLevel, accelerator = f'{crossplatform.shortModifier()}+O')
self.file_menu.add_command(label = 'Save', command = self.saveLevel, accelerator = f'{crossplatform.shortModifier()}+S')
Expand All @@ -1747,7 +1747,7 @@ def createMenubar(self):

self.menubar.add_cascade(label = 'File', menu = self.file_menu)

self.help_menu = tk.Menu(self.menubar, tearoff=0)
self.help_menu = tk.Menu(self.menubar, tearoff = 0)

self.help_menu.add_command(label = 'Discord', command = lambda *args : webbrowser.open(__links__['discord']))
self.help_menu.add_command(label = 'About', command = self.showAbout)
Expand All @@ -1756,6 +1756,30 @@ def createMenubar(self):
self.help_menu.add_command(label = 'Open log', command = lambda *args : crossplatform.open_file(_log_filename))

self.menubar.add_cascade(label = 'Help', menu = self.help_menu)

self.view_menu: dict[
typing.Literal[
'menu',
'vars',
],
tk.Menu | dict[typing.Literal[
'radius'
], tk.BooleanVar]
] = {
'menu': tk.Menu(self.menubar, tearoff = 0),
'vars': {
'radius': tk.BooleanVar(value = self.settings.get('visualization.radius', True))
}
}

self.view_menu['vars']['radius'].trace_add('write', lambda *args : self.updateView('radius', self.view_menu['vars']['radius'].get()))
self.view_menu['menu'].add_checkbutton(label = 'radius', onvalue = True, offvalue = False, variable = self.view_menu['vars']['radius'])

self.menubar.add_cascade(label = 'View', menu = self.view_menu['menu'])

def updateView(self, view: str, state: bool = True):
self.settings.set(['visualization', view], state)
self.updateLevel()

def showAbout(self):
about = popups.About(
Expand Down

0 comments on commit 55c2b93

Please sign in to comment.