示例#1
0
    def __init__(self, master, bitmap_tag=None, *args, **kwargs):
        self.bitmap_tag = bitmap_tag
        textures = kwargs.get('textures', ())
        BitmapDisplayFrame.__init__(self, master, *args, **kwargs)
        self.sequence_index = tk.IntVar(self)
        self.sprite_index   = tk.IntVar(self)

        labels = []
        labels.append(tk.Label(self.controls_frame0, text="Sequence index"))
        labels.append(tk.Label(self.controls_frame1, text="Sprite index"))
        for lbl in labels:
            lbl.config(width=15, anchor='w')

        self.sequence_menu = ScrollMenu(self.controls_frame0, menu_width=7,
                                        variable=self.sequence_index)
        self.sprite_menu = ScrollMenu(self.controls_frame1, menu_width=7,
                                      variable=self.sprite_index)

        padx = self.horizontal_padx
        pady = self.horizontal_pady
        for lbl in labels:
            lbl.pack(side='left', padx=(15, 0), pady=pady)
        self.sequence_menu.pack(side='left', padx=padx, pady=pady)
        self.sprite_menu.pack(side='left', padx=padx, pady=pady)
        self.write_trace(self.sequence_index, self.sequence_changed)
        self.write_trace(self.sprite_index,   self.sprite_changed)

        self.change_textures(textures)
        self.apply_style()
示例#2
0
    def __init__(self, *args, **kwargs):
        BitmapDisplayFrame.__init__(self, *args, **kwargs)
        for w in (self.hsb, self.vsb, self.root_canvas):
            w.pack_forget()

        self.preview_label = tk.Label(self, text="Bitmap preview\t")
        self.image_canvas = tk.Canvas(self, highlightthickness=0)
        self.channel_menu = ScrollMenu(self,
                                       menu_width=9,
                                       can_scroll=True,
                                       variable=self.channel_index)
        self.save_button = ttk.Button(self,
                                      width=11,
                                      text="Save as...",
                                      command=self.save_as)

        padx = self.horizontal_padx
        pady = self.horizontal_pady

        self.image_canvas.config(width=1, height=1)
        self.preview_label.pack(side='left', padx=padx, pady=pady, fill='x')
        self.channel_menu.pack(side='left', padx=padx, pady=pady)
        self.save_button.pack(side='left', padx=padx, pady=pady)
        self.image_canvas.pack(side='left',
                               padx=padx,
                               pady=pady,
                               fill='x',
                               expand=True)

        self.apply_style()
示例#3
0
    def setup_window(self, *args, **kwargs):
        ConverterBase.setup_window(self, *args, **kwargs)

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

        self.pack_widgets()
        self.apply_style()
示例#4
0
    def __init__(self, *args, **kwargs):
        kwargs.update(relief='flat', bd=0, highlightthickness=0)
        data_frame.DataFrame.__init__(self, *args, **kwargs)

        try:
            sel_index = self.node.get_index()
        except Exception:
            sel_index = -1

        # make the widgets
        self.content = tk.Frame(self, relief='flat', bd=0)

        self.display_comment()

        self.title_label = tk.Label(
            self.content,
            text=self.gui_name,
            justify='left',
            anchor='w',
            width=self.title_size,
            disabledforeground=self.text_disabled_color)
        self.sel_menu = ScrollMenu(self.content,
                                   f_widget_parent=self,
                                   menu_width=self.widget_width,
                                   sel_index=sel_index,
                                   max_index=self.desc.get('ENTRIES', 0) - 1,
                                   disabled=self.disabled,
                                   default_text="<INVALID>",
                                   option_getter=self.get_options,
                                   callback=self.select_option)

        if self.gui_name != '':
            self.title_label.pack(side="left", fill="x")
        self.content.pack(fill="x", expand=True)
        self.sel_menu.pack(side="left", fill="x")
        self.populate()
        self.pose_fields()
        self._initialized = True
示例#5
0
    def __init__(self, *args, **kwargs):
        kwargs.update(relief='flat', bd=0, highlightthickness=0)
        data_frame.DataFrame.__init__(self, *args, **kwargs)

        sel_index = -1 if self.node is None else self.node + 1

        # make the widgets
        self.content = tk.Frame(self, relief='flat', bd=0)
        self.title_label = tk.Label(
            self.content,
            text=self.gui_name,
            justify='left',
            anchor='w',
            width=self.title_size,
            disabledforeground=self.text_disabled_color)
        self.sel_menu = ScrollMenu(self.content,
                                   f_widget_parent=self,
                                   menu_width=self.widget_width,
                                   sel_index=sel_index,
                                   max_index=0,
                                   disabled=self.disabled,
                                   default_text="<INVALID>",
                                   option_getter=self.get_options,
                                   callback=self.select_option)

        self.sel_menu.bind('<FocusIn>', self.flag_sanity_change)
        self.sel_menu.arrow_button.bind('<FocusIn>', self.flag_sanity_change)
        self.sel_menu.bind('<Enter>', self.flag_sanity_change)
        self.sel_menu.arrow_button.bind('<Enter>', self.flag_sanity_change)
        self.sel_menu.options_volatile = 'DYN_NAME_PATH' in self.desc

        if self.gui_name != '':
            self.title_label.pack(side="left", fill="x")
        self.content.pack(fill="x", expand=True)
        self.sel_menu.pack(side="left", fill="x")
        self.populate()
        self._initialized = True
示例#6
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()
示例#7
0
    def __init__(self, *args, **kwargs):
        field_widget.FieldWidget.__init__(self, *args, **kwargs)
        self.u_node_widgets_by_u_index = {}

        if self.f_widget_parent is None:
            self.pack_padx = self.pack_pady = 0

        kwargs.update(relief='flat',
                      bd=0,
                      highlightthickness=0,
                      bg=self.default_bg_color)

        show_frame = bool(
            kwargs.pop('show_frame', not self.blocks_start_hidden))
        if self.is_empty and self.hide_if_blank:
            show_frame = False

        tk.Frame.__init__(self, *args, **e_c.fix_kwargs(**kwargs))

        self.show = tk.BooleanVar(self)
        self.show.set(show_frame)

        max_u_index = len(self.desc['CASE_MAP'])
        u_index = getattr(self.node, "u_index", None)
        if u_index is None:
            u_index = max_u_index

        toggle_text = '-' if show_frame else '+'

        self.title = tk.Frame(self, relief='raised')
        self.show_btn = ttk.Checkbutton(self.title,
                                        width=3,
                                        text=toggle_text,
                                        command=self.toggle_visible,
                                        style='ShowButton.TButton')
        self.title_label = tk.Label(self.title,
                                    text=self.gui_name,
                                    anchor='w',
                                    width=self.title_size,
                                    justify='left')
        self.title_label.font_type = "frame_title"
        self.sel_menu = ScrollMenu(self.title,
                                   f_widget_parent=self,
                                   sel_index=u_index,
                                   max_index=max_u_index,
                                   disabled=self.disabled,
                                   callback=self.select_option,
                                   option_getter=self.get_options)

        self.show_btn.pack(side="left")
        self.title_label.pack(side="left", fill="x", expand=True)
        self.sel_menu.pack(side="left", fill="x")
        self.title.pack(fill="x", expand=True)

        self.content = tk.Frame(self, relief="sunken")

        # make the default raw bytes union frame
        self.raw_frame = tk.Frame(self.content, relief="flat", bd=0)
        self.raw_label = tk.Label(self.raw_frame,
                                  text='DataUnion',
                                  width=self.title_size,
                                  anchor='w',
                                  disabledforeground=self.text_disabled_color)
        self.import_btn = ttk.Button(self.raw_frame,
                                     text='Import',
                                     command=self.import_node,
                                     width=7)
        self.export_btn = ttk.Button(self.raw_frame,
                                     text='Export',
                                     command=self.export_node,
                                     width=7)

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

        self.populate()
        self._initialized = True
示例#8
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
示例#9
0
    def __init__(self, *args, **kwargs):
        kwargs.update(relief='flat',
                      bd=0,
                      highlightthickness=0,
                      bg=self.default_bg_color)
        field_widget.FieldWidget.__init__(self, *args, **kwargs)
        tk.Frame.__init__(self, *args, **e_c.fix_kwargs(**kwargs))

        show_frame = bool(
            kwargs.pop('show_frame', not self.blocks_start_hidden))
        if self.is_empty and self.hide_if_blank:
            show_frame = False

        self.show = tk.BooleanVar()
        self.show.set(show_frame)
        self.options_sane = False

        node_len = 0
        try:
            node_len = len(self.node)
        except Exception:
            pass

        self.sel_index = (node_len > 0) - 1

        # make the title, element menu, and all the buttons
        self.controls = tk.Frame(self, relief='raised', bd=self.frame_depth)
        self.title = title = tk.Frame(self.controls, relief='flat', bd=0)
        self.buttons = buttons = tk.Frame(self.controls, relief='flat', bd=0)

        toggle_text = '-' if show_frame else '+'

        self.title_label = tk.Label(
            title,
            text=self.gui_name,
            justify='left',
            anchor='w',
            width=self.title_size,
            font=self.get_font("frame_title"),
            disabledforeground=self.text_disabled_color)
        self.title_label.font_type = "frame_title"

        self.show_btn = ttk.Checkbutton(title,
                                        width=3,
                                        text=toggle_text,
                                        command=self.toggle_visible,
                                        style='ShowButton.TButton')
        self.sel_menu = ScrollMenu(title,
                                   f_widget_parent=self,
                                   sel_index=self.sel_index,
                                   max_index=node_len - 1,
                                   option_getter=self.get_options,
                                   callback=self.select_option)

        self.shift_up_btn = ttk.Button(title,
                                       width=7,
                                       text='Shift ▲',
                                       command=self.shift_entry_up)
        self.shift_down_btn = ttk.Button(buttons,
                                         width=7,
                                         text='Shift ▼',
                                         command=self.shift_entry_down)
        self.add_btn = ttk.Button(buttons,
                                  width=4,
                                  text='Add',
                                  command=self.add_entry)
        self.insert_btn = ttk.Button(buttons,
                                     width=6,
                                     text='Insert',
                                     command=self.insert_entry)
        self.duplicate_btn = ttk.Button(buttons,
                                        width=9,
                                        text='Duplicate',
                                        command=self.duplicate_entry)
        self.delete_btn = ttk.Button(buttons,
                                     width=6,
                                     text='Delete',
                                     command=self.delete_entry)
        self.delete_all_btn = ttk.Button(buttons,
                                         width=10,
                                         text='Delete all',
                                         command=self.delete_all_entries)

        self.import_btn = ttk.Button(buttons,
                                     width=6,
                                     text='Import',
                                     command=self.import_node)
        self.export_btn = ttk.Button(buttons,
                                     width=6,
                                     text='Export',
                                     command=self.export_node)

        # pack the title, menu, and all the buttons
        for w in (self.shift_down_btn, self.export_btn, self.import_btn,
                  self.delete_all_btn, self.delete_btn, self.duplicate_btn,
                  self.insert_btn, self.add_btn):
            w.pack(side="right", padx=(0, 4), pady=(2, 2))

        self.show_btn.pack(side="left")
        if self.gui_name != '':
            self.title_label.pack(side="left", fill="x", expand=True)

        self.sel_menu.pack(side="left", fill="x", expand=True, padx=(0, 4))
        self.shift_up_btn.pack(side="right", padx=(0, 1), pady=(2, 2))

        self.title.pack(fill="x", expand=True, padx=0)
        self.buttons.pack(fill="x", expand=True, padx=0)
        self.controls.pack(fill="x", expand=True, padx=0)

        self.populate()
        self._initialized = True
示例#10
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)
示例#11
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()
示例#12
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("Gbxmodel compiler")
        self.resizable(1, 1)
        self.update()
        try:
            self.iconbitmap(e_c.MOZZ_ICON_PATH)
        except Exception:
            print("Could not load window icon.")

        self.superhigh_lod_cutoff = tk.StringVar(self)
        self.high_lod_cutoff = tk.StringVar(self)
        self.medium_lod_cutoff = tk.StringVar(self)
        self.low_lod_cutoff = tk.StringVar(self)
        self.superlow_lod_cutoff = tk.StringVar(self)
        self.shader_path_string_var = tk.StringVar(self)

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

        self.optimize_level = tk.IntVar(self)
        self.tags_dir = tk.StringVar(self, tags_dir if tags_dir else "")
        self.jms_dir = tk.StringVar(self)
        self.gbxmodel_path = tk.StringVar(self)

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

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

        self.jms_dir_frame = tk.LabelFrame(self.dirs_frame,
                                           text="Source models folder")
        self.tags_dir_frame = tk.LabelFrame(self.dirs_frame,
                                            text="Tags directory root folder")
        self.gbxmodel_path_frame = tk.LabelFrame(self.dirs_frame,
                                                 text="Gbxmodel output path")

        self.lods_frame = tk.LabelFrame(self.settings_frame,
                                        text="LOD cutoffs")
        self.shaders_frame = tk.LabelFrame(self.settings_frame, text="Shaders")

        self.optimize_label = tk.Label(
            self.settings_frame,
            justify="right",
            text=("Vertex optimization\n(Set before loading)"))
        self.optimize_menu = ScrollMenu(self.settings_frame,
                                        menu_width=5,
                                        options=("None", "Exact", "Loose"))
        self.optimize_menu.sel_index = 1

        self.jms_info_tree = tk.ttk.Treeview(self.jms_info_frame,
                                             selectmode='browse',
                                             padding=(0, 0),
                                             height=4)
        self.jms_info_vsb = tk.Scrollbar(self.jms_info_frame,
                                         orient='vertical',
                                         command=self.jms_info_tree.yview)
        self.jms_info_hsb = tk.Scrollbar(self.jms_info_frame,
                                         orient='horizontal',
                                         command=self.jms_info_tree.xview)
        self.jms_info_tree.config(yscrollcommand=self.jms_info_vsb.set,
                                  xscrollcommand=self.jms_info_hsb.set)

        self.shader_names_menu = ScrollMenu(
            self.shaders_frame,
            menu_width=10,
            callback=self.select_shader,
            option_getter=self.get_shader_names,
            options_volatile=True)
        self.shader_types_menu = ScrollMenu(self.shaders_frame,
                                            menu_width=20,
                                            options=shader_types,
                                            callback=self.select_shader_type)
        self.shader_path_browse_button = tk.Button(
            self.shaders_frame,
            text="Browse",
            width=6,
            command=self.browse_shader_path)
        self.shader_path_entry = tk.Entry(
            self.shaders_frame, textvariable=self.shader_path_string_var)

        self.write_trace(self.shader_path_string_var, self.shader_path_edited)

        self.superhigh_lod_label = tk.Label(self.lods_frame, text="Superhigh")
        self.high_lod_label = tk.Label(self.lods_frame, text="High")
        self.medium_lod_label = tk.Label(self.lods_frame, text="Medium")
        self.low_lod_label = tk.Label(self.lods_frame, text="Low")
        self.superlow_lod_label = tk.Label(self.lods_frame, text="Superlow")
        self.superhigh_lod_cutoff_entry = tk.Entry(
            self.lods_frame,
            textvariable=self.superhigh_lod_cutoff,
            width=6,
            justify='right')
        self.high_lod_cutoff_entry = tk.Entry(
            self.lods_frame,
            textvariable=self.high_lod_cutoff,
            width=6,
            justify='right')
        self.medium_lod_cutoff_entry = tk.Entry(
            self.lods_frame,
            textvariable=self.medium_lod_cutoff,
            width=6,
            justify='right')
        self.low_lod_cutoff_entry = tk.Entry(self.lods_frame,
                                             textvariable=self.low_lod_cutoff,
                                             width=6,
                                             justify='right')
        self.superlow_lod_cutoff_entry = tk.Entry(
            self.lods_frame,
            textvariable=self.superlow_lod_cutoff,
            width=6,
            justify='right')

        self.jms_dir_entry = tk.Entry(self.jms_dir_frame,
                                      textvariable=self.jms_dir,
                                      state=tk.DISABLED)
        self.jms_dir_browse_button = tk.Button(self.jms_dir_frame,
                                               text="Browse",
                                               command=self.jms_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.gbxmodel_path_entry = tk.Entry(self.gbxmodel_path_frame,
                                            textvariable=self.gbxmodel_path,
                                            state=tk.DISABLED)
        self.gbxmodel_path_browse_button = tk.Button(
            self.gbxmodel_path_frame,
            text="Browse",
            command=self.gbxmodel_path_browse)

        self.load_button = tk.Button(self.buttons_frame,
                                     text="Load\nmodels",
                                     command=self.load_models)
        self.save_button = tk.Button(self.buttons_frame,
                                     text="Save as JMS",
                                     command=self.save_models)
        self.compile_button = tk.Button(self.buttons_frame,
                                        text="Compile\ngbxmodel",
                                        command=self.compile_gbxmodel)

        self.populate_model_info_tree()

        # pack everything
        self.main_frame.pack(fill="both", side='left', pady=3, padx=3)
        self.jms_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", expand=True)

        self.superhigh_lod_label.grid(sticky='e',
                                      row=0,
                                      column=0,
                                      padx=3,
                                      pady=1)
        self.high_lod_label.grid(sticky='e', row=1, column=0, padx=3, pady=1)
        self.medium_lod_label.grid(sticky='e', row=2, column=0, padx=3, pady=1)
        self.low_lod_label.grid(sticky='e', row=3, column=0, padx=3, pady=1)
        self.superlow_lod_label.grid(sticky='e',
                                     row=4,
                                     column=0,
                                     padx=3,
                                     pady=1)
        self.superhigh_lod_cutoff_entry.grid(sticky='ew',
                                             row=0,
                                             column=1,
                                             padx=3,
                                             pady=1)
        self.high_lod_cutoff_entry.grid(sticky='ew',
                                        row=1,
                                        column=1,
                                        padx=3,
                                        pady=1)
        self.medium_lod_cutoff_entry.grid(sticky='ew',
                                          row=2,
                                          column=1,
                                          padx=3,
                                          pady=1)
        self.low_lod_cutoff_entry.grid(sticky='ew',
                                       row=3,
                                       column=1,
                                       padx=3,
                                       pady=1)
        self.superlow_lod_cutoff_entry.grid(sticky='ew',
                                            row=4,
                                            column=1,
                                            padx=3,
                                            pady=1)

        self.jms_dir_frame.pack(expand=True, fill='x')
        self.tags_dir_frame.pack(expand=True, fill='x')
        self.gbxmodel_path_frame.pack(expand=True, fill='x')

        self.jms_dir_entry.pack(side='left', expand=True, fill='x')
        self.jms_dir_browse_button.pack(side='left')

        self.gbxmodel_path_entry.pack(side='left', expand=True, fill='x')
        self.gbxmodel_path_browse_button.pack(side='left')

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

        self.optimize_label.grid(sticky='ne', row=3, column=1, padx=3)
        self.optimize_menu.grid(sticky='new',
                                row=3,
                                column=2,
                                padx=3,
                                pady=(3, 0))
        self.lods_frame.grid(sticky='ne', row=0, column=3, rowspan=4)
        self.shaders_frame.grid(sticky='nsew',
                                row=0,
                                column=0,
                                columnspan=3,
                                rowspan=3,
                                pady=(0, 3))

        self.shader_names_menu.grid(sticky='new',
                                    row=0,
                                    column=0,
                                    padx=3,
                                    columnspan=5,
                                    pady=2)
        self.shader_path_browse_button.grid(sticky='ne',
                                            row=1,
                                            column=4,
                                            padx=3,
                                            pady=2)
        self.shader_types_menu.grid(sticky='new',
                                    row=1,
                                    column=1,
                                    padx=3,
                                    columnspan=3,
                                    pady=2)
        self.shader_path_entry.grid(sticky='new',
                                    row=2,
                                    column=0,
                                    padx=3,
                                    columnspan=5,
                                    pady=2)

        self.jms_info_hsb.pack(side="bottom", fill='x')
        self.jms_info_vsb.pack(side="right", fill='y')
        self.jms_info_tree.pack(side='left', fill='both', expand=True)

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

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