Esempio n. 1
0
    def setup_window(self, *args, **kwargs):
        kwargs.setdefault(
            "title",
            "%s to %s convertor" % (self.src_ext.capitalize(), self.dst_ext))
        self.title(kwargs.pop("title"))
        self.resizable(0, 0)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            pass

        # do path_replace to make sure the path works on linux
        tags_dir = Path(path_split(curr_dir, "tags", after=True))
        if self.app_root is not self and hasattr(self.app_root, "tags_dir"):
            tags_dir = getattr(self.app_root, "tags_dir")

        self.tags_dir = tk.StringVar(self, tags_dir)
        self.tag_path = tk.StringVar(self)

        # make the frames
        self.tags_dir_frame = tk.LabelFrame(self, text="Directory of tags")
        self.tag_path_frame = tk.LabelFrame(self, text="Single tag")

        # add the filepath boxes
        self.tags_dir_entry = tk.Entry(self.tags_dir_frame,
                                       textvariable=self.tags_dir)
        self.tags_dir_entry.config(width=70, state=tk.DISABLED)
        self.tag_path_entry = tk.Entry(self.tag_path_frame,
                                       textvariable=self.tag_path)
        self.tag_path_entry.config(width=70, state=tk.DISABLED)

        # add the buttons
        self.convert_dir_btn = tk.Button(self,
                                         text="Convert directory",
                                         width=15,
                                         command=self.convert_dir)
        self.convert_file_btn = tk.Button(self,
                                          text="Convert tag",
                                          width=15,
                                          command=self.convert_tag)
        self.tags_dir_browse_btn = tk.Button(self.tags_dir_frame,
                                             text="Browse",
                                             width=6,
                                             command=self.tags_dir_browse)
        self.tag_path_browse_btn = tk.Button(self.tag_path_frame,
                                             text="Browse",
                                             width=6,
                                             command=self.tag_path_browse)

        if self.app_root and self.app_root is not self:
            self.transient(self.app_root)
Esempio n. 2
0
    def setup_window(self, *args, **kwargs):
        ConverterBase.setup_window(self, *args, **kwargs)

        self.guess_mod2 = tk.IntVar(self, 1)
        self.use_mats = tk.IntVar(self, 1)

        # make the frames
        self.settings_frame = tk.LabelFrame(self, text="Conversion settings")

        # add the buttons
        self.guess_mod2_checkbutton = tk.Checkbutton(
            self.settings_frame, variable=self.guess_mod2,
            text="Locate gbxmodel in directory")
        self.use_mats_checkbutton = tk.Checkbutton(
            self.settings_frame, variable=self.use_mats,
            text="Use collision materials as shaders")

        self.pack_widgets()
        self.apply_style()
Esempio n. 3
0
    def setup_window(self, *args, **kwargs):
        ConverterBase.setup_window(self, *args, **kwargs)

        self.settings_frame = tk.LabelFrame(self, text="Conversion settings")
        self.from_label = tk.Label(self.settings_frame, text="from")
        self.src_menu = ScrollMenu(
            self.settings_frame,
            options=self.object_types,
            menu_width=20,
            sel_index=0,
        )
        self.to_label = tk.Label(self.settings_frame, text="to")
        self.dst_menu = ScrollMenu(
            self.settings_frame,
            options=self.object_types,
            menu_width=20,
            sel_index=10,
        )

        self.pack_widgets()
        self.apply_style()
    def __init__(self, app_root, *args, **kwargs):
        self.app_root = app_root

        if isinstance(self, tk.Toplevel):
            kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)

        window_base_class.__init__(self, app_root, *args, **kwargs)
        BinillaWidget.__init__(self, app_root, *args, **kwargs)

        self.title("Halo 1 & 2 bitmap source extractor")
        self.resizable(0, 0)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        self.tags_dir = tk.StringVar(self)
        self.data_dir = tk.StringVar(self)
        self.tags_dir.set(e_c.WORKING_DIR.joinpath('tags'))
        self.data_dir.set(e_c.WORKING_DIR.joinpath('data'))

        # make the frames
        self.tags_dir_frame = tk.LabelFrame(self, text="Tags directory")
        self.data_dir_frame = tk.LabelFrame(self, text="Data directory")

        # add the filepath boxes
        self.tags_dir_entry = tk.Entry(self.tags_dir_frame,
                                       textvariable=self.tags_dir)
        self.tags_dir_entry.config(width=55, state=tk.DISABLED)
        self.data_dir_entry = tk.Entry(self.data_dir_frame,
                                       textvariable=self.data_dir)
        self.data_dir_entry.config(width=55, state=tk.DISABLED)

        # add the buttons
        self.extract_btn = tk.Button(self,
                                     text="Extract source files",
                                     width=22,
                                     command=self.extract)
        self.tags_dir_browse_btn = tk.Button(self.tags_dir_frame,
                                             text="Browse",
                                             width=6,
                                             command=self.tags_dir_browse)
        self.data_dir_browse_btn = tk.Button(self.data_dir_frame,
                                             text="Browse",
                                             width=6,
                                             command=self.data_dir_browse)

        # pack everything
        self.tags_dir_entry.pack(expand=True, fill='x', side='left')
        self.data_dir_entry.pack(expand=True, fill='x', side='left')
        self.tags_dir_browse_btn.pack(fill='x', side='left')
        self.data_dir_browse_btn.pack(fill='x', side='left')

        self.tags_dir_frame.pack(expand=True, fill='both')
        self.data_dir_frame.pack(expand=True, fill='both')
        self.extract_btn.pack(fill='both', padx=5, pady=5)

        if self.app_root is not self and self.app_root:
            self.transient(self.app_root)

        self.apply_style()
Esempio n. 5
0
    def generate_widgets(self):
        if self._initialized:
            return

        pr_version_str = "%s.%s.%s" % version_info[:3]
        tk_version_str = str(tk.TkVersion)

        main_frame = tk.Frame(self, borderwidth=0, relief='sunken')
        buttons_frame = tk.Frame(self)
        header_frame = tk.Frame(main_frame)
        py_label_frame = tk.Frame(header_frame, borderwidth=0)

        app_image_button = None
        if os.path.isfile(self.appbitmap_filepath):
            self.app_image = tk.PhotoImage(file=self.appbitmap_filepath)
            app_image_button = tk.Button(header_frame,
                                         text='[picture]',
                                         bd=0,
                                         image=self.app_image,
                                         relief='flat',
                                         command=self._pressed,
                                         highlightthickness=0)

        app_name_label = tk.Label(header_frame,
                                  text=self.app_name,
                                  font=self.get_font("heading"))
        app_name_label.font_type = "heading"
        python_ver_label = tk.Label(py_label_frame,
                                    text='Python version:  %s' %
                                    pr_version_str)
        tk_ver_label = tk.Label(py_label_frame,
                                text='Tk version:  %s' % tk_version_str)

        close_button = tk.Button(buttons_frame,
                                 text='Close',
                                 width=12,
                                 command=self.destroy)

        modules_frame = tk.Frame(main_frame, borderwidth=0)
        names = tuple(sorted(self.module_infos))
        max_width = 1
        if len(names) > 3:
            max_width = 2

        x = y = 0
        for name in names:
            info = self.module_infos[name]
            proper_name = self.get_proper_module_name(name)
            accelerated_str = ""
            if info.get("accelerated", None) is not None:
                accelerated_str = "  -  " + ("Fast" if info["accelerated"] else
                                             "Slow")

            module_frame = tk.LabelFrame(
                modules_frame,
                text="%s  -  %s: %s%s" %
                (info["date"], proper_name, self.get_version_string(name),
                 accelerated_str))

            license_button = tk.Button(module_frame,
                                       text='License',
                                       width=8,
                                       command=lambda s=self, n=name: s.
                                       display_module_text(n, "license"))
            readme_button = tk.Button(module_frame,
                                      text='Readme',
                                      width=8,
                                      command=lambda s=self, n=name: s.
                                      display_module_text(n, "readme"))
            browse_button = tk.Button(
                module_frame,
                text='Browse',
                width=8,
                command=lambda s=self, n=name: s.open_module_location(n))

            browse_button.pack(expand=True,
                               fill='both',
                               side='left',
                               padx=6,
                               pady=4)
            license_button.pack(expand=True,
                                fill='both',
                                side='left',
                                padx=6,
                                pady=4)
            readme_button.pack(expand=True,
                               fill='both',
                               side='left',
                               padx=6,
                               pady=4)
            if not info["location"]:
                browse_button.config(state="disabled")
            if not info["license"]:
                license_button.config(state="disabled")
            if not info["readme"]:
                readme_button.config(state="disabled")

            module_frame.grid(row=y, column=x, sticky="news")
            x += 1
            if x == max_width:
                x = 0
                y += 1

        app_name_label.pack(padx=10, fill='both')
        if app_image_button:
            app_image_button.pack(padx=0, pady=3)
        py_label_frame.pack(padx=10, pady=0)

        python_ver_label.pack(padx=10, pady=0, side='left')
        tk_ver_label.pack(padx=10, pady=0, side='right')
        close_button.pack(padx=5, pady=5)

        header_frame.pack(expand=True, fill="both")
        main_frame.pack(expand=True, fill="both")
        modules_frame.pack(fill='both')
        buttons_frame.pack(fill="x")

        self._initialized = True
Esempio n. 6
0
    def setup_window(self, *args, **kwargs):
        ConverterBase.setup_window(self, *args, **kwargs)

        self.include_weather_polyhedra = tk.IntVar(self, 1)
        self.include_fog_planes = tk.IntVar(self, 1)
        self.include_portals = tk.IntVar(self, 1)
        self.include_collision = tk.IntVar(self, 1)
        self.include_renderable = tk.IntVar(self, 1)
        self.include_mirrors = tk.IntVar(self, 0)
        self.include_lightmaps = tk.IntVar(self, 0)

        self.include_markers = tk.IntVar(self, 1)
        self.include_lens_flares = tk.IntVar(self, 0)

        self.fan_portals = tk.IntVar(self, 1)
        self.fan_weather_polyhedra = tk.IntVar(self, 1)
        self.fan_fog_planes = tk.IntVar(self, 1)
        self.fan_mirrors = tk.IntVar(self, 1)
        self.fan_collision = tk.IntVar(self, 1)

        self.optimize_portals = tk.IntVar(self, 0)
        self.optimize_fog_planes = tk.IntVar(self, 0)
        self.weather_tolerance_string = tk.StringVar(
            self, str(self.weather_tolerance))
        self.weather_tolerance_string.trace(
            "w", lambda *a, s=self: s.set_weather_tolerance())

        # make the frames
        self.include_frame = tk.LabelFrame(self,
                                           text="Geometry/markers to include")
        self.weather_tolerance_frame = tk.LabelFrame(
            self, text="Weather polyhedron tolerance")
        self.topology_frame = tk.LabelFrame(self, text="Topology generation")

        # Generate the important frame and its contents
        include_vars = {
            "Weather polyhedra": self.include_weather_polyhedra,
            "Fog planes": self.include_fog_planes,
            "Portals": self.include_portals,
            "Collidable": self.include_collision,
            "Renderable": self.include_renderable,
            "Mirrors": self.include_mirrors,
            "Lightmaps": self.include_lightmaps,
            "Markers": self.include_markers,
            "Lens flares": self.include_lens_flares
        }
        self.include_buttons = []
        for text in ("Collidable", "Portals", "Renderable",
                     "Weather polyhedra", "Fog planes", "Markers", "Mirrors",
                     "Lens flares", "Lightmaps"):
            self.include_buttons.append(
                tk.Checkbutton(self.include_frame,
                               variable=include_vars[text],
                               text=text))

        # Generate the topology frame and its contents
        topology_vars = {
            "Weather polyhedra": self.fan_weather_polyhedra,
            "Fog planes": self.fan_fog_planes,
            "Mirrors": self.fan_mirrors,
            "Portals": self.fan_portals,
            "Collision": self.fan_collision
        }
        self.topology_frames = []
        self.topology_labels = []
        self.topology_buttons = []
        for text in ("Portals", "Fog planes", "Weather polyhedra", "Mirrors",
                     "Collision"):
            var = topology_vars[text]
            f = tk.Frame(self.topology_frame)
            name_lbl = tk.Label(f, text=text, width=17, anchor="w")
            fan_cbtn = tk.Checkbutton(f, variable=var, text="Triangle fan")
            strip_cbtn = tk.Checkbutton(f,
                                        variable=var,
                                        text="Triangle strip",
                                        onvalue=0,
                                        offvalue=1)
            self.topology_frames.append(f)
            self.topology_labels.append(name_lbl)
            self.topology_buttons.extend((fan_cbtn, strip_cbtn))
            if text == "Portals":
                self.topology_buttons.append(
                    tk.Checkbutton(f,
                                   variable=self.optimize_portals,
                                   text="Optimize"))
            elif text == "Fog planes":
                self.topology_buttons.append(
                    tk.Checkbutton(f,
                                   variable=self.optimize_fog_planes,
                                   text="Optimize"))

        self.weather_tolerance_info = tk.Label(
            self.weather_tolerance_frame,
            justify='left',
            anchor="w",
            text=
            ("Due to how weather polyhedrons work, there is no geometry to extract, so it must be generated. \n"
             "My method for doing this isn't perfect, so sometimes geometry will be missing faces. Adjust this\n"
             "value to find the sweet spot. NEVER set to 0, and be wary of setting to 0.0001 or higher.\n"
             "\tNOTE: You will probably need to manually clean up the generated geometry a bit."
             ))
        self.weather_tolerance_spinbox = tk.Spinbox(
            self.weather_tolerance_frame,
            from_=self.min_weather_tolerance,
            to=100,
            width=25,
            increment=self.weather_tolerance,
            textvariable=self.weather_tolerance_string,
            justify="right")

        self.pack_widgets()
        self.apply_style()