Пример #1
0
    def __init__(self, container, world: "BaseLevel",
                 close_self_callback: Callable[[], None]):
        SimplePanel.__init__(self, container)
        self.world = world
        self._close_self_callback = close_self_callback

        self._close_world_button = wx.Button(
            self, wx.ID_ANY, label=lang.get("world.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.add_object(
            wx.StaticText(
                self,
                label="{}: ".format(
                    lang.get("program_about.currently_opened_world")),
            ),
            0,
            wx.ALL | wx.CENTER,
        )
        self.add_object(WorldUI(self, self.world.level_wrapper), 0,
                        wx.ALL | wx.CENTER)
        self.add_object(
            wx.StaticText(
                self,
                label="{}\n<=================".format(
                    lang.get("program_about.choose_from_options")),
            ),
            0,
            wx.ALL | wx.CENTER,
        )
    def __init__(self, parent: wx.Window, open_world):
        super(AmuletMainMenu, self).__init__(parent)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        sizer.AddStretchSpacer(1)
        self._open_world_callback = open_world
        name_sizer = wx.BoxSizer()
        sizer.Add(name_sizer, 0, wx.CENTER)
        icon_img = image.logo.amulet_logo.bitmap(64, 64)

        icon = wx.StaticBitmap(self, wx.ID_ANY, icon_img, (0, 0), (64, 64))
        icon2 = wx.StaticBitmap(self, wx.ID_ANY, icon_img, (0, 0), (64, 64))
        icon2.Bind(wx.EVT_LEFT_DOWN,
                   lambda evt: wx.lib.inspection.InspectionTool().Show())
        name_sizer.Add(icon, flag=wx.CENTER)

        amulet_name = wx.StaticText(self, label="Amulet")
        amulet_name.SetFont(wx.Font(40, wx.DECORATIVE, wx.NORMAL, wx.NORMAL))
        name_sizer.Add(amulet_name,
                       flag=wx.CENTER | wx.LEFT | wx.RIGHT,
                       border=10)
        name_sizer.Add(icon2, flag=wx.CENTER)
        button_font = wx.Font(20, wx.DECORATIVE, wx.NORMAL, wx.NORMAL)
        self._open_world_button = wx.Button(
            self, label=lang.get("main_menu.open_world"), size=(400, 70))
        self._open_world_button.SetFont(button_font)
        self._open_world_button.Bind(wx.EVT_BUTTON, self._show_world_select)
        sizer.Add(self._open_world_button, 0, wx.ALL | wx.CENTER, 5)

        self._help_button = wx.Button(self,
                                      label=lang.get("main_menu.help"),
                                      size=(400, 70))
        self._help_button.SetToolTip(lang.get("app.browser_open_tooltip"))
        self._help_button.SetFont(button_font)
        self._help_button.Bind(wx.EVT_BUTTON, self._documentation)
        sizer.Add(self._help_button, 0, wx.ALL | wx.CENTER, 5)

        self._discord_button = wx.Button(self,
                                         label=lang.get("main_menu.discord"),
                                         size=(400, 70))
        self._discord_button.SetToolTip(lang.get("app.browser_open_tooltip"))
        self._discord_button.SetFont(button_font)
        self._discord_button.Bind(wx.EVT_BUTTON, self._discord)
        sizer.Add(self._discord_button, 0, wx.ALL | wx.CENTER, 5)

        sizer.AddStretchSpacer(2)
Пример #3
0
    def __init__(self, parent, open_world_callback):
        super(WorldSelectUI, self).__init__(parent)
        self.open_world_callback = open_world_callback
        self.header = simple.SimplePanel(self, wx.HORIZONTAL)
        self.header_open_world = wx.Button(self.header,
                                           wx.ID_ANY,
                                           label=lang.get("open_world_button"))
        self.header_open_world.Bind(wx.EVT_BUTTON, self._open_world)
        self.header.add_object(self.header_open_world)
        self.add_object(self.header, 0, 0)

        self.content = ScrollableWorldsUI(self, open_world_callback)
        self.add_object(self.content, 1, wx.EXPAND)
Пример #4
0
    def __init__(self, parent):
        wx.Frame.__init__(
            self,
            parent,
            id=wx.ID_ANY,
            title=f"Amulet V{version}",
            pos=wx.DefaultPosition,
            size=wx.Size(560, 400),
            style=wx.CAPTION
            | wx.CLOSE_BOX
            | wx.MINIMIZE_BOX
            | wx.MAXIMIZE_BOX
            | wx.MAXIMIZE
            | wx.SYSTEM_MENU
            | wx.TAB_TRAVERSAL
            | wx.CLIP_CHILDREN
            | wx.RESIZE_BORDER,
        )
        self.locale = wx.Locale(
            wx.LANGUAGE_ENGLISH)  # TODO: work out proper localisation
        icon = wx.Icon()
        icon.CopyFromBitmap(image.logo.icon128.bitmap())
        self.SetIcon(icon)

        self._open_worlds: Dict[str, CLOSEABLE_PAGE_TYPE] = {}

        self.world_tab_holder = flatnotebook.FlatNotebook(
            self, agwStyle=NOTEBOOK_MENU_STYLE)

        self.world_tab_holder.Bind(flatnotebook.EVT_FLATNOTEBOOK_PAGE_CLOSING,
                                   self._on_page_close)

        self._main_menu = AmuletMainMenu(self.world_tab_holder,
                                         self._open_world)

        self._last_page: BasePageUI = self._main_menu

        self._add_world_tab(self._main_menu, lang.get("main_menu"))

        self.Bind(wx.EVT_CLOSE, self._on_close_app)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self._page_change)

        if update_check is not None:
            self.Bind(
                update_check.EVT_UPDATE_CHECK,
                lambda evt: update_check.show_update_window(
                    self, version, evt),
            )
            update_check.check_for_update(version, self)

        self.Show()
Пример #5
0
 def _open_world(self, evt):
     dir_dialog = wx.DirDialog(
         None,
         lang.get("open_world_dialogue"),
         "",
         wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST,
     )
     try:
         if dir_dialog.ShowModal() == wx.ID_CANCEL:
             return
         path = dir_dialog.GetPath()
     except Exception:
         wx.LogError("select_directory_failed")
         return
     finally:
         dir_dialog.Destroy()
     self.open_world_callback(path)
Пример #6
0
    def __init__(self, parent, open_world_callback):
        super(RecentWorldUI, self).__init__(parent)
        self._open_world_callback = open_world_callback

        self.add_object(
            wx.StaticText(
                self,
                wx.ID_ANY,
                lang.get("recent_worlds"),
                wx.DefaultPosition,
                wx.DefaultSize,
                0,
            ),
            0,
            wx.ALL | wx.ALIGN_CENTER,
        )

        self._world_list = None
        self.rebuild()
Пример #7
0
    def __init__(self, container, world: World,
                 close_self_callback: Callable[[], None]):
        SimplePanel.__init__(self, container)
        self.world = world
        self._close_self_callback = close_self_callback

        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
Пример #8
0

def get_java_dir():
    if platform == "win32":
        return os.path.join(os.getenv("APPDATA"), ".minecraft")
    elif platform == "darwin":
        return os.path.expanduser("~/Library/Application Support/minecraft")
    else:
        return os.path.expanduser("~/.minecraft")


def get_java_saves_dir():
    return os.path.join(get_java_dir(), "saves")


minecraft_world_paths = {lang.get("java_platform"): get_java_saves_dir()}

if platform == "win32":
    minecraft_world_paths[lang.get("bedrock_platform")] = os.path.join(
        os.getenv("LOCALAPPDATA"),
        "Packages",
        "Microsoft.MinecraftUWP_8wekyb3d8bbwe",
        "LocalState",
        "games",
        "com.mojang",
        "minecraftWorlds",
    )

world_images: Dict[str, Tuple[int, wx.Bitmap, int]] = {}

Пример #9
0
    def __init__(self, canvas: "EditCanvas"):
        wx.BoxSizer.__init__(self, wx.HORIZONTAL)
        EditCanvasContainer.__init__(self, canvas)

        level = self.canvas.world
        self._version_text = wx.StaticText(
            canvas,
            label=
            f"{level.level_wrapper.platform}, {level.level_wrapper.version}",
        )
        self._version_text.SetToolTip(
            lang.get("program_3d_edit.file_ui.version_tooltip"))
        self.Add(self._version_text, 0)
        self.AddStretchSpacer(1)
        self._projection_button = wx.Button(canvas, label="3D")
        self._projection_button.SetToolTip(
            lang.get("program_3d_edit.file_ui.projection_tooltip"))
        self._projection_button.Bind(wx.EVT_BUTTON, self._on_projection_button)
        self.Add(self._projection_button, 0,
                 wx.TOP | wx.BOTTOM | wx.RIGHT | wx.CENTER, 5)
        self._location_button = wx.Button(
            canvas,
            label=", ".join([f"{s:.2f}" for s in self.canvas.camera.location]))
        self._location_button.SetToolTip(
            lang.get("program_3d_edit.file_ui.location_tooltip"))
        self._location_button.Bind(wx.EVT_BUTTON,
                                   lambda evt: self.canvas.goto())

        self.Add(self._location_button, 0,
                 wx.TOP | wx.BOTTOM | wx.RIGHT | wx.CENTER, 5)

        self._dim_options = SimpleChoiceAny(canvas)
        self._dim_options.SetToolTip(
            lang.get("program_3d_edit.file_ui.dim_tooltip"))
        self._dim_options.SetItems(level.level_wrapper.dimensions)
        self._dim_options.SetValue(level.level_wrapper.dimensions[0])
        self._dim_options.Bind(wx.EVT_CHOICE, self._on_dimension_change)

        self.Add(self._dim_options, 0,
                 wx.TOP | wx.BOTTOM | wx.RIGHT | wx.CENTER, 5)

        def create_button(text, operation):
            button = wx.Button(canvas, label=text)
            button.Bind(wx.EVT_BUTTON, operation)
            self.Add(button, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)
            return button

        self._undo_button: Optional[wx.Button] = create_button(
            "0", lambda evt: self.canvas.undo())
        self._undo_button.SetBitmap(
            image.icon.tablericons.arrow_back_up.bitmap(20, 20))
        self._undo_button.SetToolTip(
            lang.get("program_3d_edit.file_ui.undo_tooltip"))

        self._redo_button: Optional[wx.Button] = create_button(
            "0", lambda evt: self.canvas.redo())
        self._redo_button.SetBitmap(
            image.icon.tablericons.arrow_forward_up.bitmap(20, 20))
        self._redo_button.SetToolTip(
            lang.get("program_3d_edit.file_ui.redo_tooltip"))

        self._save_button: Optional[wx.Button] = create_button(
            "0", lambda evt: self.canvas.save())
        self._save_button.SetBitmap(
            image.icon.tablericons.device_floppy.bitmap(20, 20))
        self._save_button.SetToolTip(
            lang.get("program_3d_edit.file_ui.save_tooltip"))

        close_button = wx.BitmapButton(
            canvas, bitmap=image.icon.tablericons.square_x.bitmap(20, 20))
        close_button.SetToolTip(
            lang.get("program_3d_edit.file_ui.close_tooltip"))
        close_button.Bind(
            wx.EVT_BUTTON,
            lambda evt: wx.PostEvent(self.canvas, EditCloseEvent()))
        self.Add(close_button, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)

        self._update_buttons()

        self.Layout()