Commit 3d359917 authored by keyongyu's avatar keyongyu

mse

parent 346dfc10
......@@ -24,16 +24,20 @@ public class DataConfig
public const string TAG_CATEGORY = "category";
public const string TAG_TYPE = "type";
public const string TAG_SETNAME = "setname";
public MSEConfig msecfg;
public DataConfig()
{
InitMember(MyPath.Combine(Application.StartupPath, FILE_INFO));
InitMember(MyPath.Combine(Application.StartupPath, FILE_INFO)
, Application.StartupPath);
}
public DataConfig(string conf)
public DataConfig(string conf, string datapath)
{
InitMember(conf);
InitMember(conf, datapath);
}
public void InitMember(string conf)
public void InitMember(string conf, string datapath)
{
msecfg = new MSEConfig(datapath);
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
if(!File.Exists(conf))
{
......
......@@ -18,6 +18,7 @@ public class DataManager
{
public const string TAG_START = "##";
public const string TAG_END = "#";
public const string SEP_LINE = " ";
#region 根据tag获取内容
static string reReturn(string content)
......@@ -84,11 +85,11 @@ public static string subString(string content, string tag)
{
if (line.StartsWith("#"))
continue;
if ((l = line.IndexOf(" ")) < 0)
if ((l = line.IndexOf(SEP_LINE)) < 0)
continue;
strkey = line.Substring(0, l).Replace("0x", "");
strword = line.Substring(l + 1);
int t = strword.IndexOf('\t');
int t = strword.IndexOf(SEP_LINE);
if (t > 0)
strword = strword.Substring(0, t);
if (line.StartsWith("0x"))
......
......@@ -11,6 +11,7 @@
using System.IO;
using System.Text;
using DataEditorX.Language;
using System.Globalization;
namespace DataEditorX.Config
{
......@@ -39,12 +40,17 @@ public class MSEConfig
public const string TAG_SPELL_TRAP = "spelltrap";
public const string FILE_CONFIG = "mse-config.txt";
public const string FILE_TEMPLATE = "mse-template.txt";
public const string SEP_LINE = " ";
public MSEConfig(string path)
{
Iscn2tw=false;
regx_monster="(\\s\\S*?)";
regx_pendulum="(\\s\\S*?)";
init(path);
}
public void init(string path)
{
Iscn2tw = false;
regx_monster = "(\\s\\S*?)";
regx_pendulum = "(\\s\\S*?)";
string file = MyPath.Combine(path, FILE_TEMPLATE);
if (File.Exists(file))
......@@ -58,51 +64,77 @@ public MSEConfig(string path)
string tmp = MyPath.Combine(path, FILE_CONFIG);
replaces=new List<RegStr>();
if(File.Exists(tmp))
{
string[] lines=File.ReadAllLines(tmp, Encoding.UTF8);
foreach(string line in lines)
{
if(string.IsNullOrEmpty(line) || line.StartsWith("#"))
continue;
if(line.StartsWith("cn2tw"))
Iscn2tw=(getValue(line).ToLower()=="true")?true:false;
else if(line.StartsWith("spell"))
str_spell=getValue(line);
else if(line.StartsWith("trap"))
str_trap=getValue(line);
else if(line.StartsWith("pendulum-text"))
regx_pendulum=getRegex(getValue(line));
else if(line.StartsWith("monster-text"))
regx_monster=getRegex(getValue(line));
else if(line.StartsWith("maxcount"))
int.TryParse(getValue(line),out maxcount);
else if(line.StartsWith("imagepath"))
replaces = new List<RegStr>();
typeDic = new Dictionary<long, string>();
raceDic = new Dictionary<long, string>();
//读取配置
if (File.Exists(tmp))
{
string[] lines = File.ReadAllLines(tmp, Encoding.UTF8);
foreach (string line in lines)
{
if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
continue;
if (line.StartsWith("cn2tw"))
Iscn2tw = (getValue(line).ToLower() == "true") ? true : false;
else if (line.StartsWith("spell"))
str_spell = getValue(line);
else if (line.StartsWith("trap"))
str_trap = getValue(line);
else if (line.StartsWith("pendulum-text"))
regx_pendulum = getRegex(getValue(line));
else if (line.StartsWith("monster-text"))
regx_monster = getRegex(getValue(line));
else if (line.StartsWith("maxcount"))
int.TryParse(getValue(line), out maxcount);
else if (line.StartsWith("imagepath"))
imagepath = MyPath.CheckDir(getValue(line), MyPath.Combine(path, "Images"));
else if(line.StartsWith("replace")){
string word=getValue(line);
int t=word.IndexOf(" ");
if(t>0){
string p=word.Substring(0,t);
string r=word.Substring(t+1);
if(!string.IsNullOrEmpty(p))
replaces.Add(new RegStr(p, r));
}
}
}
if(str_spell=="%%" && str_trap =="%%")
st_is_symbol=true;
else
st_is_symbol=false;
}
else
{
Iscn2tw=false;
}
}
else if (line.StartsWith("replace"))
{
string word = getValue(line);
int t = word.IndexOf(" ");
if (t > 0)
{
string p = word.Substring(0, t);
string r = word.Substring(t + 1);
if (!string.IsNullOrEmpty(p))
replaces.Add(new RegStr(p, r));
}
}
else if (line.StartsWith("race"))
{
DicAdd(raceDic, line);
}
else if (line.StartsWith("type"))
{
DicAdd(typeDic, line);
}
}
if (str_spell == "%%" && str_trap == "%%")
st_is_symbol = true;
else
st_is_symbol = false;
}
else
{
Iscn2tw = false;
}
}
void DicAdd(Dictionary<long,string> dic, string line)
{
int i = line.IndexOf("0x");
int j = (i>0)?line.IndexOf(SEP_LINE, i+1):-1;
if (j > 0)
{
string strkey = line.Substring(i + 2, j - i - 1);
string strval = line.Substring(j + 1);
long key;
long.TryParse(strkey, NumberStyles.HexNumber, null, out key);
if (!dic.ContainsKey(key))
dic.Add(key, strval.Trim());
}
}
string getRegex(string word)
{
return word.Replace("\\n","\n").Replace("\\t","\t");
......@@ -114,18 +146,29 @@ string getValue(string line)
return line.Substring(t+1).Trim();
return "";
}
//每个存档最大数
public int maxcount;
//图片路径
public string imagepath;
//标志是符号
public bool st_is_symbol;
//魔法标志
public string str_spell;
//陷阱标志
public string str_trap;
//简体转繁体?
public bool Iscn2tw;
//特数字替换
public List<RegStr> replaces;
//效果文正则提取
public string regx_pendulum;
public string regx_monster;
//模版
public string head;
public string monster;
public string pendulum;
public string spelltrap;
public Dictionary<long, string> typeDic;
public Dictionary<long, string> raceDic;
}
}
This diff is collapsed.
......@@ -46,12 +46,10 @@ public class TaskHelper
private bool isRun = false;
private BackgroundWorker worker;
public TaskHelper(string datapath, BackgroundWorker worker,
Dictionary<long, string> typedic,
Dictionary<long, string> racedic)
public TaskHelper(string datapath, BackgroundWorker worker, MSEConfig mcfg)
{
this.worker = worker;
mseHelper = new MSE(datapath, typedic, racedic);
mseHelper = new MSE(mcfg);
imgSet.Init();
}
public bool IsRuning()
......
......@@ -33,197 +33,19 @@ public static bool isDataBase(string file)
return true;
return false;
}
public static string GetCardImagePath(string picpath,Card c)
{
string jpg = MyPath.Combine(picpath, c.id + ".jpg");
string jpg2 = MyPath.Combine(picpath, c.idString + ".jpg");
string jpg3 = MyPath.Combine(picpath, c.name + ".jpg");
string png = MyPath.Combine(picpath, c.id + ".png");
string png2 = MyPath.Combine(picpath, c.idString + ".png");
string png3 = MyPath.Combine(picpath, c.name + ".png");
if (File.Exists(jpg))
{
return jpg;
}
else if (File.Exists(jpg2))
{
return jpg2;
}
else if (File.Exists(jpg3))
{
File.Copy(jpg3, jpg, true);
if (File.Exists(jpg))
{//复制失败
return jpg;
}
}
else if (File.Exists(png))
{
return png;
}
else if (File.Exists(png2))
{
return png2;
}
else if (File.Exists(png3))
{
File.Copy(png3, png, true);
if (File.Exists(png))
{//复制失败
return png;
}
}
return "";
}
public static string GetStar(long level)
{
long j = level & 0xff;
string star = "";
for (int i = 0; i < j; i++)
{
star += "*";
}
return star;
}
public static string GetAttributeString(int attr)
{
return DataManager.GetValue(datacfg.dicCardAttributes, attr);
}
public static string GetAttribute(int attr)
{
CardAttribute cattr = (CardAttribute)attr;
string sattr = "none";
switch (cattr)
{
case CardAttribute.ATTRIBUTE_DARK:
sattr = "dark";
break;
case CardAttribute.ATTRIBUTE_DEVINE:
sattr = "divine";
break;
case CardAttribute.ATTRIBUTE_EARTH:
sattr = "earth";
break;
case CardAttribute.ATTRIBUTE_FIRE:
sattr = "fire";
break;
case CardAttribute.ATTRIBUTE_LIGHT:
sattr = "light";
break;
case CardAttribute.ATTRIBUTE_WATER:
sattr = "water";
break;
case CardAttribute.ATTRIBUTE_WIND:
sattr = "wind";
break;
}
return sattr;
}
public static string GetRace(long race)
{
return DataManager.GetValue(datacfg.dicCardRaces, race);
}
public static string[] GetTypes(Card c)
{
string[] types = new string[] { "normal monster", "", "", "" };
if (c.IsType(CardType.TYPE_MONSTER))
{//卡片类型和第1效果
if (c.IsType(CardType.TYPE_XYZ))
{
types[0] = "xyz monster";
types[1] = GetType(CardType.TYPE_XYZ);
}
else if (c.IsType(CardType.TYPE_TOKEN))
{
types[0] = (c.race == 0)?"token card":"token monster";
types[1] = GetType(CardType.TYPE_TOKEN);
}
else if (c.IsType(CardType.TYPE_RITUAL))
{
types[0] = "ritual monster";
types[1] = GetType(CardType.TYPE_RITUAL);
}
else if (c.IsType(CardType.TYPE_FUSION))
{
types[0] = "fusion monster";
types[1] = GetType(CardType.TYPE_FUSION);
}
else if (c.IsType(CardType.TYPE_SYNCHRO))
{
types[0] = "synchro monster";
types[1] = GetType(CardType.TYPE_SYNCHRO);
}
else if (c.IsType(CardType.TYPE_EFFECT))
{
types[0] = "effect monster";
}
else
types[0] = "normal monster";
//同调
if (types[0] == "synchro monster" || types[0] == "token monster")
{
if (c.IsType(CardType.TYPE_TUNER)
&& c.IsType(CardType.TYPE_EFFECT))
{//调整效果
types[2] = GetType(CardType.TYPE_TUNER);
types[3] = GetType(CardType.TYPE_EFFECT);
}
else if (c.IsType(CardType.TYPE_TUNER))
{
types[2] = GetType(CardType.TYPE_TUNER);
}
else if (c.IsType(CardType.TYPE_EFFECT))
{
types[2] = GetType(CardType.TYPE_EFFECT);
}
}
else if (types[0] == "normal monster")
{
if (c.IsType(CardType.TYPE_PENDULUM))//灵摆
types[1] = GetType(CardType.TYPE_PENDULUM);
else if (c.IsType(CardType.TYPE_TUNER))//调整
types[1] = GetType(CardType.TYPE_TUNER);
}
else if (types[0] != "effect monster")
{//效果
if (c.IsType(CardType.TYPE_EFFECT))
types[2] = GetType(CardType.TYPE_EFFECT);
}
else
{//效果怪兽
types[2] = GetType(CardType.TYPE_EFFECT);
if (c.IsType(CardType.TYPE_PENDULUM))
types[1] = GetType(CardType.TYPE_PENDULUM);
else if (c.IsType(CardType.TYPE_TUNER))
types[1] = GetType(CardType.TYPE_TUNER);
else if (c.IsType(CardType.TYPE_SPIRIT))
types[1] = GetType(CardType.TYPE_SPIRIT);
else if (c.IsType(CardType.TYPE_TOON))
types[1] = GetType(CardType.TYPE_TOON);
else if (c.IsType(CardType.TYPE_UNION))
types[1] = GetType(CardType.TYPE_UNION);
else if (c.IsType(CardType.TYPE_DUAL))
types[1] = GetType(CardType.TYPE_DUAL);
else if (c.IsType(CardType.TYPE_FLIP))
types[1] = GetType(CardType.TYPE_FLIP);
else
{
types[1] = GetType(CardType.TYPE_EFFECT);
types[2] = "";
}
}
}
if (c.race == 0)
{
types[1] = "";
types[2] = "";
}
return types;
}
public static string GetCardType(Card c)
{
......@@ -311,16 +133,7 @@ public static string GetSetNameString(long type)
return "";
}
public static string GetDesc(string desc, string regx)
{
desc = desc.Replace(Environment.NewLine, "\n");
Regex regex = new Regex(regx);
Match mc = regex.Match(desc);
if (mc.Success)
return (mc.Groups.Count > 1) ?
mc.Groups[1].Value : mc.Groups[0].Value;
return "";
}
#region 根据文件读取数据库
/// <summary>
......
......@@ -113,9 +113,7 @@ void DataEditFormLoad(object sender, EventArgs e)
{
datacfg = new DataConfig();
}
tasker = new TaskHelper(datapath, bgWorker1,
datacfg.dicCardTypes,
datacfg.dicCardRaces);
tasker = new TaskHelper(datapath, bgWorker1, datacfg.msecfg);
//设置空白卡片
oldCard = new Card(0);
SetCard(oldCard);
......
......@@ -53,7 +53,8 @@ public void SetLanguage(string language)
//文件路径
conflang = MyPath.Combine(datapath, MyConfig.FILE_LANGUAGE);
//游戏数据
datacfg = new DataConfig(MyPath.Combine(datapath, DataConfig.FILE_INFO));
datacfg = new DataConfig(MyPath.Combine(datapath, DataConfig.FILE_INFO)
, datapath);
//初始化YGOUtil的数据
YGOUtil.SetConfig(datacfg);
......
This diff is collapsed.
......@@ -22,4 +22,55 @@ monster-text = [果|介|述|報]】\n([\S\s]*)
########################### Replace
replace = ([鮟|鱇|・|·]) <i>$1</i>
#replace = \s <sym-auto>^</sym-auto>
#replace = ([A-Z]) <i>$1</i>
\ No newline at end of file
#replace = ([A-Z]) <i>$1</i>
##race
race 0x1 战士族
race 0x2 魔法师族
race 0x4 天使族
race 0x8 恶魔族
race 0x10 不死族
race 0x20 机械族
race 0x40 水族
race 0x80 炎族
race 0x100 岩石族
race 0x200 鸟兽族
race 0x400 植物族
race 0x800 昆虫族
race 0x1000 雷族
race 0x2000 龙族
race 0x4000 兽族
race 0x8000 兽战士族
race 0x10000 恐龙族
race 0x20000 鱼族
race 0x40000 海龙族
race 0x80000 爬虫类族
race 0x100000 念动力族
race 0x200000 幻神兽族
race 0x400000 创造神族
race 0x800000 幻龙族
##type
type 0x1 怪兽
type 0x2 魔法
type 0x4 陷阱
type 0x8 N/A
type 0x10 通常
type 0x20 效果
type 0x40 融合
type 0x80 仪式
type 0x100 N/A
type 0x200 灵魂
type 0x400 同盟
type 0x800 二重
type 0x1000 调整
type 0x2000 同调
type 0x4000 衍生物
type 0x8000 N/A
type 0x10000 速攻
type 0x20000 永续
type 0x40000 装备
type 0x80000 场地
type 0x100000 反击
type 0x200000 反转
type 0x400000 卡通
type 0x800000 超量
type 0x1000000 灵摆
\ No newline at end of file
No preview for this file type
This diff is collapsed.
......@@ -22,4 +22,55 @@ monster-text = [果|介|述|報]】\n([\S\s]*)
########################### Replace
replace = ([鮟|鱇|・|·]) <i>$1</i>
#replace = \s <sym-auto>^</sym-auto>
#replace = ([A-Z]) <i>$1</i>
\ No newline at end of file
#replace = ([A-Z]) <i>$1</i>
##race
race 0x1 战士族
race 0x2 魔法师族
race 0x4 天使族
race 0x8 恶魔族
race 0x10 不死族
race 0x20 机械族
race 0x40 水族
race 0x80 炎族
race 0x100 岩石族
race 0x200 鸟兽族
race 0x400 植物族
race 0x800 昆虫族
race 0x1000 雷族
race 0x2000 龙族
race 0x4000 兽族
race 0x8000 兽战士族
race 0x10000 恐龙族
race 0x20000 鱼族
race 0x40000 海龙族
race 0x80000 爬虫类族
race 0x100000 念动力族
race 0x200000 幻神兽族
race 0x400000 创造神族
race 0x800000 幻龙族
##type
type 0x1 怪兽
type 0x2 魔法
type 0x4 陷阱
type 0x8 N/A
type 0x10 通常
type 0x20 效果
type 0x40 融合
type 0x80 仪式
type 0x100 N/A
type 0x200 灵魂
type 0x400 同盟
type 0x800 二重
type 0x1000 调整
type 0x2000 同调
type 0x4000 衍生物
type 0x8000 N/A
type 0x10000 速攻
type 0x20000 永续
type 0x40000 装备
type 0x80000 场地
type 0x100000 反击
type 0x200000 反转
type 0x400000 卡通
type 0x800000 超量
type 0x1000000 灵摆
\ No newline at end of file
mse version: 0.3.8
game: yugioh
stylesheet: standard
set info:
language: TW
edition:
ST mark is text: no
pendulum image is small: yes
\ No newline at end of file
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
type 1: %race%
type 2: %type1%
type 3: %type2%
type 4: %type3%
rule text:
%desc%
attack: %atk%
defense: %def%
gamecode: %code%
\ No newline at end of file
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
rule text:
%desc%
gamecode: %code%
\ No newline at end of file
card:
##head
mse version: 0.3.8
game: yugioh
stylesheet: standard
set info:
language: TW
edition:
ST mark is text: no
pendulum image is small: yes
##monster
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
type 1: %race%
type 2: %type1%
type 3: %type2%
type 4: %type3%
rule text:
%desc%
attack: %atk%
defense: %def%
gamecode: %code%
##pendulum
card:
card type: %type%
name: %name%
attribute: %attribute%
......@@ -17,4 +43,15 @@
pendulum scale 2: %pr%
pendulum text:
%pdesc%
gamecode: %code%
\ No newline at end of file
gamecode: %code%
##spelltrap
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
rule text:
%desc%
gamecode: %code%
#end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment