Skip to content

Commit

Permalink
made ursfx ui not get created on import but on open.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokepetter committed Oct 3, 2023
1 parent aa6af97 commit f814da1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions ursina/prefabs/ursfx.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def ursfx(volume_curve, volume=.75, wave='sine', pitch=0, pitch_change=0, speed=
return a


class SynthGUI(Entity):
class UrsfxGUI(Entity):
def __init__(self, **kwargs):
super().__init__(parent=camera.ui, z=-998, **kwargs)

Expand Down Expand Up @@ -270,19 +270,21 @@ def play(self):

self.code_text.text = self.recipe

if __name__ == '__main__':
app = Ursina()

gui = SynthGUI(enabled=False)

def toggle_gui_input(key):
if key == 'f3':
gui.enabled = not gui.enabled
gui = None
def open_gui():
global gui
if not gui:
gui = UrsfxGUI(enabled=False)

Entity(input=toggle_gui_input)
def toggle_gui_input(key):
if key == 'f3':
gui.enabled = not gui.enabled
Entity(input=toggle_gui_input)
gui.enabled = True


if __name__ == '__main__':
app = Ursina()
sfx_editor = UrsfxGUI()
Sprite('shore', z=10, ppu=64, color=color.gray)
gui.enabled = True
app.run()
2 changes: 1 addition & 1 deletion ursina/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _collider_counter_update():
# 'Build' : Func(print, ' '),
'API Reference' : Func(webbrowser.open, 'https://www.ursinaengine.org/api_reference.html'),
# 'Asset Store' : Func(webbrowser.open, 'https://itch.io/tools/tag-ursina'),
'ursfx (Sound Effect Maker)' : lambda: exec('from ursina.prefabs import ursfx; ursfx.gui.enabled = True'),
'ursfx (Sound Effect Maker)' : lambda: exec('from ursina.prefabs import ursfx; ursfx.open_gui()'),
# 'Open Scene Editor' : Func(print, ' '),
'Change Render Mode <gray>[F10]<default>' : self.next_render_mode,
'Reset Render Mode <gray>[Shift+F10]<default>' : Func(setattr, self, 'render_mode', 'default'),
Expand Down

0 comments on commit f814da1

Please sign in to comment.