def _edit_controls(self): edit_config = config.get(EDIT_CONFIG_ID, {}) keybind_id = edit_config.get("keybind_group", DefaultKeybindGroupId) user_keybinds = edit_config.get("user_keybinds", {}) key_config = KeyConfigDialog(self, keybind_id, KeybindKeys, PresetKeybinds, user_keybinds) if key_config.ShowModal() == wx.ID_OK: user_keybinds, keybind_id, keybinds = key_config.options edit_config["user_keybinds"] = user_keybinds edit_config["keybind_group"] = keybind_id config.put(EDIT_CONFIG_ID, edit_config) self._canvas.set_key_binds(keybinds)
def _edit_controls(self): edit_config = config.get(EDIT_CONFIG_ID, {}) keybind_id = edit_config.get("keybind_group", DefaultKeybindGroupId) user_keybinds = edit_config.get("user_keybinds", {}) key_config = KeyConfigDialog(self, keybind_id, KeybindKeys, PresetKeybinds, user_keybinds) if key_config.ShowModal() == wx.ID_OK: user_keybinds, keybind_id, keybinds = key_config.options edit_config["user_keybinds"] = user_keybinds edit_config["keybind_group"] = keybind_id config.put(EDIT_CONFIG_ID, edit_config) self._canvas.buttons.clear_registered_actions() for action, (modifier_keys, trigger_key) in keybinds.items(): self._canvas.buttons.register_action(action, trigger_key, modifier_keys)
def rebuild(self, new_world: str = None): meta: dict = config.get("amulet_meta", {}) recent_worlds: list = meta.setdefault("recent_worlds", []) if new_world is not None: while new_world in recent_worlds: recent_worlds.remove(new_world) recent_worlds.insert(0, new_world) while len(recent_worlds) > 5: recent_worlds.pop(5) if self._world_list is not None: self._world_list.Destroy() self._world_list = WorldList(self, recent_worlds, self._open_world_callback, sort=False) self.add_object(self._world_list, 1, wx.EXPAND) self.Layout() config.put("amulet_meta", meta)
def _edit_options(self): if self._canvas is not None: fov = self._canvas.fov render_distance = self._canvas.render_distance camera_sensitivity = self._canvas.camera_rotate_speed dialog = SimpleDialog(self, "Options") sizer = wx.FlexGridSizer(3, 2, 0, 0) dialog.sizer.Add(sizer, flag=wx.ALL, border=5) fov_ui = wx.SpinCtrlDouble(dialog, min=0, max=180, initial=fov) def set_fov(evt): self._canvas.fov = fov_ui.GetValue() fov_ui.Bind(wx.EVT_SPINCTRLDOUBLE, set_fov) sizer.Add( wx.StaticText(dialog, label="Field of View"), flag=wx.LEFT | wx.TOP | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5, ) sizer.Add( fov_ui, flag=wx.LEFT | wx.TOP | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5, ) render_distance_ui = wx.SpinCtrl(dialog, min=0, max=50, initial=render_distance) def set_render_distance(evt): self._canvas.render_distance = render_distance_ui.GetValue() render_distance_ui.Bind(wx.EVT_SPINCTRL, set_render_distance) sizer.Add( wx.StaticText(dialog, label="Render Distance"), flag=wx.LEFT | wx.TOP | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5, ) sizer.Add( render_distance_ui, flag=wx.LEFT | wx.TOP | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5, ) camera_sensitivity_ui = wx.SpinCtrlDouble( dialog, min=0, max=10, initial=camera_sensitivity) def set_camera_sensitivity(evt): self._canvas.camera_rotate_speed = camera_sensitivity_ui.GetValue( ) camera_sensitivity_ui.Bind(wx.EVT_SPINCTRLDOUBLE, set_camera_sensitivity) sizer.Add( wx.StaticText(dialog, label="Camera Sensitivity"), flag=wx.LEFT | wx.TOP | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5, ) sizer.Add( camera_sensitivity_ui, flag=wx.LEFT | wx.TOP | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5, ) dialog.Fit() response = dialog.ShowModal() if response == wx.ID_OK: edit_config: dict = config.get(EDIT_CONFIG_ID, {}) edit_config.setdefault("options", {}) edit_config["options"]["fov"] = fov_ui.GetValue() edit_config["options"][ "render_distance"] = render_distance_ui.GetValue() edit_config["options"][ "camera_sensitivity"] = camera_sensitivity_ui.GetValue() config.put(EDIT_CONFIG_ID, edit_config) elif response == wx.ID_CANCEL: self._canvas.fov = fov self._canvas.render_distance = render_distance self._canvas.camera_rotate_speed = camera_sensitivity
def _save_config(self, evt): select_config = config.get("edit_select_location", {}) select_config["copy_air"] = self.copy_air select_config["copy_water"] = self.copy_water select_config["copy_lava"] = self.copy_lava config.put("edit_select_location", select_config)
def write_config(): config.put("window_preferences", PRE_EXISTING_CONFIG)