예제 #1
0
def show_ui(parent, world: "World", options: dict) -> dict:
    dialog = SimpleDialog(parent, 'Replace')
    horizontal_panel = SimplePanel(dialog.custom_panel, wx.HORIZONTAL)
    dialog.custom_panel.add_object(horizontal_panel)

    original_block = BlockDefine(horizontal_panel,
                                 world.world_wrapper.translation_manager,
                                 options.get("original_block_options"),
                                 wildcard=True)
    replacement_block = BlockDefine(horizontal_panel,
                                    world.world_wrapper.translation_manager,
                                    options.get("replacement_block_options"))
    horizontal_panel.add_object(original_block, 0)
    horizontal_panel.add_object(replacement_block, 0)
    dialog.Fit()

    if dialog.ShowModal() == wx.ID_OK:
        options = {
            "original_block_options":
            original_block.options,
            "replacement_block":
            world.translation_manager.get_version(
                replacement_block.platform,
                replacement_block.version).block.to_universal(
                    replacement_block.block,
                    force_blockstate=replacement_block.force_blockstate)[0],
            "replacement_block_options":
            original_block.options,
        }
    return options
예제 #2
0
 def _add_ui_element(self, label: str, obj: Type[wx.Control]) -> wx.Control:
     panel = SimplePanel(self, wx.HORIZONTAL)
     self.add_object(panel, 0)
     text = SimpleText(panel, label)
     panel.add_object(text, 0, wx.CENTER | wx.ALL)
     wx_obj = obj(panel)
     panel.add_object(wx_obj, 0, wx.CENTER | wx.ALL)
     return wx_obj
예제 #3
0
    def _add_property(self, property_name: str, property_values: List[str], default: str = None):
        prop_panel = SimplePanel(self._properties_panel, wx.HORIZONTAL)
        self._properties.append(prop_panel)
        self._properties_panel.add_object(prop_panel, 0)
        name_text = SimpleText(prop_panel, property_name)
        prop_panel.add_object(name_text, 0, wx.CENTER | wx.ALL)
        name_list = SimpleChoice(prop_panel)
        prop_panel.add_object(name_list, 0, wx.CENTER | wx.ALL)

        if self._wildcard:
            property_values.insert(0, "*")
        name_list.SetItems(property_values)
        if default and default in property_values:
            name_list.SetSelection(property_values.index(default))
        else:
            name_list.SetSelection(0)
예제 #4
0
 def __init__(self,
              parent,
              translation_manager: PyMCTranslate.TranslationManager,
              platform: str = None,
              version: Tuple[int, int, int] = None,
              blockstate: bool = None,
              namespace: str = None,
              base_name: str = None,
              properties: Dict[str, str] = None,
              wildcard: bool = False,
              **kwargs):
     super().__init__(parent, translation_manager, platform, version,
                      blockstate, namespace, base_name, **kwargs)
     self._properties: List[SimplePanel] = []
     self._wildcard = wildcard
     self._base_name_list.Bind(wx.EVT_CHOICE, self._on_base_name_change)
     self._properties_panel: Optional[SimplePanel] = SimplePanel(
         self, wx.VERTICAL)
     self.add_object(self._properties_panel, 0)
     self._set_properties(properties)
예제 #5
0
    def __init__(self, container, world: World):
        SimplePanel.__init__(
            self,
            container
        )
        self.world = world

        self._close_world_button = wx.Button(self, wx.ID_ANY, label='Close World')
        self._close_world_button.Bind(wx.EVT_BUTTON, self._close_world)
        self.add_object(self._close_world_button, 0, wx.ALL | wx.CENTER)

        self._input = SimplePanel(self, wx.HORIZONTAL)
        self.add_object(self._input, 0, wx.ALL|wx.CENTER)
        self._input.add_object(
            wx.StaticText(
                self._input,
                wx.ID_ANY,
                'Input World: ',
                wx.DefaultPosition,
                wx.DefaultSize,
                0,
            ), 0, wx.ALL|wx.CENTER
        )
        self._input.add_object(
            WorldUI(self._input, self.world.world_wrapper), 0, wx.ALL|wx.CENTER
        )

        self._output = SimplePanel(self, wx.HORIZONTAL)
        self.add_object(self._output, 0, wx.ALL | wx.CENTER)
        self._output.add_object(
            wx.StaticText(
                self._output,
                wx.ID_ANY,
                'Output World: ',
                wx.DefaultPosition,
                wx.DefaultSize,
                0,
            ), 0, wx.ALL | wx.CENTER
        )

        self._select_output_button = wx.Button(self, wx.ID_ANY, label='Select Output World')
        self._select_output_button.Bind(wx.EVT_BUTTON, self._show_world_select)
        self.add_object(self._select_output_button, 0, wx.ALL | wx.CENTER)

        self._convert_bar = SimplePanel(self, wx.HORIZONTAL)
        self.add_object(self._convert_bar, 0, wx.ALL | wx.CENTER)

        self.loading_bar = wx.Gauge(
            self._convert_bar,
            wx.ID_ANY,
            100,
            wx.DefaultPosition,
            wx.DefaultSize,
            wx.GA_HORIZONTAL,
        )
        self._convert_bar.add_object(self.loading_bar, options=wx.ALL | wx.EXPAND)
        self.loading_bar.SetValue(0)

        self.convert_button = wx.Button(self._convert_bar, wx.ID_ANY, label=lang.get('convert'))
        self._convert_bar.add_object(self.convert_button)
        self.convert_button.Bind(wx.EVT_BUTTON, self._convert_event)

        self.out_world_path = None
예제 #6
0
 def _setup_ui(self):
     super()._setup_ui()
     self._base_name_list.Bind(wx.EVT_CHOICE, self._update_properties)
     self._properties_panel = SimplePanel(self, wx.VERTICAL)
     self.add_object(self._properties_panel, 0)
예제 #7
0
    def enable(self):
        if self._canvas is None:
            self.Update()
            self._menu = SimplePanel(self)
            self._menu.Hide()
            self.add_object(self._menu, 0, wx.EXPAND)
            self._menu.Bind(wx.EVT_ENTER_WINDOW, self._steal_focus_menu)

            dim_label = wx.StaticText(self._menu, label="Dimension:")
            self._dim_options = SimpleChoiceAny(self._menu)
            self._dim_options.SetItems(
                dict(
                    zip(self._world.world_wrapper.dimensions.values(),
                        self._world.world_wrapper.dimensions.keys())))
            self._dim_options.SetValue("overworld")
            self._dim_options.Bind(wx.EVT_CHOICE, self._on_dimension_change)

            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.Add(dim_label, 0, wx.ALL, 5)
            sizer.Add(self._dim_options, 0, wx.ALL, 5)
            self._menu.add_object(sizer, 0)

            def create_button(text, operation):
                button = wx.Button(self._menu, label=text)
                button.Bind(wx.EVT_BUTTON, operation)
                self._menu.add_object(button, 0)
                self._menu_buttons.append(button)
                return button

            self._undo_button = create_button('Undo', self._undo_event)
            self._redo_button = create_button('Redo', self._redo_event)
            self._save_button = create_button('Save', self._save_event)
            create_button('Close', self._close_world)
            self._update_buttons()

            self._operation_ui = OperationUI(self._menu, self._world,
                                             self._run_operation)
            self._menu.add_object(self._operation_ui, options=0)
            self._operation_ui.Bind(wx.EVT_ENTER_WINDOW,
                                    self._steal_focus_operation)
            self._operation_ui.Layout()
            self._operation_ui.Fit()
            self._canvas = ControllableEditCanvas(self, self._world)
            self._select_destination_ui = SelectDestinationUI(
                self._menu, self._destination_select_cancel,
                self._destination_select_confirm,
                self._canvas.structure_locations)
            self._menu.add_object(self._select_destination_ui, options=0)
            self._select_destination_ui.Bind(wx.EVT_ENTER_WINDOW,
                                             self._steal_focus_destination)
            self._select_destination_ui.Layout()
            self._select_destination_ui.Fit()
            self._select_destination_ui.Hide()

            self.add_object(self._canvas, 0, wx.EXPAND)
            self._temp.Destroy()
            self._menu.Show()

            self.GetParent().Layout()
            self._menu.Layout()
            self._menu.Fit()
            self.Update()
        self._canvas.set_size(self.GetSize()[0], self.GetSize()[1])
        self._canvas.draw()
        self._canvas.Update()
        self._canvas.enable()
        self._change_dimension()