Example #1
0
    def __init__(self, locale, parent = None):
        super(L5RCMCore, self).__init__(parent)
        #print(repr(self))
        self.pc = None

        # Flag to lock advancement refunds in order
        self.lock_advancements = True

        # current locale
        self.locale = locale

        # load data
        self.reload_data()

        # extension loader
        self.extension_loader = HouseRuleLoader()
        self.extension_loader.search_path = osutil.get_user_data_path('.')
    def import_data_pack(self, data_pack_file):
        try:
            dal.dataimport.CM_VERSION = APP_VERSION
            pack = dal.dataimport.DataPack(data_pack_file)
            if not pack.good():
                self.advise_error(self.tr("Invalid data pack."))
            else:
                dest = osutil.get_user_data_path()
                if pack.id == 'core':
                    dest = os.path.join(dest, 'core.data')
                elif pack.language:
                    dest = os.path.join(dest, 'data.' + pack.language)
                else:
                    dest = os.path.join(dest, 'data')

                pack.export_to  (dest)
            return True
        except Exception as e:
            return False
Example #3
0
    def import_data_pack(self, data_pack_file):
        try:
            dal.dataimport.CM_VERSION = APP_VERSION
            pack = dal.dataimport.DataPack(data_pack_file)
            if not pack.good():
                self.advise_error(self.tr("Invalid data pack."))
            else:
                dest = osutil.get_user_data_path()
                if pack.id == 'core':
                    dest = os.path.join(dest, 'core.data')
                elif pack.language:
                    dest = os.path.join(dest, 'data.' + pack.language)
                else:
                    dest = os.path.join(dest, 'data')

                pack.export_to  (dest)
                self.reload_data()
                #self.create_new_character()
                self.advise_successfull_import()
        except Exception as e:
            self.advise_error(self.tr("Cannot import data pack."), e.message)
Example #4
0
    def reload_data(self):
        settings = QtCore.QSettings()
        self.data_pack_blacklist = settings.value('data_pack_blacklist', [])

        # Data storage
        if not self.dstore:
            self.dstore = dal.Data(
                [osutil.get_user_data_path('core.data'),
                 osutil.get_user_data_path('data'),
                 osutil.get_user_data_path('data.' + self.locale)],
                 self.data_pack_blacklist)
        else:
            print('Re-loading datapack data')
            self.dstore.rebuild(
                    [osutil.get_user_data_path('core.data'),
                    osutil.get_user_data_path('data'),
                    osutil.get_user_data_path('data.' + self.locale)],
                    self.data_pack_blacklist)
 def open_data_dir_act(self):
     path = os.path.normpath(osutil.get_user_data_path())
     if not os.path.exists(path):
         os.makedirs(path)
     osutil.portable_open(path)