Ejemplo n.º 1
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)
Ejemplo n.º 2
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()
Ejemplo n.º 3
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
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def __init__(self, app_root, *args, **kwargs):
     self.app_root = app_root
     BinillaWidget.__init__(self, app_root, *args, **kwargs)
Ejemplo n.º 6
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
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
    def __init__(self, *args, **kwargs):
        BinillaWidget.__init__(self)

        sel_index = kwargs.pop('sel_index', -1)
        disabled = kwargs.pop('disabled', False)

        options = kwargs.pop('options', None)
        self.can_scroll = kwargs.pop('can_scroll', self.can_scroll)
        self.option_getter = kwargs.pop('option_getter', None)
        self.callback = kwargs.pop('callback', None)
        self.variable = kwargs.pop('variable', None)
        self.str_variable = kwargs.pop('str_variable', None)
        self.max_index = kwargs.pop('max_index', self.max_index)
        self.max_height = kwargs.pop('max_height', self.max_height)
        self.f_widget_parent = kwargs.pop('f_widget_parent', None)
        self.menu_width = kwargs.pop('menu_width', 0)
        self.options_volatile = kwargs.pop('options_volatile', False)
        self.default_text = kwargs.pop('default_text', e_c.INVALID_OPTION)

        if self.max_height is None:
            self.max_height = self.scroll_menu_max_height

        kwargs.update(relief='sunken',
                      bd=self.listbox_depth,
                      bg=self.default_bg_color)
        tk.Frame.__init__(self, *args, **kwargs)

        if self.variable is None:
            self.variable = tk.IntVar(self, sel_index)

        self.write_trace(self.variable, lambda *a: self.update_label())

        menu_width = self.menu_width if self.menu_width else self.scroll_menu_width
        self.sel_label = tk.Label(self,
                                  bg=self.enum_normal_color,
                                  fg=self.text_normal_color,
                                  bd=2,
                                  relief='groove',
                                  width=max(
                                      min(menu_width,
                                          self.scroll_menu_max_width), 1))
        # the button_frame is to force the button to be a certain size
        self.button_frame = tk.Frame(self,
                                     relief='flat',
                                     height=18,
                                     width=18,
                                     bd=0)
        self.button_frame.pack_propagate(0)
        self.arrow_button = tk.Button(self.button_frame, text="▼", width=2)
        self.arrow_button.font_type = "fixed_small"
        self.arrow_button.pack()
        #self.arrow_button = ttk.Button(self.button_frame, text="▼", width=2)
        #self.arrow_button.grid(row=1, column=1, sticky='news',
        #                       ipadx=0, ipady=0, padx=0, pady=0)
        self.sel_label.pack(side="left", fill="both", expand=True)
        self.button_frame.pack(side="left", fill="both")

        # make the option box to populate
        option_frame_root = self.winfo_toplevel()
        if hasattr(option_frame_root, "root_frame"):
            option_frame_root = option_frame_root.root_frame

        self.option_frame = tk.Frame(option_frame_root,
                                     highlightthickness=0,
                                     bd=0)
        self.option_frame.pack_propagate(0)
        self.option_bar = tk.Scrollbar(self.option_frame, orient="vertical")
        self.option_box = tk.Listbox(
            self.option_frame,
            highlightthickness=0,
            exportselection=False,
            bg=self.enum_normal_color,
            fg=self.text_normal_color,
            selectbackground=self.enum_highlighted_color,
            selectforeground=self.text_highlighted_color,
            yscrollcommand=self.option_bar.set,
            width=menu_width)
        self.option_bar.config(command=self.option_box.yview)

        # make sure the TagWindow knows these widgets are scrollable
        for w in (self.sel_label, self.button_frame, self.arrow_button,
                  self.option_frame, self.option_bar, self.option_box):
            w.can_scroll = self.can_scroll
            w.f_widget_parent = self.f_widget_parent

        # make bindings so arrow keys can be used to navigate the menu
        self.button_frame.bind('<Up>', self.decrement_sel)
        self.button_frame.bind('<Down>', self.increment_sel)
        self.arrow_button.bind('<Up>', self.decrement_sel)
        self.arrow_button.bind('<Down>', self.increment_sel)
        self.option_bar.bind('<Up>', self.decrement_listbox_sel)
        self.option_bar.bind('<Down>', self.increment_listbox_sel)

        if e_c.IS_LNX:
            self.sel_label.bind('<4>', self._mousewheel_scroll)
            self.sel_label.bind('<5>', self._mousewheel_scroll)
            self.button_frame.bind('<4>', self._mousewheel_scroll)
            self.button_frame.bind('<5>', self._mousewheel_scroll)
            self.arrow_button.bind('<4>', self._mousewheel_scroll)
            self.arrow_button.bind('<5>', self._mousewheel_scroll)
        else:
            self.sel_label.bind('<MouseWheel>', self._mousewheel_scroll)
            self.button_frame.bind('<MouseWheel>', self._mousewheel_scroll)
            self.arrow_button.bind('<MouseWheel>', self._mousewheel_scroll)

        self.sel_label.bind('<Button-1>', self.click_label)
        self.arrow_button.bind('<ButtonRelease-1>', self.select_option_box)
        self.arrow_button.bind('<Return>', self.select_option_box)
        self.arrow_button.bind('<space>', self.select_option_box)
        self.option_bar.bind('<FocusOut>', self.deselect_option_box)
        self.option_bar.bind('<Return>', self.select_menu)
        self.option_bar.bind('<space>', self.select_menu)
        self.option_box.bind('<<ListboxSelect>>', self.select_menu)

        self.set_disabled(disabled)

        if options is not None:
            self.set_options(options)

        if self.str_variable is None:
            self.str_variable = tk.StringVar(self, "")
Ejemplo n.º 11
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)