Skip to content

Commit

Permalink
editor: Add menu option to try the edited scene
Browse files Browse the repository at this point in the history
  • Loading branch information
tchx84 committed Feb 28, 2024
1 parent a98c8d8 commit 178550c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/gameeky/editor/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
find_project_path,
bytearray_to_string,
launch_path,
launch_player,
)


Expand Down Expand Up @@ -199,6 +200,21 @@ def _do_save(self, path) -> None:
self._scene_path = path
self._pending_changes = False

def __on_try(self, action: Gio.SimpleAction, data: Optional[Any] = None) -> None:
if self._scene_path is None:
self.__on_save_as()
else:
self._do_save(self._scene_path)
self._try_scene()

def _try_scene(self) -> None:
if self._project_path is None:
return
if self._scene_path is None:
return

launch_player(self._project_path, self._scene_path)

def __on_about(self, action: Gio.SimpleAction, data: Optional[Any] = None) -> None:
present_about(self._window)

Expand Down Expand Up @@ -287,6 +303,10 @@ def do_startup(self) -> None:
save_as_action.connect("activate", self.__on_save_as)
self.add_action(save_as_action)

try_action = Gio.SimpleAction.new("try", None)
try_action.connect("activate", self.__on_try)
self.add_action(try_action)

browse_action = Gio.SimpleAction.new("browse", None)
browse_action.connect("activate", self.__on_browse)
self.add_action(browse_action)
Expand Down
4 changes: 4 additions & 0 deletions src/gameeky/editor/widgets/scene_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@
<attribute name="action">app.save_as</attribute>
<attribute name="label" translatable="yes">Save _As…</attribute>
</item>
<item>
<attribute name="action">app.try</attribute>
<attribute name="label" translatable="yes">_Try It</attribute>
</item>
<item>
<attribute name="action">app.edit</attribute>
<attribute name="label" translatable="yes">_Settings</attribute>
Expand Down

0 comments on commit 178550c

Please sign in to comment.