Ejemplo n.º 1
0
    def __init__(self, app_root, *args, **kwargs):
        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)
        ConverterBase.__init__(self, app_root, *args, **kwargs)
        self.setup_window(*args, **kwargs)
Ejemplo n.º 2
0
 def lock_ui(self):
     ConverterBase.lock_ui(self)
     for w in self.include_buttons:
         w.config(state=tk.DISABLED)
     for w in self.topology_buttons:
         w.config(state=tk.DISABLED)
     self.weather_tolerance_spinbox.config(state=tk.DISABLED)
Ejemplo n.º 3
0
    def pack_widgets(self):
        ConverterBase.pack_widgets(self)

        # pack everything
        self.guess_mod2_checkbutton.pack(anchor='w', padx=10)
        self.use_mats_checkbutton.pack(anchor='w', padx=10)
        self.settings_frame.pack(fill='both', anchor='nw')
Ejemplo n.º 4
0
 def unlock_ui(self):
     ConverterBase.unlock_ui(self)
     for w in self.include_buttons:
         w.config(state=tk.NORMAL)
     for w in self.topology_buttons:
         w.config(state=tk.NORMAL)
     self.weather_tolerance_spinbox.config(state=tk.NORMAL)
Ejemplo n.º 5
0
    def pack_widgets(self):
        ConverterBase.pack_widgets(self)

        # pack everything
        for frame in self.topology_frames:
            frame.pack(expand=True, fill='both')

        for label in self.topology_labels:
            label.pack(anchor='w', padx=10, side='left')

        x = y = 0
        for button in self.include_buttons:
            button.grid(row=y, column=x, padx=5, pady=5, sticky="w")
            x += 1
            if x == 5:
                x = 0
                y += 1

        for button in self.topology_buttons:
            button.pack(anchor='w', padx=5, side='left')

        self.weather_tolerance_info.pack(fill='both',
                                         expand=True,
                                         padx=5,
                                         pady=5)
        self.weather_tolerance_spinbox.pack(padx=5, pady=5)

        self.include_frame.pack(expand=True, fill='both')
        self.topology_frame.pack(expand=True, fill='both')
        self.weather_tolerance_frame.pack(expand=True, fill='both')
Ejemplo n.º 6
0
    def tag_path_browse(self):
        curr_tag_path = self.tag_path.get()
        ConverterBase.tag_path_browse(self)
        if curr_tag_path == self.tag_path.get(): return

        try:
            ext = Path(curr_tag_path).suffix[1:].lower()
            self.src_menu.sel_index = self.object_types.index(ext)
        except Exception:
            pass
Ejemplo n.º 7
0
    def pack_widgets(self):
        ConverterBase.pack_widgets(self)

        # pack everything
        self.settings_frame.pack(fill='both', anchor='nw')
        self.from_label.pack(padx=(10, 0), pady=10, anchor='w', side='left')
        self.src_menu.pack(padx=(10, 0),
                           pady=10,
                           fill='x',
                           anchor='w',
                           side='left')
        self.to_label.pack(padx=(10, 0), pady=10, anchor='w', side='left')
        self.dst_menu.pack(padx=(10, 0),
                           pady=10,
                           fill='x',
                           anchor='w',
                           side='left')
Ejemplo n.º 8
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()
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
 def destroy(self):
     ConverterBase.destroy(self)
     window_base_class.destroy(self)
Ejemplo n.º 11
0
 def setup_window(self, *args, **kwargs):
     ConverterBase.setup_window(self, *args, **kwargs)
     self.pack_widgets()
     self.apply_style()
Ejemplo n.º 12
0
 def unlock_ui(self):
     ConverterBase.unlock_ui(self)
     for w in (self.guess_mod2_checkbutton, self.use_mats_checkbutton):
         w.config(state=tk.NORMAL)
Ejemplo n.º 13
0
 def lock_ui(self):
     ConverterBase.lock_ui(self)
     for w in (self.guess_mod2_checkbutton, self.use_mats_checkbutton):
         w.config(state=tk.DISABLED)
Ejemplo n.º 14
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()