Exemplo n.º 1
0
    def __init__(self, master, *args, **kwargs):
        kwargs.update(bg=self.default_bg_color, bd=self.listbox_depth,
            relief='sunken', highlightthickness=0)
        kwargs.setdefault('app_root', master)

        select_mode = kwargs.pop('select_mode', 'browse')

        self.app_root = kwargs.pop('app_root')
        BinillaWidget.__init__(self)
        tk.Frame.__init__(self, master, *args, **kwargs)

        self.tags_tree_frame = tk.Frame(self, highlightthickness=0)

        self.tags_tree = tk.ttk.Treeview(
            self.tags_tree_frame, selectmode=select_mode, padding=(0, 0))
        self.scrollbar_y = tk.Scrollbar(
            self.tags_tree_frame, orient='vertical',
            command=self.tags_tree.yview)
        self.tags_tree.config(yscrollcommand=self.scrollbar_y.set)

        self.tags_tree.bind('<<TreeviewOpen>>', self.open_selected)
        self.tags_tree.bind('<<TreeviewClose>>', self.close_selected)
        self.tags_tree.bind('<Double-Button-1>', self.activate_item)
        self.tags_tree.bind('<Return>', self.activate_item)

        self.tags_tree_frame.pack(fill='both', side='left', expand=True)

        # pack in this order so scrollbars aren't shrunk when resizing
        self.scrollbar_y.pack(side='right', fill='y')
        self.tags_tree.pack(side='right', fill='both', expand=True)

        self.reload()
        self.apply_style()
Exemplo n.º 2
0
    def __init__(self, app_root, *args, **kwargs):
        BinillaWidget.__init__(self)
        self.app_root = app_root
        self.hover_start = time()

        # begin the looping
        app_root.after(int(self.schedule_rate), self.check_loop)
Exemplo n.º 3
0
 def enable(self):
     if not self.disabled:
         return
     BinillaWidget.set_disabled(self, False)
     self.config(bg=self.default_bg_color)
     self.sel_label.config(bg=self.enum_normal_color,
                           fg=self.text_normal_color)
     self.arrow_button.config(state='normal')
Exemplo n.º 4
0
 def disable(self):
     if self.disabled:
         return
     BinillaWidget.set_disabled(self, True)
     self.config(bg=self.enum_disabled_color)
     self.sel_label.config(bg=self.enum_disabled_color,
                           fg=self.text_disabled_color)
     self.arrow_button.config(state='disabled')
Exemplo n.º 5
0
 def __init__(self, *a, **kw):
     iconbitmap = kw.pop("iconbitmap", "")
     BinillaWidget.__init__(self, *a, **kw)
     TextViewer.__init__(self, *a)
     self.apply_style()
     if iconbitmap:
         try:
             self.iconbitmap(str(iconbitmap))
         except Exception:
             print("Could not load window icon.")
Exemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        self.active_map = kwargs.pop('active_map', None)
        BinillaWidget.__init__(self, *args, **kwargs)
        tk.Toplevel.__init__(self, *args, **kwargs)

        try:
            self.iconbitmap(e_c.REFINERY_ICON_PATH)
        except Exception:
            if not e_c.IS_LNX:
                print("Could not load window icon.")

        self.geometry("300x80")
        self.title("Change map checksum")
        self.resizable(0, 0)

        self.cs = tk.StringVar(self, 'Checksum functions unavailable')
        self.cs.trace("w", self.validate)

        # frames
        self.checksum_frame = tk.LabelFrame(self,
                                            text="Current random checksum")
        self.button_frame = tk.Frame(self)

        # rename
        self.checksum_entry = tk.Entry(self.checksum_frame,
                                       textvariable=self.cs,
                                       justify='center')

        self.apply_button = tk.Button(self.button_frame,
                                      text="Apply to current map",
                                      command=self.apply,
                                      width=20)

        # pack everything
        self.checksum_frame.pack(padx=4, expand=True, fill="x", pady=2)
        self.button_frame.pack(expand=True, fill="x")

        self.checksum_entry.pack(padx=4,
                                 pady=3,
                                 side='left',
                                 fill='x',
                                 expand=True)
        self.apply_button.pack(side='left', expand=True, padx=4)

        # make the window not show up on the start bar
        self.transient(self.master)

        if self.active_map:
            s = ""
            for c in "%08x" % self.active_map.map_header.crc32:
                s += c
                if len(s) % 3 == 2:
                    s += " "
            self.cs.set(s[:11])
        self.apply_style()
Exemplo n.º 7
0
    def __init__(self, app_root, *args, **kwargs):
        self.handler = app_root.get_handler("Halo 1 OS v4")
        self.app_root = app_root
        kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)
        tk.Toplevel.__init__(self, app_root, *args, **kwargs)
        BinillaWidget.__init__(self, app_root, *args, **kwargs)

        self.title("Scenario Open Sauce remover")
        self.geometry("400x80+0+0")
        self.resizable(0, 0)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        # make the tkinter variables
        self.scenario_path = tk.StringVar(self)

        # make the frames
        self.scenario_frame = tk.LabelFrame(
            self, text="Scenario to remove sauce from")
        self.button_frame = tk.Frame(self)

        self.begin_button = tk.Button(self.button_frame,
                                      text='Remove sauce',
                                      width=20,
                                      command=self.remove_sauce)
        self.begin_button.tooltip_string = "It's okay, I like buttered noodles too sometimes."

        self.scenario_entry = tk.Entry(self.scenario_frame,
                                       textvariable=self.scenario_path)
        self.scenario_browse_button = tk.Button(self.scenario_frame,
                                                text="Browse",
                                                command=self.scenario_browse)

        for w in (self.scenario_entry, ):
            w.pack(padx=(4, 0), pady=2, side='left', expand=True, fill='x')

        for w in (self.scenario_browse_button, ):
            w.pack(padx=(0, 4), pady=2, side='left')

        for w in (self.begin_button, ):
            w.pack(padx=4, pady=2, side='left')

        self.scenario_frame.pack(fill='x', padx=1)
        self.button_frame.pack(fill="y")

        self.transient(app_root)
        self.apply_style()
        self.update()
        w, h = self.winfo_reqwidth(), self.winfo_reqheight()
        self.geometry("%sx%s" % (w, h))
        self.minsize(width=w, height=h)
Exemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        self.active_map = kwargs.pop('active_map', None)
        BinillaWidget.__init__(self, *args, **kwargs)
        tk.Toplevel.__init__(self, *args, **kwargs)

        try:
            self.iconbitmap(e_c.REFINERY_ICON_PATH)
        except Exception:
            if not e_c.IS_LNX:
                print("Could not load window icon.")

        self.geometry("300x80")
        self.title("Rename map")
        self.resizable(0, 0)

        self.rename_string = tk.StringVar(self)
        if self.active_map:
            self.rename_string.set(self.active_map.map_header.map_name)

        # frames
        self.rename_frame = tk.LabelFrame(self, text="Rename to")

        self.button_frame = tk.Frame(self)
        self.button_frame_l = tk.Frame(self.button_frame)
        self.button_frame_r = tk.Frame(self.button_frame)

        # rename
        self.rename_entry = tk.Entry(self.rename_frame,
                                     textvariable=self.rename_string)

        # accept/cancel
        self.rename_button = tk.Button(self.button_frame_l,
                                       text="Rename",
                                       command=self.rename,
                                       width=10)
        self.cancel_button = tk.Button(self.button_frame_r,
                                       text="Cancel",
                                       command=self.destroy,
                                       width=10)

        # pack everything
        self.rename_frame.pack(padx=4, expand=True, fill="x", pady=2)
        self.button_frame.pack(pady=2, expand=True, fill="x")

        self.button_frame_l.pack(padx=4, side='left', fill='x', expand=True)
        self.button_frame_r.pack(padx=4, side='right', fill='x', expand=True)

        self.rename_entry.pack(padx=4, side='left', fill='x', expand=True)
        self.rename_button.pack(side='right')
        self.cancel_button.pack(side='left')

        # make the window not show up on the start bar
        self.transient(self.master)
        self.apply_style()
Exemplo n.º 9
0
    def __init__(self, master, tag=None, *args, **kwargs):
        self._pending_scroll_counts = [0, 0]
        self.tag = tag
        self.is_new_tag = kwargs.pop("is_new_tag", self.is_new_tag)

        if 'tag_def' in kwargs:
            self.tag_def = kwargs.pop('tag_def')
        elif self.tag is not None:
            self.tag_def = self.tag.definition

        if 'widget_picker' in kwargs:
            self.widget_picker = kwargs.pop('widget_picker')
        elif hasattr(self.app_root, 'widget_picker'):
            self.widget_picker = self.app_root.widget_picker

        self.app_root = kwargs.pop('app_root', master)
        self.handler = kwargs.pop('handler', None)

        kwargs.update(bg=self.default_bg_color)

        BinillaWidget.__init__(self)
        tk.Toplevel.__init__(self, master, *args, **kwargs)

        # do any initialization that requires this object
        # be initialized as a tk.Toplevel object
        self.post_toplevel_init()

        try:
            max_undos = self.app_root.max_undos
        except AttributeError:
            max_undos = 100

        try:
            use_def_dims = self.settings.window_flags.use_default_dimensions
        except AttributeError:
            use_def_dims = False

        self.edit_manager = EditManager(max_undos)

        with self.style_change_lock:
            self.update()
            if use_def_dims:
                width = self.settings.default_dimensions.w
                height = self.settings.default_dimensions.h
            else:
                width = self.root_frame.winfo_reqwidth(
                ) + self.root_vsb.winfo_reqwidth() + 2
                height = self.root_frame.winfo_reqheight(
                ) + self.root_hsb.winfo_reqheight() + 2

            self.resize_window(width, height)
            self.apply_style()

        self._initialized = True
Exemplo n.º 10
0
    def __init__(self, master, *args, **kwargs):
        kwargs.setdefault('app_root', master)
        self.app_root = kwargs.pop('app_root')

        kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)
        BinillaWidget.__init__(self)
        tk.Frame.__init__(self, master, *args, **kwargs)

        self.hierarchy_frame = HierarchyFrame(self, app_root=self.app_root)

        self.hierarchy_frame.pack(fill='both', expand=True)
        self.apply_style()
Exemplo n.º 11
0
    def apply_style(self, seen=None):
        BinillaWidget.apply_style(self, seen)
        if self.disabled:
            bg = self.entry_disabled_color
            fg = self.text_disabled_color
        else:
            bg = self.enum_normal_color
            fg = self.text_normal_color

        menu_width = self.menu_width if self.menu_width else self.scroll_menu_width
        self.sel_label.config(bg=bg,
                              fg=fg,
                              width=max(
                                  min(menu_width, self.scroll_menu_max_width),
                                  1))
        self.option_box.config(width=menu_width)
Exemplo n.º 12
0
    def __init__(self, master, *a, **kw):
        kw.update(highlightthickness=0)
        self.messages = kw.pop("messages", self.messages)
        self.app_name = kw.pop("app_name", self.app_name)
        self.module_infos = {name: None for name in kw.pop("module_names", ())}
        self.iconbitmap_filepath = str(
            kw.pop("iconbitmap", self.iconbitmap_filepath))
        self.appbitmap_filepath = str(
            kw.pop("appbitmap", self.appbitmap_filepath))

        tk.Toplevel.__init__(self, master, *a, **kw)
        BinillaWidget.__init__(self, *a, **kw)
        self.resizable(0, 0)
        self.title("About " + self.app_name)
        self.transient(master)

        self.messages = tuple(m.strip() for m in self.messages if m.strip())

        self.update()
        try:
            if os.path.isfile(self.iconbitmap_filepath):
                self.iconbitmap(self.iconbitmap_filepath)
        except Exception:
            print("Could not load window icon.")

        for name in self.module_infos:
            try:
                self.module_infos[name] = self.get_module_info(name)
            except Exception:
                print(format_exc())

        self.generate_widgets()

        self.bind('<Escape>', lambda e=None, s=self: s.destroy())
        self.apply_style()

        self.update()
        w, h = self.winfo_reqwidth(), self.winfo_reqheight()
        self.geometry("%sx%s" % (w, h))
        self.minsize(width=w, height=h)
Exemplo n.º 13
0
    def __init__(self, app_root, *args, **kwargs):
        self.handler = app_root.handler
        self.app_root = app_root
        kwargs.update(width=400,
                      height=500,
                      bd=0,
                      highlightthickness=0,
                      bg=self.default_bg_color)
        tk.Toplevel.__init__(self, app_root, *args, **kwargs)
        BinillaWidget.__init__(self, app_root, *args, **kwargs)
        self.title("[%s] Tag dependency viewer / zipper" %
                   app_root.handler_names[app_root._curr_handler_index])
        self.minsize(width=400, height=100)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        # make the tkinter variables
        self.tag_filepath = tk.StringVar(self)

        # make the frames
        self.filepath_frame = tk.LabelFrame(self, text="Select a tag")
        self.button_frame = tk.LabelFrame(self, text="Actions")

        self.display_button = tk.Button(self.button_frame,
                                        width=25,
                                        text='Show dependencies',
                                        command=self.populate_dependency_tree)

        self.zip_button = tk.Button(self.button_frame,
                                    width=25,
                                    text='Zip tag recursively',
                                    command=self.recursive_zip)

        self.dependency_frame = DependencyFrame(self, app_root=self.app_root)

        self.filepath_entry = tk.Entry(self.filepath_frame,
                                       textvariable=self.tag_filepath)
        self.browse_button = tk.Button(self.filepath_frame,
                                       text="Browse",
                                       command=self.browse)

        self.display_button.pack(padx=4, pady=2, side='left')
        self.zip_button.pack(padx=4, pady=2, side='right')

        self.filepath_entry.pack(padx=(4, 0),
                                 pady=2,
                                 side='left',
                                 expand=True,
                                 fill='x')
        self.browse_button.pack(padx=(0, 4), pady=2, side='left')

        self.filepath_frame.pack(fill='x', padx=1)
        self.button_frame.pack(fill='x', padx=1)
        self.dependency_frame.pack(fill='both', padx=1, expand=True)

        self.transient(app_root)
        self.apply_style()
        self.update()
        w, h = self.winfo_reqwidth(), self.winfo_reqheight()
        self.geometry("%sx%s" % (w, h))
        self.minsize(width=w, height=h)
Exemplo n.º 14
0
 def apply_style(self, seen=None):
     BinillaWidget.apply_style(self, seen)
     self.root_canvas.config(bg=self.default_bg_color)
     self.root_frame.config(bg=self.default_bg_color)
Exemplo n.º 15
0
    def __init__(self, app_root, *args, **kwargs):
        self.app_root = app_root
        BinillaWidget.__init__(self)
        tk.Toplevel.__init__(self, app_root, *args, **kwargs)

        self.list_index_to_window = []

        self.title("Tag window manager")
        self.minsize(width=400, height=250)

        # make the frames
        self.windows_frame = tk.Frame(self)
        self.button_frame = tk.Frame(self)
        self.ok_frame = tk.Frame(self.button_frame)
        self.cancel_frame = tk.Frame(self.button_frame)

        # make the buttons
        self.ok_button = tk.Button(self.ok_frame,
                                   text='OK',
                                   width=15,
                                   command=self.select)
        self.cancel_button = tk.Button(self.cancel_frame,
                                       text='Cancel',
                                       width=15,
                                       command=self.destroy)

        # make the scrollbars and listbox
        self.scrollbar_y = tk.Scrollbar(self.windows_frame, orient="vertical")
        self.scrollbar_x = tk.Scrollbar(self, orient="horizontal")
        self.windows_listbox = tk.Listbox(self.windows_frame,
                                          selectmode='single',
                                          exportselection=False,
                                          highlightthickness=0,
                                          xscrollcommand=self.scrollbar_x.set,
                                          yscrollcommand=self.scrollbar_y.set)

        # set up the scrollbars
        self.scrollbar_x.config(command=self.windows_listbox.xview)
        self.scrollbar_y.config(command=self.windows_listbox.yview)

        # set up the keybindings
        self.windows_listbox.bind('<Return>', self.select)
        self.scrollbar_x.bind('<Return>', self.select)
        self.scrollbar_y.bind('<Return>', self.select)
        self.windows_listbox.bind('<Double-Button-1>', self.select)
        self.ok_button.bind('<Return>', self.select)
        self.cancel_button.bind('<Return>', self.destroy)
        self.bind('<Escape>', self.destroy)

        # store the windows by title
        windows_by_title = {}
        for w in self.app_root.tag_windows.values():
            windows_by_title[w.title()] = w

        # populate the listbox
        for title in sorted(windows_by_title):
            self.list_index_to_window.append(windows_by_title[title])
            self.windows_listbox.insert('end', title)

        self.windows_listbox.select_set(0)

        # pack everything
        self.ok_button.pack(padx=12, pady=5, side='right')
        self.cancel_button.pack(padx=12, pady=5, side='left')
        self.ok_frame.pack(side='left', fill='x', expand=True)
        self.cancel_frame.pack(side='right', fill='x', expand=True)

        self.windows_listbox.pack(side='left', fill="both", expand=True)
        self.scrollbar_y.pack(side='left', fill="y")

        self.windows_frame.pack(fill="both", expand=True)
        self.scrollbar_x.pack(fill="x")
        self.button_frame.pack(fill="x")

        self.apply_style()
        self.transient(self.app_root)
        self.ok_button.focus_set()
        self.wait_visibility()
        self.lift()
        self.grab_set()
Exemplo n.º 16
0
    def __init__(self, app_root, *args, **kwargs):
        self.handler = app_root.handler
        self.app_root = app_root
        kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)
        tk.Toplevel.__init__(self, app_root, *args, **kwargs)
        BinillaWidget.__init__(self, app_root, *args, **kwargs)

        self.tag_data_extractors = getattr(self.handler, "tag_data_extractors",
                                           None)
        self.tag_class_fcc_to_ext = {
            k: self.handler.id_ext_map[k].strip(".")
            for k in self.handler.id_ext_map
        }
        self.tag_class_ext_to_fcc = {
            self.tag_class_fcc_to_ext[k]: k
            for k in self.tag_class_fcc_to_ext
        }

        self.title("Tag Data Extractor")
        self.resizable(0, 0)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        self.listbox_index_to_def_id = list(
            sorted(k for k in self.tag_data_extractors.keys()
                   if k in self.tag_class_fcc_to_ext))

        # make the tkinter variables
        self.dir_path = tk.StringVar(self, self.handler.tagsdir)
        self.tag_path = tk.StringVar(self)
        self.overwrite = tk.BooleanVar(self)
        self.decode_adpcm = tk.BooleanVar(self)
        self.use_scenario_names_in_scripts = tk.BooleanVar(self)

        # make the frames
        self.options_frame = tk.LabelFrame(self, text="Extraction options")
        self.dir_extract_frame = tk.LabelFrame(
            self, text="Directory to extract from")
        self.dir_path_frame = tk.Frame(self.dir_extract_frame)
        self.def_ids_frame = tk.LabelFrame(
            self.dir_extract_frame,
            text="Select which tag types to extract from")
        self.tag_path_frame = tk.LabelFrame(self, text="Tag to extract from")

        self.def_ids_scrollbar = tk.Scrollbar(self.def_ids_frame,
                                              orient="vertical")
        self.def_ids_listbox = tk.Listbox(
            self.def_ids_frame,
            selectmode='multiple',
            highlightthickness=0,
            yscrollcommand=self.def_ids_scrollbar.set,
            exportselection=False)
        self.def_ids_scrollbar.config(command=self.def_ids_listbox.yview)

        for def_id in self.listbox_index_to_def_id:
            try:
                tag_ext = self.handler.id_ext_map[def_id].split('.')[-1]
            except KeyError:
                # not available with the current tag set
                continue
            self.def_ids_listbox.insert('end', tag_ext)
            self.def_ids_listbox.select_set('end')

        self.overwrite_cbtn = tk.Checkbutton(
            self.options_frame,
            variable=self.overwrite,
            text="Overwrite existing data files")
        self.decode_adpcm_cbtn = tk.Checkbutton(self.options_frame,
                                                variable=self.decode_adpcm,
                                                text="Decode Xbox ADPCM audio")
        self.use_scenario_names_in_scripts_cbtn = tk.Checkbutton(
            self.options_frame,
            variable=self.use_scenario_names_in_scripts,
            text="Use scenario names in scripts")

        self.dir_path_entry = tk.Entry(self.dir_path_frame,
                                       textvariable=self.dir_path)
        self.dir_browse_button = tk.Button(self.dir_path_frame,
                                           text="Browse",
                                           command=self.dir_browse)
        self.dir_extract_button = tk.Button(self.dir_path_frame,
                                            text="Extract",
                                            command=self.dir_extract)

        self.tag_path_entry = tk.Entry(self.tag_path_frame,
                                       textvariable=self.tag_path)
        self.tag_browse_button = tk.Button(self.tag_path_frame,
                                           text="Browse",
                                           command=self.tag_browse)
        self.tag_extract_button = tk.Button(self.tag_path_frame,
                                            text="Extract",
                                            command=self.tag_extract)

        self.cancel_extraction_button = tk.Button(
            self, text="Cancel extraction", command=self.cancel_extraction)

        self.overwrite_cbtn.pack(fill="x", anchor="nw", side="left")
        self.decode_adpcm_cbtn.pack(fill="x", anchor="nw")
        self.use_scenario_names_in_scripts_cbtn.pack(fill="x",
                                                     anchor="nw",
                                                     side="left")

        self.def_ids_listbox.pack(side='left', fill="both", expand=True)
        self.def_ids_scrollbar.pack(side='left', fill="y")

        self.dir_path_entry.pack(padx=(4, 0),
                                 pady=2,
                                 side='left',
                                 expand=True,
                                 fill='x')
        self.dir_browse_button.pack(padx=(0, 4), pady=2, side='left')
        self.dir_extract_button.pack(padx=(0, 4), pady=2, side='left')

        self.tag_path_entry.pack(padx=(4, 0),
                                 pady=2,
                                 side='left',
                                 expand=True,
                                 fill='x')
        self.tag_browse_button.pack(padx=(0, 4), pady=2, side='left')
        self.tag_extract_button.pack(padx=(0, 4), pady=2, side='left')

        self.dir_path_frame.pack(fill='x', padx=1)
        self.def_ids_frame.pack(fill='x', padx=1, expand=True)

        self.options_frame.pack(fill='x', padx=1)
        self.dir_extract_frame.pack(fill='x', padx=1)
        self.tag_path_frame.pack(fill='x', padx=1)
        self.cancel_extraction_button.pack(fill='both', padx=1, expand=True)

        self.transient(app_root)
        self.apply_style()
        self.update()
        w, h = self.winfo_reqwidth(), self.winfo_reqheight()
        self.geometry("%sx%s" % (w, h))
        self.minsize(width=w, height=h)
Exemplo n.º 17
0
    def __init__(self, app_root, action, *args, **kwargs):
        self.app_root = app_root
        try:
            title = app_root.handler.defs_filepath
        except AttributeError:
            title = "Tag definitions"

        title = "%s (%s total)" % (kwargs.pop(
            'title', title), len(self.app_root.handler.defs))

        BinillaWidget.__init__(self)
        tk.Toplevel.__init__(self, app_root, *args, **kwargs)
        self.title(title)

        self.action = action
        self.def_id = None
        self.sorted_def_ids = []
        self.minsize(width=400, height=300)

        self.list_canvas = tk.Canvas(self, highlightthickness=0)
        self.button_canvas = tk.Canvas(self, height=50, highlightthickness=0)

        #create and set the y scrollbar for the canvas root
        self.def_listbox = tk.Listbox(self.list_canvas,
                                      selectmode='single',
                                      exportselection=False,
                                      highlightthickness=0,
                                      font=self.get_font("fixed"))
        self.def_listbox.font_type = "fixed"

        self.ok_btn = tk.Button(self.button_canvas,
                                text='OK',
                                command=self.complete_action,
                                width=16)
        self.cancel_btn = tk.Button(self.button_canvas,
                                    text='Cancel',
                                    command=self.destroy,
                                    width=16)
        self.hsb = tk.Scrollbar(self.button_canvas, orient='horizontal')
        self.vsb = tk.Scrollbar(self.list_canvas, orient='vertical')

        self.def_listbox.config(xscrollcommand=self.hsb.set,
                                yscrollcommand=self.vsb.set)

        self.hsb.config(command=self.def_listbox.xview)
        self.vsb.config(command=self.def_listbox.yview)

        self.list_canvas.pack(fill='both', expand=True)
        self.button_canvas.pack(fill='x')

        self.vsb.pack(side='right', fill='y')
        self.def_listbox.pack(fill='both', expand=True)

        self.hsb.pack(side='top', fill='x')
        self.ok_btn.pack(side='left', padx=9)
        self.cancel_btn.pack(side='right', padx=9)

        # make selecting things more natural
        self.def_listbox.bind('<<ListboxSelect>>', self.set_selected_def)
        self.def_listbox.bind('<Return>', self.complete_action)
        self.def_listbox.bind('<Double-Button-1>', self.complete_action)
        self.ok_btn.bind('<Return>', self.complete_action)
        self.cancel_btn.bind('<Return>', self.destroy)
        self.bind('<Escape>', self.destroy)

        self.transient(self.app_root)
        self.wait_visibility()
        self.lift()
        self.grab_set()

        self.apply_style()
        self.cancel_btn.focus_set()
        self.populate_listbox()
    def __init__(self, app_root, *args, **kwargs):
        if window_base_class == tk.Toplevel:
            kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)
            self.app_root = app_root
        else:
            self.app_root = self

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

        self.title("Model_animations compiler")
        self.resizable(1, 1)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        tags_dir = getattr(app_root, "tags_dir", "")

        self.tags_dir = tk.StringVar(self, tags_dir if tags_dir else "")
        self.jma_dir = tk.StringVar(self)
        self.model_animations_path = tk.StringVar(self)

        self.animation_count_limit = tk.IntVar(self, 256)
        self.calculate_limp_limb_vectors = tk.IntVar(self, 0)
        self.update_mode = tk.IntVar(self, ANIMATION_COMPILE_MODE_PRESERVE)
        self.animation_delta_tolerance_string = tk.StringVar(
            self, str(self.animation_delta_tolerance))
        self.animation_delta_tolerance_string.trace(
            "w", lambda *a, s=self: s.set_animation_delta_tolerance())

        # make the frames
        self.main_frame = tk.Frame(self)
        self.jma_info_frame = tk.LabelFrame(self, text="Animations info")

        self.dirs_frame = tk.LabelFrame(self.main_frame, text="Directories")
        self.buttons_frame = tk.Frame(self.main_frame)
        self.settings_frame = tk.Frame(self.main_frame)

        self.jma_dir_frame = tk.LabelFrame(self.dirs_frame,
                                           text="Source animations folder")
        self.tags_dir_frame = tk.LabelFrame(self.dirs_frame,
                                            text="Tags directory root folder")
        self.model_animations_path_frame = tk.LabelFrame(
            self.dirs_frame, text="Model_animations output path")

        self.animation_delta_tolerance_frame = tk.LabelFrame(
            self.settings_frame, text="Animation delta tolerance")
        self.update_mode_frame = tk.LabelFrame(
            self.settings_frame,
            text="What to do with existing model_animations tag")

        self.compile_mode_replace_rbtn = tk.Radiobutton(
            self.update_mode_frame,
            anchor="w",
            variable=self.update_mode,
            value=ANIMATION_COMPILE_MODE_NEW,
            text="Erase all animations/tag values")
        self.compile_mode_preserve_rbtn = tk.Radiobutton(
            self.update_mode_frame,
            anchor="w",
            variable=self.update_mode,
            value=ANIMATION_COMPILE_MODE_PRESERVE,
            text="Preserve any used animations/tag values")
        self.compile_mode_additive_rbtn = tk.Radiobutton(
            self.update_mode_frame,
            anchor="w",
            variable=self.update_mode,
            value=ANIMATION_COMPILE_MODE_ADDITIVE,
            text="Erase nothing(only add/update animations and values)")

        self.animation_delta_tolerance_info = tk.Label(
            self.animation_delta_tolerance_frame,
            justify='left',
            anchor="w",
            text=("How much a nodes position, rotation, or scale\n"
                  "must change from the starting frame for that\n"
                  "type of transform to be considered animated."))
        self.animation_delta_tolerance_spinbox = tk.Spinbox(
            self.animation_delta_tolerance_frame,
            from_=0,
            to=100,
            width=25,
            increment=self.animation_delta_tolerance,
            textvariable=self.animation_delta_tolerance_string,
            justify="right")

        self.use_os_animation_count_limit_cbtn = tk.Checkbutton(
            self.settings_frame,
            onvalue=2048,
            offvalue=256,
            variable=self.animation_count_limit,
            anchor="w",
            text="Use Open Sauce animation count limit")
        self.calculate_limp_limb_vectors_cbtn = tk.Checkbutton(
            self.settings_frame,
            variable=self.calculate_limp_limb_vectors,
            text=("Calculate biped limp body node vectors\n"
                  "(requires matching gbxmodel)"),
            anchor="w")

        self.jma_info_tree = tk.ttk.Treeview(self.jma_info_frame,
                                             selectmode='browse',
                                             padding=(0, 0),
                                             height=4)
        self.jma_info_vsb = tk.Scrollbar(self.jma_info_frame,
                                         orient='vertical',
                                         command=self.jma_info_tree.yview)
        self.jma_info_hsb = tk.Scrollbar(self.jma_info_frame,
                                         orient='horizontal',
                                         command=self.jma_info_tree.xview)
        self.jma_info_tree.config(yscrollcommand=self.jma_info_vsb.set,
                                  xscrollcommand=self.jma_info_hsb.set)

        self.jma_dir_entry = tk.Entry(self.jma_dir_frame,
                                      textvariable=self.jma_dir,
                                      state=tk.DISABLED)
        self.jma_dir_browse_button = tk.Button(self.jma_dir_frame,
                                               text="Browse",
                                               command=self.jma_dir_browse)

        self.tags_dir_entry = tk.Entry(self.tags_dir_frame,
                                       textvariable=self.tags_dir,
                                       state=tk.DISABLED)
        self.tags_dir_browse_button = tk.Button(self.tags_dir_frame,
                                                text="Browse",
                                                command=self.tags_dir_browse)

        self.model_animations_path_entry = tk.Entry(
            self.model_animations_path_frame,
            textvariable=self.model_animations_path,
            state=tk.DISABLED)
        self.model_animations_path_browse_button = tk.Button(
            self.model_animations_path_frame,
            text="Browse",
            command=self.model_animations_path_browse)

        self.load_button = tk.Button(self.buttons_frame,
                                     text="Load\nanimations",
                                     command=self.load_animations)
        self.save_button = tk.Button(self.buttons_frame,
                                     text="Save as JMA",
                                     command=self.save_animations)
        self.compile_button = tk.Button(self.buttons_frame,
                                        text="Compile\nmodel_animations",
                                        command=self.compile_model_animations)

        self.populate_animations_info_tree()

        # pack everything
        self.main_frame.pack(fill="both", side='left', pady=3, padx=3)
        self.jma_info_frame.pack(fill="both",
                                 side='left',
                                 pady=3,
                                 padx=3,
                                 expand=True)

        self.dirs_frame.pack(fill="x")
        self.buttons_frame.pack(fill="x", pady=3, padx=3)
        self.settings_frame.pack(fill="both")

        self.jma_dir_frame.pack(fill='x')
        self.tags_dir_frame.pack(fill='x')
        self.model_animations_path_frame.pack(fill='x')

        self.jma_dir_entry.pack(side='left', fill='x', expand=True)
        self.jma_dir_browse_button.pack(side='left')

        self.model_animations_path_entry.pack(side='left',
                                              fill='x',
                                              expand=True)
        self.model_animations_path_browse_button.pack(side='left')

        self.tags_dir_entry.pack(side='left', fill='x', expand=True)
        self.tags_dir_browse_button.pack(side='left')

        self.jma_info_hsb.pack(side="bottom", fill='x')
        self.jma_info_vsb.pack(side="right", fill='y')
        self.jma_info_tree.pack(side='left', fill='both', expand=True)

        self.load_button.pack(side='left', fill='both', padx=3, expand=True)
        self.save_button.pack(side='left', fill='both', padx=3, expand=True)
        self.compile_button.pack(side='right',
                                 fill='both',
                                 padx=3,
                                 expand=True)

        for w in (self.update_mode_frame,
                  self.animation_delta_tolerance_frame):
            w.pack(expand=True, fill='both')

        for w in (
                self.compile_mode_replace_rbtn,
                self.compile_mode_preserve_rbtn,
                self.compile_mode_additive_rbtn,
        ):
            w.pack(expand=True, fill='both')

        self.animation_delta_tolerance_info.pack(fill='both',
                                                 expand=True,
                                                 padx=5,
                                                 pady=5)
        self.animation_delta_tolerance_spinbox.pack(padx=5, pady=5, anchor="w")

        self.use_os_animation_count_limit_cbtn.pack(expand=True, fill='both')
        # TODO: Uncomment this once this works
        #self.calculate_limp_limb_vectors_cbtn.pack(expand=True, fill='both')

        self.apply_style()
        if self.app_root is not self:
            self.transient(self.app_root)
 def apply_style(self, seen=None):
     BinillaWidget.apply_style(self, seen)
     self.update()
     w, h = self.winfo_reqwidth(), self.winfo_reqheight()
     self.geometry("%sx%s" % (w, h))
     self.minsize(width=w, height=h)
    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()
Exemplo n.º 21
0
    def __init__(self, app_root, *args, **kwargs):
        if window_base_class == tk.Toplevel:
            kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)
            self.app_root = app_root
        else:
            self.app_root = self

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

        self.title("Sound compiler")
        self.resizable(1, 1)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        self.wav_dir = tk.StringVar(self)
        self.sound_path = tk.StringVar(self)

        self.generate_mouth_data = tk.IntVar(self, 0)
        self.split_into_smaller_chunks = tk.IntVar(self, 1)

        self.compression = tk.IntVar(self, constants.COMPRESSION_PCM_16_LE)
        self.sample_rate = tk.IntVar(self, constants.SAMPLE_RATE_22K)
        self.encoding = tk.IntVar(self, constants.ENCODING_MONO)
        self.update_mode = tk.IntVar(self, constants.SOUND_COMPILE_MODE_PRESERVE)

        self.adpcm_lookahead = tk.IntVar(self, 3)
        self.adpcm_noise_shaping = tk.IntVar(self, adpcm.NOISE_SHAPING_OFF)

        self.chunk_size_string = tk.StringVar(self, str(self.chunk_size))
        self.chunk_size_string.trace(
            "w", lambda *a, s=self: s.set_chunk_size())

        # make the frames
        self.main_frame = tk.Frame(self)
        self.wav_info_frame = tk.LabelFrame(
            self, text="Import info")

        self.dirs_frame = tk.LabelFrame(
            self.main_frame, text="Directories")
        self.buttons_frame = tk.Frame(self.main_frame)
        self.settings_frame = tk.Frame(
            self.main_frame)

        self.wav_dir_frame = tk.LabelFrame(
            self.dirs_frame, text="Wav files folder")
        self.sound_path_frame = tk.LabelFrame(
            self.dirs_frame, text="Sound output path")

        self.update_mode_frame = tk.LabelFrame(
            self.main_frame, text="What to do with existing sound tag")
        self.processing_frame = tk.LabelFrame(
            self.settings_frame, text="Format settings")
        self.adpcm_frame = tk.LabelFrame(
            self.settings_frame, text="ADPCM settings")
        self.misc_frame = tk.LabelFrame(
            self.settings_frame, text="Misc settings")


        self.compile_mode_replace_rbtn = tk.Radiobutton(
            self.update_mode_frame, anchor="w",
            variable=self.update_mode, value=constants.SOUND_COMPILE_MODE_NEW,
            text="Erase everything(create from scratch)")
        self.compile_mode_preserve_rbtn = tk.Radiobutton(
            self.update_mode_frame, anchor="w",
            variable=self.update_mode, value=constants.SOUND_COMPILE_MODE_PRESERVE,
            text="Preserve tag values(skip fractions and such)")
        self.compile_mode_additive_rbtn = tk.Radiobutton(
            self.update_mode_frame, anchor="w",
            variable=self.update_mode, value=constants.SOUND_COMPILE_MODE_ADDITIVE,
            text="Erase nothing(only add/update permutations)")


        self.compression_menu = ScrollMenu(
            self.processing_frame,  variable=self.compression, menu_width=10,
            options=tuple(
                compression_names[const] for const in compression_menu_values
                )
            )
        self.sample_rate_menu = ScrollMenu(
            self.processing_frame, variable=self.sample_rate, menu_width=5,
            options=tuple(
                sample_rate_names[const] for const in sample_rate_menu_values
                )
            )
        self.encoding_menu = ScrollMenu(
            self.processing_frame, variable=self.encoding, menu_width=5,
            options=tuple(
                encoding_names[const] for const in encoding_menu_values
                )
            )

        self.adpcm_lookahead_label = tk.Label(
            self.adpcm_frame, text="Lookahead prediction �")
        self.adpcm_lookahead_menu = ScrollMenu(
            self.adpcm_frame, variable=self.adpcm_lookahead,
            menu_width=17, options=adpcm_lookahead_names
            )
        self.adpcm_noise_shaping_label = tk.Label(
            self.adpcm_frame, text="Noise shaping �")
        self.adpcm_noise_shaping_menu = ScrollMenu(
            self.adpcm_frame, variable=self.adpcm_noise_shaping,
            menu_width=17, options=adpcm_noise_shaping_names
            )
        self.adpcm_lookahead_label.tooltip_string = self.adpcm_lookahead_menu.tooltip_string = (
            "Number of samples to look ahead when determining minimum\n"
            "ADPCM error. Higher numbers are typically better."
            )
        self.adpcm_noise_shaping_label.tooltip_string = self.adpcm_noise_shaping_menu.tooltip_string = (
            "The type of noise shaping algorithm to apply to the sound.\n"
            "Noise shaping is a form of dithering, but for audio.\n"
            "Results will vary, so always test after turning this on."
            )

        self.compression_menu.sel_index = 0
        self.sample_rate_menu.sel_index = 0
        self.encoding_menu.sel_index = 0

        self.generate_mouth_data_cbtn = tk.Checkbutton(
            self.misc_frame, variable=self.generate_mouth_data,
            anchor="w", text="Generate mouth data �")
        self.split_into_smaller_chunks_cbtn = tk.Checkbutton(
            self.misc_frame, variable=self.split_into_smaller_chunks,
            anchor="w", text="Split into chunks �")
        self.chunk_size_label = tk.Label(
            self.misc_frame, text="Chunk size �")
        self.chunk_size_spinbox = tk.Spinbox(
            self.misc_frame, from_=self.min_chunk_size,
            to=self.max_chunk_size, increment=1024*4,
            textvariable=self.chunk_size_string, justify="right")

        self.generate_mouth_data_cbtn.tooltip_string = (
            "Whether or not to generate mouth data for this sound.\n"
            "Mouth data animates a characters mouth to the sound."
            )
        self.split_into_smaller_chunks_cbtn.tooltip_string = (
            "Whether or not to split long sounds into pieces.\n"
            "Long sounds may not play properly ingame, and this\n"
            "setting is recommended if the sound is over a few seconds."
            )
        self.chunk_size_label.tooltip_string = self.chunk_size_spinbox.tooltip_string = (
            'The number of samples per chunk to split long sounds into.\n'
            'NOTE 1:\tThis is for mono. A value of 2 equals 1 stereo sample.\n'
            'NOTE 2:\tThis will be rounded down to a multiple of 64 for ADPCM.'
            )


        self._pr_info_tree = tk.ttk.Treeview(
            self.wav_info_frame, selectmode='browse', padding=(0, 0), height=4)
        self.wav_info_vsb = tk.Scrollbar(
            self.wav_info_frame, orient='vertical',
            command=self._pr_info_tree.yview)
        self.wav_info_hsb = tk.Scrollbar(
            self.wav_info_frame, orient='horizontal',
            command=self._pr_info_tree.xview)
        self._pr_info_tree.config(yscrollcommand=self.wav_info_vsb.set,
                                  xscrollcommand=self.wav_info_hsb.set)

        self.wav_dir_entry = tk.Entry(
            self.wav_dir_frame, textvariable=self.wav_dir, state=tk.DISABLED)
        self.wav_dir_browse_button = tk.Button(
            self.wav_dir_frame, text="Browse", command=self.wav_dir_browse)


        self.sound_path_entry = tk.Entry(
            self.sound_path_frame,
            textvariable=self.sound_path,
            state=tk.DISABLED)
        self.sound_path_browse_button = tk.Button(
            self.sound_path_frame, text="Browse",
            command=self.sound_path_browse)


        self.load_button = tk.Button(
            self.buttons_frame, text="Load wav files",
            command=self.load_wav_files)
        self.compile_button = tk.Button(
            self.buttons_frame, text="Compile sound",
            command=self.compile_sound)

        self.populate_wav_info_tree()

        # pack everything
        self.main_frame.pack(fill="both", side='left', pady=3, padx=3)
        self.wav_info_frame.pack(fill="both", side='left', pady=3, padx=3,
                                 expand=True)

        self.dirs_frame.pack(fill="x")
        self.buttons_frame.pack(fill="x", pady=3, padx=3)
        self.update_mode_frame.pack(fill='both')
        self.settings_frame.pack(fill="both")

        self.wav_dir_frame.pack(fill='x')
        self.sound_path_frame.pack(fill='x')

        self.wav_dir_entry.pack(side='left', fill='x', expand=True)
        self.wav_dir_browse_button.pack(side='left')

        self.sound_path_entry.pack(side='left', fill='x', expand=True)
        self.sound_path_browse_button.pack(side='left')

        self.wav_info_hsb.pack(side="bottom", fill='x')
        self.wav_info_vsb.pack(side="right",  fill='y')
        self._pr_info_tree.pack(side='left', fill='both', expand=True)

        self.load_button.pack(side='left', fill='both', padx=3, expand=True)
        self.compile_button.pack(side='right', fill='both', padx=3, expand=True)

        for w in (self.processing_frame, self.adpcm_frame, self.misc_frame):
            w.pack(expand=True, fill='both')

        for w in (self.compile_mode_replace_rbtn,
                  self.compile_mode_preserve_rbtn,
                  self.compile_mode_additive_rbtn,):
            w.pack(expand=True, fill='both')

        for w in (self.compression_menu,
                  self.sample_rate_menu,
                  self.encoding_menu):
            w.pack(expand=True, side='left', fill='both')

        i = 0
        for w, lbl in (
                (self.adpcm_lookahead_menu, self.adpcm_lookahead_label),
                (self.adpcm_noise_shaping_menu, self.adpcm_noise_shaping_label)
                ):
            lbl.grid(row=i, column=0, sticky="w", padx=(17, 0))
            w.grid(row=i, column=2, sticky="news", padx=(10, 0))
            i += 1


        self.generate_mouth_data_cbtn.grid(
            row=0, column=0, sticky="news", padx=(17, 0))
        self.split_into_smaller_chunks_cbtn.grid(
            row=0, column=1, sticky="news", padx=(17, 0))
        self.chunk_size_label.grid(
            row=1, column=0, sticky="w", padx=(17, 0))
        self.chunk_size_spinbox.grid(
            row=1, column=1, sticky="news", padx=(10, 10))

        self.apply_style()
        if self.app_root is not self:
            self.transient(self.app_root)
Exemplo n.º 22
0
    def __init__(self, master, *args, **kwargs):
        BinillaWidget.__init__(self)
        self.temp_root = kwargs.pop('temp_root', self.temp_root)
        textures = kwargs.pop('textures', ())
        app_root = kwargs.pop('app_root', ())

        self.image_canvas_ids = []
        self.textures = []
        self._image_handlers = {}

        temp_name = str(int(random.random() * (1 << 32)))
        self.temp_dir = os.path.join(self.temp_root, temp_name)

        kwargs.update(relief='flat',
                      bd=self.frame_depth,
                      bg=self.default_bg_color)
        tk.Frame.__init__(self, master, *args, **kwargs)

        self.bitmap_index = tk.IntVar(self)
        self.mipmap_index = tk.IntVar(self)
        self.depth_index = tk.IntVar(self)
        self.channel_index = tk.IntVar(self)
        self.cube_display_index = tk.IntVar(self)
        self.root_canvas = tk.Canvas(self, highlightthickness=0)
        self.root_frame = tk.Frame(self.root_canvas, highlightthickness=0)

        # create the root_canvas and the root_frame within the canvas
        self.controls_frame0 = tk.Frame(self.root_frame, highlightthickness=0)
        self.controls_frame1 = tk.Frame(self.root_frame, highlightthickness=0)
        self.controls_frame2 = tk.Frame(self.root_frame, highlightthickness=0)
        self.image_root_frame = tk.Frame(self.root_frame, highlightthickness=0)
        self.image_canvas = tk.Canvas(self.image_root_frame,
                                      highlightthickness=0,
                                      bg=self.bitmap_canvas_bg_color)
        self.depth_canvas = tk.Canvas(self.image_canvas,
                                      highlightthickness=0,
                                      bg=self.bitmap_canvas_bg_color)

        self.bitmap_menu = ScrollMenu(self.controls_frame0,
                                      menu_width=7,
                                      variable=self.bitmap_index,
                                      can_scroll=True)
        self.mipmap_menu = ScrollMenu(self.controls_frame1,
                                      menu_width=7,
                                      variable=self.mipmap_index,
                                      can_scroll=True)
        self.depth_menu = ScrollMenu(self.controls_frame2,
                                     menu_width=7,
                                     variable=self.depth_index,
                                     can_scroll=True)
        self.channel_menu = ScrollMenu(self.controls_frame0,
                                       menu_width=9,
                                       variable=self.channel_index,
                                       can_scroll=True)
        self.cube_display_menu = ScrollMenu(self.controls_frame1,
                                            menu_width=9,
                                            variable=self.cube_display_index,
                                            options=("cross", "linear"),
                                            can_scroll=True)

        self.save_button = ttk.Button(self.controls_frame2,
                                      width=11,
                                      text="Browse",
                                      command=self.save_as)
        self.depth_menu.default_text = self.mipmap_menu.default_text =\
                                       self.bitmap_menu.default_text =\
                                       self.channel_menu.default_text =\
                                       self.cube_display_menu.default_text = ""

        labels = []
        labels.append(tk.Label(self.controls_frame0, text="Bitmap index"))
        labels.append(tk.Label(self.controls_frame1, text="Mipmap level"))
        labels.append(tk.Label(self.controls_frame2, text="Depth level"))
        labels.append(tk.Label(self.controls_frame0, text="Channels"))
        labels.append(tk.Label(self.controls_frame1, text="Cubemap display"))
        labels.append(tk.Label(self.controls_frame2, text="Save to file"))
        for lbl in labels:
            lbl.config(width=15,
                       anchor='w',
                       bg=self.default_bg_color,
                       fg=self.text_normal_color,
                       disabledforeground=self.text_disabled_color)

        self.hsb = tk.Scrollbar(self,
                                orient="horizontal",
                                command=self.root_canvas.xview)
        self.vsb = tk.Scrollbar(self,
                                orient="vertical",
                                command=self.root_canvas.yview)
        self.root_canvas.config(xscrollcommand=self.hsb.set,
                                xscrollincrement=1,
                                yscrollcommand=self.vsb.set,
                                yscrollincrement=1)
        for w in [
                self.root_frame, self.root_canvas, self.image_canvas,
                self.controls_frame0, self.controls_frame1,
                self.controls_frame2
        ] + labels:
            if e_c.IS_LNX:
                w.bind('<Shift-4>', self.mousewheel_scroll_x)
                w.bind('<Shift-5>', self.mousewheel_scroll_x)
                w.bind('<4>', self.mousewheel_scroll_y)
                w.bind('<5>', self.mousewheel_scroll_y)
            else:
                w.bind('<Shift-MouseWheel>', self.mousewheel_scroll_x)
                w.bind('<MouseWheel>', self.mousewheel_scroll_y)

        # pack everything
        # pack in this order so scrollbars aren't shrunk
        self.root_frame_id = self.root_canvas.create_window(
            (0, 0), anchor="nw", window=self.root_frame)
        self.hsb.pack(side='bottom', fill='x', anchor='nw')
        self.vsb.pack(side='right', fill='y', anchor='nw')
        self.root_canvas.pack(fill='both', anchor='nw', expand=True)
        self.controls_frame0.pack(side='top', fill='x', anchor='nw')
        self.controls_frame1.pack(side='top', fill='x', anchor='nw')
        self.controls_frame2.pack(side='top', fill='x', anchor='nw')
        self.image_root_frame.pack(fill='both', anchor='nw', expand=True)
        self.image_canvas.pack(fill='both',
                               side='right',
                               anchor='nw',
                               expand=True)

        padx = self.horizontal_padx
        pady = self.horizontal_pady
        for lbl in labels[:3]:
            lbl.pack(side='left', padx=(25, 0), pady=pady)
        self.bitmap_menu.pack(side='left', padx=padx, pady=pady)
        self.mipmap_menu.pack(side='left', padx=padx, pady=pady)
        self.depth_menu.pack(side='left', padx=padx, pady=pady)
        for lbl in labels[3:]:
            lbl.pack(side='left', padx=(15, 0), pady=pady)
        self.save_button.pack(side='left', padx=padx, pady=pady)
        self.channel_menu.pack(side='left', padx=padx, pady=pady)
        self.cube_display_menu.pack(side='left', padx=padx, pady=pady)

        self.change_textures(textures)

        self.write_trace(self.bitmap_index, self.settings_changed)
        self.write_trace(self.mipmap_index, self.settings_changed)
        self.write_trace(self.depth_index, self.settings_changed)
        self.write_trace(self.cube_display_index, self.settings_changed)
        self.write_trace(self.channel_index, self.settings_changed)

        self.apply_style()
Exemplo n.º 23
0
    def __init__(self, *args, **kwargs):
        title = kwargs.pop('title', None)
        self.renamable = kwargs.pop('renamable', self.renamable)
        self.settings = settings = kwargs.pop('settings', {})
        self.tag_index_ref = kwargs.pop('tag_index_ref', self.tag_index_ref)
        # Zatarita, added propagatable kwarg for displaying checkbox
        self.propagatable = kwargs.pop('propagatable', self.propagatable)
        BinillaWidget.__init__(self, *args, **kwargs)
        tk.Toplevel.__init__(self, *args, **kwargs)

        try:
            self.iconbitmap(e_c.REFINERY_ICON_PATH)
        except Exception:
            if not e_c.IS_LNX:
                print("Could not load window icon.")

        self.bind('<Escape>', lambda e=None, s=self, *a, **kw: s.destroy())

        if self.app_root is None and hasattr(self.master, 'app_root'):
            self.app_root = self.master.app_root

        self.accept_rename = settings.get('accept_rename', tk.IntVar(self))
        self.accept_settings = settings.get('accept_settings', tk.IntVar(self))
        self.rename_string = settings.get('rename_string', tk.StringVar(self))
        self.newtype_string = settings.get('newtype_string',
                                           tk.StringVar(self))
        self.extract_to_dir = settings.get('out_dir', tk.StringVar(self))
        self.tagslist_path = settings.get('tagslist_path', tk.StringVar(self))
        self.extract_mode = settings.get('extract_mode', tk.StringVar(self))
        self.recursive_rename = tk.IntVar(self)
        self.resizable(1, 0)

        if title is None:
            title = self.rename_string.get()
            if not title:
                title = "Options"
        self.title(title)

        self.original_name = PureWindowsPath(self.rename_string.get())
        if self.tag_index_ref is not None:
            # this ActionsWindow is displaying a single tag. the
            # original name will have an extension. remove it
            self.original_name = self.original_name.with_suffix("")

        self.rename_string.set(str(self.original_name))
        self.newtype_string.set("")

        self.accept_rename.set(0)
        self.accept_settings.set(0)

        # frames
        self.rename_frame = tk.LabelFrame(self, text="Rename to")
        self.rename_frame_inner0 = tk.Frame(self.rename_frame)
        self.rename_frame_inner1 = tk.Frame(self.rename_frame)
        self.tags_list_frame = tk.LabelFrame(
            self, text="Tags list log(erase to disable logging)")
        self.extract_to_frame = tk.LabelFrame(self,
                                              text="Directory to extract to")
        self.settings_frame = tk.LabelFrame(self, text="Extract settings")

        self.button_frame = tk.Frame(self)
        self.accept_frame = tk.Frame(self.button_frame)
        self.cancel_frame = tk.Frame(self.button_frame)

        # rename
        self.rename_entry = tk.Entry(self.rename_frame_inner0,
                                     width=50,
                                     textvariable=self.rename_string)
        self.rename_button = tk.Button(self.rename_frame_inner0,
                                       text="Rename",
                                       command=self.rename,
                                       width=6)
        self.class_scroll_menu = ScrollMenu(self.rename_frame_inner1,
                                            menu_width=35)
        self.recursive_rename_cbtn = tk.Checkbutton(
            self.rename_frame_inner1,
            text="Recursive",
            variable=self.recursive_rename)

        if self.tag_index_ref:
            # populate the class_scroll_menu options
            opts = sorted([n for n in self.tag_index_ref.class_1.NAME_MAP])
            self.class_scroll_menu.set_options(opts)
            try:
                self.class_scroll_menu.sel_index = opts.index(
                    self.tag_index_ref.class_1.enum_name)
            except ValueError:
                pass

        # tags list
        self.tags_list_entry = tk.Entry(self.tags_list_frame,
                                        width=50,
                                        textvariable=self.tagslist_path)
        self.browse_tags_list_button = tk.Button(self.tags_list_frame,
                                                 text="Browse",
                                                 command=self.tags_list_browse)

        # extract to dir
        self.extract_to_entry = tk.Entry(self.extract_to_frame,
                                         width=50,
                                         textvariable=self.extract_to_dir)
        self.browse_extract_to_button = tk.Button(
            self.extract_to_frame,
            text="Browse",
            command=self.extract_to_browse)

        # settings
        self.recursive_cbtn = tk.Checkbutton(self.settings_frame,
                                             text="Recursive extraction",
                                             variable=settings.get(
                                                 "recursive", tk.IntVar(self)))
        self.overwrite_cbtn = tk.Checkbutton(
            self.settings_frame,
            text="Overwrite tags(not recommended)",
            variable=settings.get("overwrite", tk.IntVar(self)))
        self.do_printout_cbtn = tk.Checkbutton(
            self.settings_frame,
            text="Print extracted tag names",
            variable=settings.get("do_printout", tk.IntVar(self)))
        # zatarita added do_propegate_settings to place the check box in frame, and link value to variable
        self.do_propegate_settings = tk.Checkbutton(
            self.settings_frame,
            text="Use these settings for each item",
            variable=settings.get("propagate_settings", tk.IntVar(self)))

        # accept/cancel
        self.accept_button = tk.Button(self.accept_frame,
                                       text="Add to queue",
                                       command=self.add_to_queue,
                                       width=14)
        self.cancel_button = tk.Button(self.cancel_frame,
                                       text="Cancel",
                                       command=self.destroy,
                                       width=14)
        self.show_meta_button = tk.Button(self,
                                          text="Display metadata",
                                          command=self.show_meta)

        # pack everything
        # frames
        if self.renamable:
            self.rename_frame.pack(padx=4, pady=2, expand=True, fill="x")
        self.rename_frame_inner0.pack(expand=True, fill="x")
        self.rename_frame_inner1.pack(expand=True, fill="x")
        self.tags_list_frame.pack(padx=4, pady=2, expand=True, fill="x")
        self.extract_to_frame.pack(padx=4, pady=2, expand=True, fill="x")
        self.settings_frame.pack(padx=4, pady=2, expand=True, fill="x")

        self.button_frame.pack(pady=2, expand=True, fill="x")
        self.accept_frame.pack(padx=4, side='left', fill='x', expand=True)
        self.cancel_frame.pack(padx=4, side='right', fill='x', expand=True)

        # rename
        self.rename_entry.pack(padx=4, side='left', fill='x', expand=True)
        self.rename_button.pack(padx=4, side='left', fill='x')
        if self.tag_index_ref:
            self.class_scroll_menu.pack(padx=4, side='left', fill='x')
        #self.recursive_rename_cbtn.pack(padx=4, side='left', fill='x')

        # extract to
        self.extract_to_entry.pack(padx=4, side='left', fill='x', expand=True)
        self.browse_extract_to_button.pack(padx=4, side='left', fill='x')

        # tags list
        self.tags_list_entry.pack(padx=4, side='left', fill='x', expand=True)
        self.browse_tags_list_button.pack(padx=4, side='left', fill='x')

        # settings
        # zatarita, added propagatable check box to top of settings frame. (if enabled)
        if self.propagatable:
            self.do_propegate_settings.pack(padx=4, anchor='w')
        self.recursive_cbtn.pack(padx=4, anchor='w')
        self.overwrite_cbtn.pack(padx=4, anchor='w')
        self.do_printout_cbtn.pack(padx=4, anchor='w')

        # accept/cancel
        self.accept_button.pack(side='right')
        self.cancel_button.pack(side='left')
        if self.tag_index_ref is not None:
            self.show_meta_button.pack(padx=4, pady=4, expand=True, fill='x')

        # make the window not show up on the start bar
        self.transient(self.master)
        self.wait_visibility()
        self.lift()
        self.grab_set()
        self.apply_style()

        try:
            self.update()
            self.app_root.place_window_relative(self)
            # I would use focus_set, but it doesn't seem to always work
            self.accept_button.focus_force()
        except AttributeError:
            pass
Exemplo n.º 24
0
    def __init__(self, app_root, *args, **kwargs):
        if window_base_class == tk.Toplevel:
            kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)
            self.app_root = app_root
        else:
            self.app_root = self

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

        #self.title("Model_animations compressor/decompressor")
        self.title("Model_animations decompressor")
        #self.resizable(1, 1)
        self.resizable(0, 0)
        self.update()
        anims_dir = getattr(app_root, "tags_dir", str(Path.cwd()))

        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        self.model_animations_path = tk.StringVar(self)
        self.model_animations_dir = tk.StringVar(
            self, anims_dir if anims_dir else "")
        self.preserve_compressed = tk.IntVar(self, True)
        self.overwrite = tk.IntVar(self, False)

        # make the frames
        self.main_frame = tk.Frame(self)
        self.anims_info_frame = tk.LabelFrame(self, text="Animations info")

        self.model_animations_path_frame = tk.LabelFrame(
            self.main_frame, text="Model_animations path")
        self.model_animations_path_buttons_frame = tk.Frame(self.main_frame)
        self.model_animations_dir_frame = tk.LabelFrame(
            self.main_frame, text="Model_animations dir")
        self.model_animations_dir_buttons_frame = tk.Frame(self.main_frame)
        self.settings_frame = tk.Frame(self.main_frame)

        self.preserve_compressed_cbtn = tk.Checkbutton(
            self.settings_frame,
            anchor="w",
            variable=self.preserve_compressed,
            text="Preserve compressed animation data in tag")
        self.overwrite_cbtn = tk.Checkbutton(
            self.settings_frame,
            anchor="w",
            variable=self.overwrite,
            text="Overwrite model_animations tags")

        self.anims_info_tree = tk.ttk.Treeview(self.anims_info_frame,
                                               selectmode='browse',
                                               padding=(0, 0),
                                               height=4)
        self.anims_info_vsb = tk.Scrollbar(self.anims_info_frame,
                                           orient='vertical',
                                           command=self.anims_info_tree.yview)
        self.anims_info_hsb = tk.Scrollbar(self.anims_info_frame,
                                           orient='horizontal',
                                           command=self.anims_info_tree.xview)
        self.anims_info_tree.config(yscrollcommand=self.anims_info_vsb.set,
                                    xscrollcommand=self.anims_info_hsb.set)

        self.model_animations_path_entry = tk.Entry(
            self.model_animations_path_frame,
            width=50,
            textvariable=self.model_animations_path,
            state=tk.DISABLED)
        self.model_animations_path_browse_button = tk.Button(
            self.model_animations_path_frame,
            text="Browse",
            command=self.model_animations_path_browse)

        self.model_animations_dir_entry = tk.Entry(
            self.model_animations_dir_frame,
            width=50,
            textvariable=self.model_animations_dir,
            state=tk.DISABLED)
        self.model_animations_dir_browse_button = tk.Button(
            self.model_animations_dir_frame,
            text="Browse",
            command=self.model_animations_dir_browse)

        self.compress_button = tk.Button(
            self.model_animations_path_buttons_frame,
            text="Compress tag",
            command=self.compress_model_animations)
        self.decompress_button = tk.Button(
            self.model_animations_path_buttons_frame,
            text="Decompress tag",
            command=self.decompress_model_animations)

        self.compress_all_button = tk.Button(
            self.model_animations_dir_buttons_frame,
            text="Compress all",
            command=self.compress_all_model_animations)
        self.decompress_all_button = tk.Button(
            self.model_animations_dir_buttons_frame,
            text="Decompress all",
            command=self.decompress_all_model_animations)

        self.populate_animations_info_tree()

        # pack everything
        self.main_frame.pack(fill="both", side='left', pady=3, padx=3)
        #self.anims_info_frame.pack(fill="both", side='left', pady=3, padx=3, expand=True)

        self.model_animations_dir_frame.pack(fill='x')
        self.model_animations_dir_buttons_frame.pack(fill="x", pady=3, padx=3)
        self.model_animations_path_frame.pack(fill='x')
        self.model_animations_path_buttons_frame.pack(fill="x", pady=3, padx=3)
        self.settings_frame.pack(fill="both")

        for w in (self.preserve_compressed_cbtn, self.overwrite_cbtn):
            w.pack(expand=True, fill='both')

        self.model_animations_dir_entry.pack(side='left',
                                             fill='x',
                                             expand=True)
        self.model_animations_dir_browse_button.pack(side='left')

        self.model_animations_path_entry.pack(side='left',
                                              fill='x',
                                              expand=True)
        self.model_animations_path_browse_button.pack(side='left')

        self.anims_info_hsb.pack(side="bottom", fill='x')
        self.anims_info_vsb.pack(side="right", fill='y')
        self.anims_info_tree.pack(side='left', fill='both', expand=True)

        #self.compress_all_button.pack(side='right', fill='both', padx=3, expand=True)
        self.decompress_all_button.pack(side='right',
                                        fill='both',
                                        padx=3,
                                        expand=True)
        #self.compress_button.pack(side='right', fill='both', padx=3, expand=True)
        self.decompress_button.pack(side='right',
                                    fill='both',
                                    padx=3,
                                    expand=True)

        self.apply_style()
        if self.app_root is not self:
            self.transient(self.app_root)
Exemplo n.º 25
0
 def __init__(self, app_root, *args, **kwargs):
     self.app_root = app_root
     BinillaWidget.__init__(self, app_root, *args, **kwargs)
Exemplo n.º 26
0
    def __init__(self, app_root, *args, **kwargs):
        self.handler = handler = app_root.handler
        self.app_root = app_root
        kwargs.update(bd=0, highlightthickness=0, bg=self.default_bg_color)
        tk.Toplevel.__init__(self, app_root, *args, **kwargs)
        BinillaWidget.__init__(self, app_root, *args, **kwargs)

        self.title("[%s] Tags directory error locator" %
                   app_root.handler_names[app_root._curr_handler_index])
        self.minsize(width=400, height=300)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        ext_id_map = handler.ext_id_map
        self.listbox_index_to_def_id = [
            ext_id_map[ext] for ext in sorted(ext_id_map.keys())
        ]

        # make the tkinter variables
        self.open_logfile = tk.BooleanVar(self, True)
        self.directory_path = tk.StringVar(self)
        self.logfile_path = tk.StringVar(self)

        # make the frames
        self.directory_frame = tk.LabelFrame(self, text="Directory to scan")
        self.logfile_frame = tk.LabelFrame(self, text="Output log filepath")
        self.def_ids_frame = tk.LabelFrame(
            self, text="Select which tag types to scan")
        self.logfile_dir_frame = tk.Frame(self.logfile_frame)
        self.button_frame = tk.Frame(self.def_ids_frame)

        self.scan_button = tk.Button(self.button_frame,
                                     text='Scan directory',
                                     width=20,
                                     command=self.scan_directory)
        self.cancel_button = tk.Button(self.button_frame,
                                       text='Cancel scan',
                                       width=20,
                                       command=self.cancel_scan)
        self.select_all_button = tk.Button(self.button_frame,
                                           text='Select all',
                                           width=20,
                                           command=self.select_all)
        self.deselect_all_button = tk.Button(self.button_frame,
                                             text='Deselect all',
                                             width=20,
                                             command=self.deselect_all)

        self.directory_entry = tk.Entry(self.directory_frame,
                                        textvariable=self.directory_path)
        self.dir_browse_button = tk.Button(self.directory_frame,
                                           text="Browse",
                                           command=self.dir_browse)

        self.logfile_entry = tk.Entry(
            self.logfile_dir_frame,
            textvariable=self.logfile_path,
        )
        self.log_browse_button = tk.Button(self.logfile_dir_frame,
                                           text="Browse",
                                           command=self.log_browse)
        self.open_logfile_cbtn = tk.Checkbutton(
            self.logfile_frame,
            text="Open log when done scanning",
            variable=self.open_logfile)

        self.def_ids_scrollbar = tk.Scrollbar(self.def_ids_frame,
                                              orient="vertical")
        self.def_ids_listbox = tk.Listbox(
            self.def_ids_frame,
            selectmode='multiple',
            highlightthickness=0,
            yscrollcommand=self.def_ids_scrollbar.set,
            exportselection=False)
        self.def_ids_scrollbar.config(command=self.def_ids_listbox.yview)

        for def_id in self.listbox_index_to_def_id:
            tag_ext = handler.id_ext_map[def_id].split('.')[-1]
            self.def_ids_listbox.insert('end', tag_ext)

            # these tag types are massive, so by
            # default dont set them to be scanned
            if def_id in ("sbsp", "scnr"):
                continue
            self.def_ids_listbox.select_set('end')

        for w in (self.directory_entry, self.logfile_entry):
            w.pack(padx=(4, 0), pady=2, side='left', expand=True, fill='x')

        for w in (self.dir_browse_button, self.log_browse_button):
            w.pack(padx=(0, 4), pady=2, side='left')

        for w in (self.scan_button, self.cancel_button):
            w.pack(padx=4, pady=2)

        for w in (self.deselect_all_button, self.select_all_button):
            w.pack(padx=4, pady=2, side='bottom')

        self.def_ids_listbox.pack(side='left', fill="both", expand=True)
        self.def_ids_scrollbar.pack(side='left', fill="y")
        self.button_frame.pack(side='left', fill="y")

        self.directory_frame.pack(fill='x', padx=1)
        self.logfile_frame.pack(fill='x', padx=1)
        self.logfile_dir_frame.pack(fill='x')
        self.open_logfile_cbtn.pack(fill='x', side=tk.LEFT)
        self.def_ids_frame.pack(fill='both', padx=1, expand=True)

        self.transient(app_root)

        self.directory_path.set(handler.tagsdir)
        self.logfile_path.set(Path(handler.tagsdir, "tag_scanner.log"))
        self.apply_style()
        self.update()
        w, h = self.winfo_reqwidth(), self.winfo_reqheight()
        self.geometry("%sx%s" % (w, h))
        self.minsize(width=w, height=h)
Exemplo n.º 27
0
 def __init__(self, master, *args, **kwargs):
     BinillaWidget.__init__(self)
     self.change_bitmap(kwargs.pop('bitmap_tag', None))
     kwargs.setdefault("command", self.show_window)
     kwargs.setdefault("text", "Bitmap preview")
     ttk.Button.__init__(self, master, *args, **kwargs)
Exemplo n.º 28
0
    def apply_style(self, seen=None):
        BinillaWidget.apply_style(self, seen)
        self.tags_tree_frame.config(bg=self.default_bg_color)

        dir_tree = self.tags_tree
        self.highlight_tags_dir()
Exemplo n.º 29
0
    def __init__(self, *args, **kwargs):
        self.settings = settings = kwargs.pop('settings', {})
        BinillaWidget.__init__(self, *args, **kwargs)
        tk.Toplevel.__init__(self, *args, **kwargs)
        try:
            self.iconbitmap(e_c.REFINERY_ICON_PATH)
        except Exception:
            if not e_c.IS_LNX:
                print("Could not load window icon.")

        self.geometry("550x350")
        self.minsize(width=450, height=350)
        self.resizable(1, 1)
        self.title("Settings")

        self.tabs = ttk.Notebook(self)
        self.dirs_frame         = tk.Frame(self.tabs)
        self.extract_frame      = tk.Frame(self.tabs)
        self.data_extract_frame = tk.Frame(self.tabs)
        self.tag_fixup_frame    = tk.Frame(self.tabs)
        self.deprotect_frame    = tk.Frame(self.tabs)
        self.heuristics_frame   = tk.Frame(self.tabs)
        self.fonts_frame        = tk.Frame(self.tabs)
        self.other_frame        = tk.Frame(self.tabs)

        self.tabs.add(self.dirs_frame, text="Directories")
        self.tabs.add(self.extract_frame, text="Extraction")
        self.tabs.add(self.data_extract_frame, text="Data extraction")
        self.tabs.add(self.tag_fixup_frame, text="Tag fixup")
        self.tabs.add(self.deprotect_frame, text="Deprotection")
        self.tabs.add(self.heuristics_frame, text="Heuristics")
        self.tabs.add(self.fonts_frame, text="Fonts")
        self.tabs.add(self.other_frame, text="Other")

        font_families = tuple(sorted(tkinter.font.families()))

        self.tags_dir_frame  = tk.LabelFrame(
            self.dirs_frame, text="Default tags extraction folder")
        self.data_dir_frame  = tk.LabelFrame(
            self.dirs_frame, text="Default data extraction folder")
        self.tags_list_frame = tk.LabelFrame(
            self.dirs_frame, text="Tags list log (erase to disable logging)")

        for attr in ("overwrite", "recursive",
                     "rename_scnr_dups", "decode_adpcm",
                     "bitmap_extract_keep_alpha",
                     "generate_comp_verts", "generate_uncomp_verts",
                     "force_lower_case_paths", "fix_tag_classes",
                     "autoload_resources", "extract_yelo_cheape",
                     "use_minimum_priorities", "use_heuristics",
                     "rename_cached_tags", "show_all_fields",
                     "show_structure_meta",
                     "edit_all_fields", "allow_corrupt",
                     "valid_tag_paths_are_accurate", "limit_tag_path_lengths",
                     "scrape_tag_paths_from_scripts", "shallow_ui_widget_nesting",
                     "fix_tag_index_offset", "use_tag_index_for_script_names",
                     "do_printout", "print_heuristic_name_changes",
                     "use_scenario_names_for_script_names",
                     "skip_seen_tags_during_queue_processing",
                     "disable_safe_mode", "disable_tag_cleaning",):
            object.__setattr__(self, attr, settings.get(attr, tk.IntVar(self)))

        for attr in ("bitmap_extract_format", "globals_overwrite_mode",
                     "tags_dir", "data_dir", "tagslist_path"):
            object.__setattr__(self, attr, settings.get(attr, tk.StringVar(self)))


        # tags directory
        self.tags_dir_entry = tk.Entry(
            self.tags_dir_frame, state='disabled',
            textvariable=self.tags_dir)
        self.tags_dir_browse_button = tk.Button(
            self.tags_dir_frame, text="Browse",
            command=self.tags_dir_browse, width=6)

        # data directory
        self.data_dir_entry = tk.Entry(
            self.data_dir_frame, state='disabled',
            textvariable=self.data_dir)
        self.data_dir_browse_button = tk.Button(
            self.data_dir_frame, text="Browse",
            command=self.data_dir_browse, width=6)

        # tags list
        self.tags_list_entry = tk.Entry(
            self.tags_list_frame, textvariable=self.tagslist_path)
        self.browse_tags_list_button = tk.Button(
            self.tags_list_frame, text="Browse",
            command=self.tags_list_browse, width=6)


        self.rename_scnr_dups_cbtn = tk.Checkbutton(
            self.tag_fixup_frame, text=(
                "Rename duplicate camera points, cutscene\n"+
                "flags, and recorded animations in scenario"),
            variable=self.rename_scnr_dups, justify="left")
        self.generate_comp_verts_cbtn = tk.Checkbutton(
            self.tag_fixup_frame, text="Generate compressed lightmap vertices",
            variable=self.generate_comp_verts)
        self.generate_uncomp_verts_cbtn = tk.Checkbutton(
            self.tag_fixup_frame, text="Generate uncompressed lightmap vertices",
            variable=self.generate_uncomp_verts)

        self.dont_touch_frame = tk.LabelFrame(
            self.tag_fixup_frame,
            text="ONLY CHECK THESE IF YOU ARE NOT DEALING WITH PROTECTED MAPS")
        self.disable_safe_mode_cbtn = tk.Checkbutton(
            self.dont_touch_frame, variable=self.disable_safe_mode, justify="left",
            text="Disable safe-mode")
        self.disable_tag_cleaning_cbtn = tk.Checkbutton(
            self.dont_touch_frame, variable=self.disable_tag_cleaning, justify="left",
            text="Disable cleaning errors from tags when reading them.")


        self.overwrite_cbtn = tk.Checkbutton(
            self.extract_frame, text="Overwrite files(not recommended)",
            variable=self.overwrite)
        self.recursive_cbtn = tk.Checkbutton(
            self.extract_frame, text="Recursive extraction",
            variable=self.recursive)
        self.do_printout_cbtn = tk.Checkbutton(
            self.extract_frame, text="Print extracted file names",
            variable=self.do_printout)
        self.force_lower_case_paths_cbtn = tk.Checkbutton(
            self.extract_frame, text="Force all tag paths to lowercase",
            variable=self.force_lower_case_paths)
        self.skip_seen_tags_during_queue_processing_cbtn = tk.Checkbutton(
            self.extract_frame, text="During processing, skip any tags that were already extracted",
            variable=self.skip_seen_tags_during_queue_processing)
        self.globals_overwrite_mode_frame = tk.LabelFrame(
            self.extract_frame, relief="flat",
            text="When to overwrite an existing globals.globals")

        sel_index = self.globals_overwrite_mode.get()
        if sel_index not in range(len(globals_overwrite_gui_names)):
            sel_index = 0

        self.globals_overwrite_mode_menu = ScrollMenu(
            self.globals_overwrite_mode_frame, sel_index=sel_index,
            variable=self.globals_overwrite_mode, menu_width=50,
            options=globals_overwrite_gui_names)


        self.decode_adpcm_cbtn = tk.Checkbutton(
            self.data_extract_frame, variable=self.decode_adpcm,
            text="Decode Xbox audio")
        self.bitmap_extract_frame = tk.LabelFrame(
            self.data_extract_frame, relief="flat",
            text="Bitmap extraction format")
        self.bitmap_extract_keep_alpha_cbtn = tk.Checkbutton(
            self.bitmap_extract_frame, variable=self.bitmap_extract_keep_alpha,
            text="Preserve alpha when extracting to PNG")
        self.use_tag_index_for_script_names_cbtn = tk.Checkbutton(
            self.data_extract_frame, variable=self.use_tag_index_for_script_names,
            text=("When extracting scripts, redirect tag references to\n"
                  "what the tag is currently named(guarantees scripts\n"
                  "point to a valid tag, even if you rename them)"),
            justify="left")
        self.use_scenario_names_for_script_names_cbtn = tk.Checkbutton(
            self.data_extract_frame, variable=self.use_scenario_names_for_script_names,
            text=("When extracting scripts, extract names for encounters,\n"
                  "command lists, scripts, cutscene titles/camera points/flags,\n"
                  "trigger volumes, recorded animations, ai conversations,\n"
                  "object names, device groups, and player starting profiles\n"
                  "from the scenarios reflexives, rather than script strings."),
            justify="left")

        try:
            sel_index = bitmap_file_formats.index(self.bitmap_extract_format.get())
        except Exception:
            sel_index = 0

        self.bitmap_extract_format_menu = ScrollMenu(
            self.bitmap_extract_frame, str_variable=self.bitmap_extract_format,
            menu_width=10, options=bitmap_file_formats, sel_index=sel_index)


        self.fix_tag_classes_cbtn = tk.Checkbutton(
            self.deprotect_frame, text="Fix tag classes",
            variable=self.fix_tag_classes)
        self.use_heuristics_cbtn = tk.Checkbutton(
            self.deprotect_frame, text="Use heuristic deprotection methods",
            variable=self.use_heuristics)
        self.scrape_tag_paths_from_scripts_cbtn = tk.Checkbutton(
            self.deprotect_frame, text="Scrape tag paths from scenario scripts",
            variable=self.scrape_tag_paths_from_scripts)
        self.rename_cached_tags_cbtn = tk.Checkbutton(
            self.deprotect_frame, text=("Rename cached tags using tag paths in\n"
                                        "bitmaps/loc/sounds resource maps"),
            variable=self.rename_cached_tags, justify="left")
        self.limit_tag_path_lengths_cbtn = tk.Checkbutton(
            self.deprotect_frame, text="Limit tag paths to 254 characters (tool.exe limitation)",
            variable=self.limit_tag_path_lengths)
        self.fix_tag_index_offset_cbtn = tk.Checkbutton(
            self.deprotect_frame, text=("Fix tag index offset when saving\n"
                                        "WARNING: Can corrupt certain maps"),
            variable=self.fix_tag_index_offset, justify='left')


        self.valid_tag_paths_are_accurate_cbtn = tk.Checkbutton(
            self.heuristics_frame, text="Do not rename non-protected tag paths",
            variable=self.valid_tag_paths_are_accurate)
        self.shallow_ui_widget_nesting_cbtn = tk.Checkbutton(
            self.heuristics_frame, text="Use shallow ui_widget_definition nesting",
            variable=self.shallow_ui_widget_nesting)
        self.use_fast_heuristics_cbtn = tk.Checkbutton(
            self.heuristics_frame, text="Use fast heuristics",
            variable=self.use_minimum_priorities)
        self.print_heuristic_progress_cbtn = tk.Checkbutton(
            self.heuristics_frame, text=("Print heuristic tag path changes"),
            variable=self.print_heuristic_name_changes, justify='left')


        font_frame_widgets = {}
        for font_type in sorted(self.font_settings):
            if font_type not in ("default", "treeview", "console", "heading",
                                 "heading_small", "frame_title",):
                continue

            if font_type == "console":
                font_type_name_text = "Map info"
            elif font_type == "treeview":
                font_type_name_text = "Map contents / Extraction queue"
            elif font_type == "heading_small":
                font_type_name_text = "Map contents columns / Settings tabs"
            else:
                font_type_name_text = font_type.replace("_", " ").capitalize()

            font_frame = tk.LabelFrame(
                self.fonts_frame, text=font_type_name_text)

            font_info = self.font_settings[font_type]
            try:
                sel_index = font_families.index(font_info.family)
            except Exception:
                sel_index = -1

            family_var = tk.StringVar(self)
            size_var = tk.StringVar(self, str(font_info.size))
            weight_var = tk.IntVar(self, int(font_info.weight == "bold"))
            self.write_trace(family_var, lambda *a, v=family_var, t=font_type:
                             self.update_font_family(v, t))
            self.write_trace(size_var, lambda *a, v=size_var, t=font_type:
                             self.update_font_size(v, t))
            self.write_trace(weight_var, lambda *a, v=weight_var, t=font_type:
                             self.update_font_weight(v, t))

            family_label = tk.Label(font_frame, text="Family ")
            family_menu = ScrollMenu(
                font_frame, str_variable=family_var, menu_width=20,
                options=font_families, sel_index=sel_index)
            weight_btn = tk.Checkbutton(font_frame, text="bold", variable=weight_var)
            size_label = tk.Label(font_frame, text="Size ")
            size_menu = tk.Spinbox(
                font_frame, width=3, state="readonly",
                textvariable=size_var, from_=0, to=200)

            font_frame_widgets[font_type_name_text] = (
                font_frame, (family_label, family_menu, weight_btn,
                             size_label, size_menu))

        self.apply_fonts_btn = tk.Button(
            self.fonts_frame, text="Apply changes", command=self.apply_fonts)


        self.autoload_resources_cbtn = tk.Checkbutton(
            self.other_frame, text=("Load resource maps automatically\n" +
                                    "when loading a non-resource map"),
            variable=self.autoload_resources, justify="left")
        self.extract_yelo_cheape_cbtn = tk.Checkbutton(
            self.other_frame, variable=self.extract_yelo_cheape,
            text="Extract cheape.map when extracting from yelo maps")
        self.show_all_fields_cbtn = tk.Checkbutton(
            self.other_frame, variable=self.show_all_fields,
            text="Show hidden fields when viewing metadata")
        self.show_structure_meta_cbtn = tk.Checkbutton(
            self.other_frame, variable=self.show_structure_meta,
            text="Show hidden meta structure fields when viewing metadata")
        self.edit_all_fields_cbtn = tk.Checkbutton(
            self.other_frame, variable=self.edit_all_fields,
            text="Allow editing all fields when viewing metadata")
        self.allow_corrupt_cbtn = tk.Checkbutton(
            self.other_frame, variable=self.allow_corrupt,
            text="Allow previewing corrupt tags")


        # pack everything
        self.tabs.pack(fill="both", expand=True)
        for w in (self.tags_dir_frame, self.data_dir_frame,
                  self.tags_list_frame):
            w.pack(padx=4, pady=2, fill="x")

        for w in (self.overwrite_cbtn, self.recursive_cbtn,
                  self.do_printout_cbtn, self.force_lower_case_paths_cbtn,
                  self.skip_seen_tags_during_queue_processing_cbtn,
                  self.globals_overwrite_mode_frame):
            w.pack(padx=4, anchor='w')

        for w in (self.bitmap_extract_keep_alpha_cbtn,
                  self.bitmap_extract_format_menu, self.globals_overwrite_mode_menu):
            w.pack(padx=16, anchor='w')

        for w in (self.decode_adpcm_cbtn, self.bitmap_extract_frame,
                  self.use_tag_index_for_script_names_cbtn,
                  self.use_scenario_names_for_script_names_cbtn):
            w.pack(padx=4, anchor='w')

        for w in (self.rename_scnr_dups_cbtn,
                  self.generate_uncomp_verts_cbtn, self.generate_comp_verts_cbtn):
            w.pack(padx=4, anchor='w')

        self.dont_touch_frame.pack(padx=4, anchor='w', expand=True, fill="both")
        for w in (self.disable_safe_mode_cbtn, self.disable_tag_cleaning_cbtn):
            w.pack(padx=4, anchor='w')

        for w in (self.fix_tag_classes_cbtn, self.use_heuristics_cbtn,
                  self.fix_tag_index_offset_cbtn, self.rename_cached_tags_cbtn,
                  self.limit_tag_path_lengths_cbtn,
                  self.scrape_tag_paths_from_scripts_cbtn,
                  ):
            w.pack(padx=4, anchor='w')

        for w in (self.print_heuristic_progress_cbtn,
                  self.valid_tag_paths_are_accurate_cbtn,
                  self.shallow_ui_widget_nesting_cbtn,
                  self.use_fast_heuristics_cbtn,
                  ):
            w.pack(padx=4, anchor='w')

        for w in (self.autoload_resources_cbtn, self.extract_yelo_cheape_cbtn,
                  self.show_all_fields_cbtn, self.show_structure_meta_cbtn,
                  self.edit_all_fields_cbtn, self.allow_corrupt_cbtn,
                  ):
            w.pack(padx=4, anchor='w')

        for k in sorted(font_frame_widgets):
            font_frame, font_widgets = font_frame_widgets[k]
            font_frame.pack(padx=4, anchor='w', expand=True, fill="x")
            for w in font_widgets:
                w.pack(padx=(0, 4), pady=2, side='left', fill='both',
                       expand=isinstance(w, ScrollMenu))

        self.apply_fonts_btn.pack(padx=4, anchor='w', expand=True, fill="both")

        for w1, w2 in ((self.tags_dir_entry, self.tags_dir_browse_button),
                       (self.data_dir_entry, self.data_dir_browse_button),
                       (self.tags_list_entry, self.browse_tags_list_button)):
            w1.pack(padx=(4, 0), pady=2, side='left', expand=True, fill='x')
            w2.pack(padx=(0, 4), pady=2, side='left')

        # make the window not show up on the start bar
        self.transient(self.master)
        self.apply_style()
Exemplo n.º 30
0
 def set_disabled(self, disable=True):
     if bool(disable) != self.disabled:
         self.config(state='disabled' if disable else 'normal')
         BinillaWidget.set_disabled(self, disable)