def _create_scene_file(self, level_name, scene_name, ext, matching_ssb=None): dir_name = f"{SCRIPT_DIR}/{level_name}" if '.' in scene_name: raise ValueError( _("The file name provided must not have a file extension.")) if len(scene_name) > 8: raise ValueError( _("The file name provided is too long (max 8 characters).")) ssx_name = f"{dir_name}/{scene_name}.{ext}" self.project.ensure_dir(dir_name) self.project.create_new_file(ssx_name, self._get_empty_scene(), FileType.SSA) if matching_ssb is not None: ssb_name = f"{dir_name}/{scene_name}{matching_ssb}.ssb" save_kwargs = { 'filename': ssb_name, 'static_data': self.project.get_rom_module().get_static_data(), 'project_fm': self.project.get_project_file_manager() } self.project.create_new_file( ssb_name, SsbLoadedFileHandler.create(**save_kwargs), SsbLoadedFileHandler, **save_kwargs) # Update debugger SkyTempleMainController.debugger_manager().on_script_added( ssb_name, level_name, ext, f'{scene_name}.{ext}') return ssx_name, ssb_name else: return ssx_name, None
def collect_state_context() -> Dict[str, 'Captured']: from skytemple.controller.main import MainController from skytemple.core.rom_project import RomProject from skytemple_files.common.util import capture_any rom_project = RomProject.get_current() try: view_state = MainController._instance._current_view_module.collect_debugging_info( # type: ignore MainController._instance._current_view_controller # type: ignore ) if "models" in view_state: # type: ignore view_state["models"] = { k: capture_any(v) for k, v in view_state["models"].items() } # type: ignore except Exception as ex: view_state = {"error_collecting": str(ex)} w, h = MainController.window().get_size() dw = if_not_none(MainController.debugger_manager()._opened_main_window, lambda w: w.get_size()[0]) dh = if_not_none(MainController.debugger_manager()._opened_main_window, lambda w: w.get_size()[1]) return { "skytemple": { "window": { "width": w, "height": h, }, "rom": { "filename": if_not_none(rom_project, lambda p: p.get_rom_name()), "edition": if_not_none(rom_project, lambda p: p.get_rom_module().get_static_data()), }, "module": type(MainController._instance._current_view_module).__qualname__, "view": MainController._instance._current_view_controller_class. __qualname__, # type: ignore "view_state": view_state }, "ssb_debugger": { "window": { "width": dw, "height": dh, }, "open_scripts": debugger_open_scripts(MainController.debugger_manager()), "focused_script": debugger_focused_script(MainController.debugger_manager()), #"emulator_state": debugger_emulator_state(MainController.debugger_manager()) } }
def get_content(self) -> Gtk.Widget: box: Gtk.Box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 20) label = self.generate_content_label( _('Each of the scenes has at least one script assigned to them, which is run when the scene is loaded.\n' 'In addition to that, there is also "COMMON/unionall.ssb", which contains the game\'s coroutines ' '(main scripts).\n\n' 'To edit the game\'s scripts, open the Script Engine Debugger. You can also do this by clicking the bug ' 'icon in the top right.\n') ) button_box = Gtk.ButtonBox.new(Gtk.Orientation.VERTICAL) button: Gtk.Button = Gtk.Button.new_with_label(_('Open Script Engine Debugger')) button.connect('clicked', lambda *args: MainController.debugger_manager().open(MainController.window())) button_box.pack_start(button, False, False, 0) box.pack_start(label, False, False, 0) box.pack_start(button_box, False, False, 0) return box