def __init__(self, parent, f, yadodata=False, dataversion=10): base.CWBinaryBase.__init__(self, parent, f, yadodata) self.type = 2 self.fname = self.get_fname() if 10 <= dataversion: # 1.28以降 _w = f.word() # 不明(0) _yadoname = f.string() f.image() # 宿の埋め込み画像は破棄 self.memberslist = [] for member in cw.util.decodetextlist(f.string(True)): if member <> "": self.memberslist.append(util.check_filename(member)) self.name = f.string() self.money = f.dword() # 冒険中の現在値 self.nowadventuring = f.bool() else: # 1.20 self.memberslist = [] for member in cw.util.decodetextlist(f.string(True)): if member <> "": self.memberslist.append(util.check_filename(member)) dataversion_str = f.string() _scenarioname = f.string() # プレイ中のシナリオ名 f.image() # 宿の埋め込み画像は破棄 self.name = "" self.money = 0 self.nowadventuring = f.bool() # 読み込み後に操作 self.cards = [] # データの取得に失敗したカード。変換時に追加する self.errorcards = [] self.data = None
def export_image(self): """内部画像を出力する""" if not hasattr(self, "image"): return "" # 画像保存ディレクトリ if self.xmltype == "Summary": imgdir = self.get_dir() elif self.xmltype == "BeastCard" and self.summoneffect: imgdir = self.get_imgdir() if not imgdir: root = self.get_root() name = util.check_filename(root.name) imgdir = util.join_paths(self.get_dir(), "Material", root.xmltype, name) imgdir = util.check_duplicate(imgdir) self.set_imgdir(imgdir) elif self.xmltype in ("Adventurer", "SkillCard", "ItemCard", "BeastCard", "CastCard"): name = util.check_filename(self.name) imgdir = util.join_paths(self.get_dir(), "Material", self.xmltype, name) imgdir = util.check_duplicate(imgdir) self.set_imgdir(imgdir) else: imgdir = util.join_paths(self.get_dir(), "Material", self.xmltype) # 画像保存 if self.image: # 画像パス if self.xmltype == "Summary": path = util.join_paths(imgdir, self.xmltype + ".bmp") else: name = util.check_filename(self.name) + ".bmp" path = util.join_paths(imgdir, name) # 画像出力 path = util.check_duplicate(path) if not os.path.isdir(imgdir): os.makedirs(imgdir) f = open(path, "wb") f.write(self.image) f.close() # 最後に参照パスを返す path = path.replace(self.get_dir() + "/", "", 1) return util.repl_escapechar(path) else: return ""
def create_xml(self, dpath): """XMLファイルを作成する。 dpath: XMLを作成するディレクトリ """ # 保存ディレクトリ設定 self.set_dir(dpath) # xml文字列取得 xmltext = '<?xml version="1.0" encoding="UTF-8"?>\n' xmltext += self.get_xmltext(0) # xmlファイルパス if self.xmltype in ("Summary", "Environment"): path = util.join_paths(self.get_dir(), self.xmltype + ".xml") else: name = util.check_filename(self.name) + ".xml" # シナリオデータは先頭にidを付与 if not self.is_yadodata(): name = str(self.id).zfill(2) + "_" + name path = util.join_paths(self.get_dir(), self.xmltype, name) # xml出力 path = util.check_duplicate(path) if not os.path.isdir(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) f = open(path, "wb") f.write(xmltext.encode("utf-8")) f.close()
def __init__(self, ydata, dstpath, targetengine): self.ydata = ydata self.targetengine = targetengine self.name = self.ydata.name self.dir = util.join_paths(dstpath, util.check_filename(self.name)) self.dir = util.check_duplicate(self.dir) # progress dialog data self.message = "" self.curnum = 0 self.maxnum = 1 self.maxnum += len(ydata.storehouse) self.maxnum += len(ydata.standbys) self.maxnum += len(ydata.partys) * 2 self.maxnum += len(ydata.album) # エラーログ self.errorlog = ""
def create_fpath(name, ext): fpath = util.join_paths(self.dir, util.check_filename(name) + ext) fpath = util.check_duplicate(fpath) return fpath