def updateUI(self):
 
   if not self.current_dir == None:
     chapter, scene, room, mode = common.get_dir_info(self.current_dir)
     
     self.ui.lblChapter.setText(common.chapter_to_text(chapter))
     
     if not scene == -1:
       if chapter == common.CHAPTER_FREETIME:
         self.ui.lblScene.setText("%03d: %s" % (scene, object_labels.get_char_name(scene, common.editor_config.data01_dir)))
       elif chapter == common.CHAPTER_ISLAND and scene >= 701 and scene <= 715:
         scene -= 700
         self.ui.lblScene.setText("%03d: %s" % (scene, object_labels.get_char_name(scene, common.editor_config.data01_dir)))
       else:
         self.ui.lblScene.setText("%03d" % scene)
     else:
       self.ui.lblScene.setText("N/A")
     
     if not room == -1:
       self.ui.lblRoom.setText("%03d: %s" % (room, object_labels.get_map_name(room, common.editor_config.data01_dir)))
     else:
       self.ui.lblRoom.setText("N/A")
     
     self.ui.lblMode.setText(common.mode_to_text(mode))
   
   else:
     self.ui.lblChapter.setText("N/A")
     self.ui.lblScene.setText("N/A")
     self.ui.lblRoom.setText("N/A")
     self.ui.lblMode.setText("N/A")
Beispiel #2
0
    def updateUI(self):

        if not self.current_dir == None:
            chapter, scene, room, mode = common.get_dir_info(self.current_dir)

            self.ui.lblChapter.setText(common.chapter_to_text(chapter))

            if not scene == -1:
                self.ui.lblScene.setText("%03d" % scene)
            else:
                self.ui.lblScene.setText("N/A")

            if not room == -1:
                self.ui.lblRoom.setText("%03d: %s" %
                                        (room, map_names.get_map_name(room)))
            else:
                self.ui.lblRoom.setText("N/A")

            self.ui.lblMode.setText(common.mode_to_text(mode))

        else:
            self.ui.lblChapter.setText("N/A")
            self.ui.lblScene.setText("N/A")
            self.ui.lblRoom.setText("N/A")
            self.ui.lblMode.setText("N/A")
Beispiel #3
0
    def updateUI(self):

        if not self.current_dir == None:
            chapter, scene, room, mode = common.get_dir_info(self.current_dir)

            self.ui.lblChapter.setText(common.chapter_to_text(chapter))

            if not scene == -1:
                if chapter == common.CHAPTER_FREETIME:
                    self.ui.lblScene.setText(
                        "%03d: %s" %
                        (scene,
                         object_labels.get_char_name(
                             scene, common.editor_config.data01_dir)))
                elif chapter == common.CHAPTER_ISLAND and scene >= 701 and scene <= 715:
                    scene -= 700
                    self.ui.lblScene.setText(
                        "%03d: %s" %
                        (scene,
                         object_labels.get_char_name(
                             scene, common.editor_config.data01_dir)))
                else:
                    self.ui.lblScene.setText("%03d" % scene)
            else:
                self.ui.lblScene.setText("N/A")

            if not room == -1:
                self.ui.lblRoom.setText(
                    "%03d: %s" % (room,
                                  object_labels.get_map_name(
                                      room, common.editor_config.data01_dir)))
            else:
                self.ui.lblRoom.setText("N/A")

            self.ui.lblMode.setText(common.mode_to_text(mode))

        else:
            self.ui.lblChapter.setText("N/A")
            self.ui.lblScene.setText("N/A")
            self.ui.lblRoom.setText("N/A")
            self.ui.lblMode.setText("N/A")
 def updateUI(self):
 
   if not self.current_dir == None:
     chapter, scene, room, mode = common.get_dir_info(self.current_dir)
     
     self.ui.lblChapter.setText(common.chapter_to_text(chapter))
     
     if not scene == -1:
       self.ui.lblScene.setText("%03d" % scene)
     else:
       self.ui.lblScene.setText("N/A")
     
     if not room == -1:
       self.ui.lblRoom.setText("%03d: %s" % (room, get_map_name(room)))
     else:
       self.ui.lblRoom.setText("N/A")
     
     self.ui.lblMode.setText(common.mode_to_text(mode))
   
   else:
     self.ui.lblChapter.setText("N/A")
     self.ui.lblScene.setText("N/A")
     self.ui.lblRoom.setText("N/A")
     self.ui.lblMode.setText("N/A")
 def load_dir(self, directory, base_dir = "data01"):
   
   if not directory:
     return
   
   # directory, wrd_file = dir_tools.parse_dir(directory, base_dir)
   # Only expands if necessary.
   full_dir = dir_tools.expand_script_pak(directory)
   full_dir = os.path.join(base_dir, SCRIPT_DIR, full_dir)
   
   if not os.path.isdir(full_dir):
     raise Exception("Directory \"" + directory + "\" not found.")
   
   self.script_files = []
   self.directory    = directory
   self.wrd          = None
   self.wrd_file     = None
   self.py_file      = None
   
   scene_info = []
   wrd_file   = os.path.join(full_dir, os.path.splitext(directory)[0] + ".scp.wrd")
   
   if os.path.isfile(wrd_file):
   
     self.wrd  = WrdFile()
     py_file   = os.path.splitext(wrd_file)[0] + ".py"
     
     if os.path.isfile(py_file):
       try:
         self.wrd.load_python(py_file)
       except:
         _LOGGER.warning("%s failed to load. Parsing wrd file instead. Exception info:\n%s" % (py_file, traceback.format_exc()))
         self.wrd.load_bin(wrd_file)
       else:
         # If we succeeded in loading the python file, compile it to binary.
         # _LOGGER.info("%s loaded successfully. Compiling to binary." % py_file)
         # self.wrd.save_bin(wrd_file)
         _LOGGER.info("%s loaded successfully." % py_file)
     
     else:
       _LOGGER.info("Decompiled wrd file not found. Generating %s" % py_file)
       self.wrd.load_bin(wrd_file)
       self.wrd.save_python(py_file)
     
     scene_info    = self.wrd.to_scene_info()
     self.wrd_file = wrd_file
     self.py_file  = py_file
   
   else:
     scene_info    = None
     self.wrd      = None
     self.wrd_file = None
     self.py_file  = None
   
   self.script_files = []
   if scene_info == None:
     text_files = [filename for filename in os.listdir(full_dir) if os.path.splitext(filename)[1].lower() == ".txt"]
     for filename in text_files:
       self.script_files.append(ScriptFile(os.path.join(full_dir, filename)))
       
   else:
     # Get our files in the order listed by the wrd.
     for info in scene_info:
       if info.file_id == None:
         script_file = ScriptJump(info)
       
       else:
         filename = os.path.join(full_dir, "%04d.txt" % info.file_id)
         script_file = ScriptFile(filename, info)
         
         if script_file.filename == None:
           _LOGGER.warning("File %s referenced by %s does not exist." % (filename, wrd_file))
           continue
       
       self.script_files.append(script_file)
   
   chapter, scene, room, mode = common.get_dir_info(directory)
   
   for file in self.script_files:
     if file.scene_info.chapter == -1: file.scene_info.chapter = chapter
     if file.scene_info.scene == -1:   file.scene_info.scene   = scene
     if file.scene_info.room == -1:    file.scene_info.room    = room
     if file.scene_info.mode == None:  file.scene_info.mode    = mode
    def load_dir(self, directory, umdimage="umdimage"):

        self.script_files = []
        self.directory = directory
        self.wrd = None
        self.wrd_file = None
        self.py_file = None

        base_name = directory
        directory, wrd_file = dir_tools.parse_dir(directory, umdimage)

        if directory == None:
            self.directory = ""
            raise Exception("Directory \"" + base_name + "\" not found.")

        full_dir = os.path.join(umdimage, directory)

        scene_info = []

        if not wrd_file == None and os.path.isfile(wrd_file):

            # Even of the first directory existed and we have a .wrd file,
            # it's possible there aren't actually any text files here.
            if not os.path.isdir(full_dir):
                raise Exception("There are no text files in \"" + directory +
                                "\".")

            self.wrd = WrdFile()

            py_file = os.path.splitext(wrd_file)[0] + ".py"

            if os.path.isfile(py_file):
                try:
                    self.wrd.load_python(py_file)
                except:
                    _LOGGER.warning(
                        "%s failed to load. Parsing wrd file instead. Exception info:\n%s"
                        % (py_file, traceback.format_exc()))
                    self.wrd.load_bin(wrd_file)
                else:
                    # If we succeeded in loading the python file, compile it to binary.
                    # _LOGGER.info("%s loaded successfully. Compiling to binary." % py_file)
                    # self.wrd.save_bin(wrd_file)
                    _LOGGER.info("%s loaded successfully." % py_file)

            else:
                _LOGGER.info("Decompiled wrd file not found. Generating %s" %
                             py_file)
                self.wrd.load_bin(wrd_file)
                self.wrd.save_python(py_file)

            scene_info = self.wrd.to_scene_info()
            self.wrd_file = wrd_file
            self.py_file = py_file

        else:
            scene_info = None
            self.wrd = None
            self.wrd_file = None

        self.script_files = []
        if scene_info == None:
            text_files = list_all_files(full_dir)
            for file in text_files:
                self.script_files.append(ScriptFile(file))

        else:
            # Get our files in the order listed by the wrd.
            for info in scene_info:
                filename = os.path.join(full_dir, "%04d.txt" % info.file_id)
                script_file = ScriptFile(filename, info)

                if script_file.filename == None:
                    _LOGGER.warning(
                        "File %s referenced by %s does not exist." %
                        (filename, wrd_file))
                    continue

                self.script_files.append(script_file)

        chapter, scene, room, mode = common.get_dir_info(base_name)

        for file in self.script_files:
            if file.scene_info.chapter == -1: file.scene_info.chapter = chapter
            if file.scene_info.scene == -1: file.scene_info.scene = scene
            if file.scene_info.room == -1: file.scene_info.room = room
            if file.scene_info.mode == None: file.scene_info.mode = mode
Beispiel #7
0
    def load_dir(self, directory, base_dir="data01"):

        if not directory:
            return

        # directory, wrd_file = dir_tools.parse_dir(directory, base_dir)
        # Only expands if necessary.
        full_dir = dir_tools.expand_script_pak(directory)

        directory1 = normalize(directory)
        match = RE_FONT_PAK.match(directory1)
        if match:
            full_dir = os.path.join(base_dir, SCRIPT_BIN_DIR, full_dir)

    #     if not os.path.isdir(full_dir):
    #       full_dir = os.path.join(base_dir, SCRIPT_BIN_DIR, directory)
        else:
            full_dir = os.path.join(base_dir, SCRIPT_DIR, full_dir)

        if not os.path.isdir(full_dir):
            raise Exception("Directory \"" + full_dir + "\" not found.")

        self.script_files = []
        self.directory = directory
        self.wrd = None
        self.wrd_file = None
        self.py_file = None

        scene_info = []
        wrd_file = os.path.join(full_dir,
                                os.path.splitext(directory)[0] + ".scp.wrd")

        if os.path.isfile(wrd_file):

            self.wrd = WrdFile()
            py_file = os.path.splitext(wrd_file)[0] + ".py"

            if os.path.isfile(py_file):
                try:
                    self.wrd.load_python(py_file)
                except:
                    _LOGGER.warning(
                        "%s failed to load. Parsing wrd file instead. Exception info:\n%s"
                        % (py_file, traceback.format_exc()))
                    self.wrd.load_bin(wrd_file)
                else:
                    # If we succeeded in loading the python file, compile it to binary.
                    # _LOGGER.info("%s loaded successfully. Compiling to binary." % py_file)
                    # self.wrd.save_bin(wrd_file)
                    _LOGGER.info("%s loaded successfully." % py_file)

            else:
                _LOGGER.info("Decompiled wrd file not found. Generating %s" %
                             py_file)
                self.wrd.load_bin(wrd_file)
                self.wrd.save_python(py_file)

            scene_info = self.wrd.to_scene_info()
            self.wrd_file = wrd_file
            self.py_file = py_file

        else:
            scene_info = None
            self.wrd = None
            self.wrd_file = None
            self.py_file = None

        self.script_files = []
        if scene_info == None:
            text_files = [
                filename for filename in os.listdir(full_dir)
                if os.path.splitext(filename)[1].lower() == ".txt"
            ]
            for filename in text_files:
                self.script_files.append(
                    ScriptFile(os.path.join(full_dir, filename)))

        else:
            # Get our files in the order listed by the wrd.
            for info in scene_info:
                if info.file_id == None:
                    script_file = ScriptJump(info)

                else:
                    filename = os.path.join(full_dir,
                                            "%04d.txt" % info.file_id)
                    script_file = ScriptFile(filename, info)

                    if script_file.filename == None:
                        _LOGGER.warning(
                            "File %s referenced by %s does not exist." %
                            (filename, wrd_file))
                        continue

                self.script_files.append(script_file)

        chapter, scene, room, mode = common.get_dir_info(directory)

        for file in self.script_files:
            if file.scene_info.chapter == -1: file.scene_info.chapter = chapter
            if file.scene_info.scene == -1: file.scene_info.scene = scene
            if file.scene_info.room == -1: file.scene_info.room = room
            if file.scene_info.mode == None: file.scene_info.mode = mode