Commit 8f7dac84 authored by JoyJ's avatar JoyJ

cleanup and fixes

parent 84ca87cb
......@@ -54,15 +54,15 @@ void InitForm()
this.tooltipDic = new SortedList<string, string>();
this.InitializeComponent();
//设置字体,大小
string fontname = MyConfig.ReadString(MyConfig.TAG_FONT_NAME);
float fontsize = MyConfig.ReadFloat(MyConfig.TAG_FONT_SIZE, this.fctb.Font.Size);
string fontname = DEXConfig.ReadString(DEXConfig.TAG_FONT_NAME);
float fontsize = DEXConfig.ReadFloat(DEXConfig.TAG_FONT_SIZE, this.fctb.Font.Size);
this.fctb.Font = new Font(fontname, fontsize);
if (MyConfig.ReadBoolean(MyConfig.TAG_IME))
if (DEXConfig.ReadBoolean(DEXConfig.TAG_IME))
{
this.fctb.ImeMode = ImeMode.On;
}
if (MyConfig.ReadBoolean(MyConfig.TAG_WORDWRAP))
if (DEXConfig.ReadBoolean(DEXConfig.TAG_WORDWRAP))
{
this.fctb.WordWrap = true;
}
......@@ -71,7 +71,7 @@ void InitForm()
this.fctb.WordWrap = false;
}
if (MyConfig.ReadBoolean(MyConfig.TAG_TAB2SPACES))
if (DEXConfig.ReadBoolean(DEXConfig.TAG_TAB2SPACES))
{
this.tabisspaces = true;
}
......@@ -406,18 +406,6 @@ void Menuitem_showinputClick(object sender, EventArgs e)
this.tb_input.Visible = true;
}
}
//如果是作为mdi,则隐藏菜单
void HideMenu()
{
if (this.MdiParent == null)
{
return;
}
this.mainMenu.Visible = false;
this.menuitem_file.Visible = false;
this.menuitem_file.Enabled = false;
}
void CodeEditFormLoad(object sender, EventArgs e)
{
......@@ -472,7 +460,7 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.Enter)
{
string key = this.tb_input.Text;
List<AutocompleteItem> list =new List<AutocompleteItem>();
List<AutocompleteItem> list = new List<AutocompleteItem>();
foreach (AutocompleteItem item in this.items)
{
if (item.ToolTipText.Contains(key))
......@@ -619,8 +607,8 @@ private void menuitem_testlua_Click(object sender, EventArgs e)
{
return;
}
string cCode = fn.Substring(0,fn.Length - 4);
bool error=false;
string cCode = fn.Substring(0, fn.Length - 4);
bool error = false;
try
{
Directory.SetCurrentDirectory(fi.DirectoryName);
......@@ -683,8 +671,8 @@ private void OnDragDtop(object sender, DragEventArgs e)
private void menuitem_tooltipFont_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
string fontJson = MyConfig.ReadString(MyConfig.TOOLTIP_FONT);
Font f = new Font("微软雅黑",10);
string fontJson = DEXConfig.ReadString(DEXConfig.TOOLTIP_FONT);
Font f = new Font("微软雅黑", 10);
JavaScriptSerializer jss = new JavaScriptSerializer();
try
{
......@@ -694,7 +682,7 @@ private void menuitem_tooltipFont_Click(object sender, EventArgs e)
fd.Font = f;
if (fd.ShowDialog() == DialogResult.OK)
{
Common.XMLReader.Save(MyConfig.TOOLTIP_FONT, jss.Serialize(fd.Font));
Common.XMLReader.Save(DEXConfig.TOOLTIP_FONT, jss.Serialize(fd.Font));
this.fctb.lbTooltip.Font = fd.Font;
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -125,7 +125,7 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality = 90)
{
if (bitmap != null)
{
string path=Path.GetDirectoryName(filename);
string path = Path.GetDirectoryName(filename);
if (!Directory.Exists(path))//创建文件夹
{
Directory.CreateDirectory(path);
......
......@@ -196,7 +196,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
/// <param name="_comment">Comment for stored file</param>
public void AddFile(string _pathname, string _filenameInZip, string _comment)
{
Compression _method=Compression.Deflate;
Compression _method = Compression.Deflate;
if (this.access == FileAccess.Read)
{
throw new InvalidOperationException("Writing is not alowed");
......@@ -244,7 +244,7 @@ public void AddStream(Compression _method, string _filenameInZip, Stream _source
}
else
{
ZipFileEntry last = this.files[this.files.Count-1];
ZipFileEntry last = this.files[this.files.Count - 1];
_ = last.HeaderOffset + last.HeaderSize;
}
......@@ -345,7 +345,7 @@ public List<ZipFileEntry> ReadCentralDir()
ushort extraSize = BitConverter.ToUInt16(this.centralDirImage, pointer + 30);
ushort commentSize = BitConverter.ToUInt16(this.centralDirImage, pointer + 32);
uint headerOffset = BitConverter.ToUInt32(this.centralDirImage, pointer + 42);
uint headerSize = (uint)( 46 + filenameSize + extraSize + commentSize);
uint headerSize = (uint)(46 + filenameSize + extraSize + commentSize);
Encoding encoder = encodeUTF8 ? Encoding.UTF8 : _defaultEncoding;
......
......@@ -11,14 +11,14 @@ namespace DataEditorX.Config
/// <summary>
/// 配置
/// </summary>
public class MyConfig : XMLReader
public class DEXConfig : XMLReader
{
#region 常量
public const string TAG_SAVE_LAGN = "-savelanguage";
public const string TAG_SAVE_LAGN2 = "-sl";
public const string TAG_MSE_PATH="mse_path";
public const string TAG_MSE_EXPORT="mse_exprotpath";
public const string TAG_AUTO_LEN ="autolength";
public const string TAG_MSE_PATH = "mse_path";
public const string TAG_MSE_EXPORT = "mse_exprotpath";
public const string TAG_AUTO_LEN = "autolength";
/// <summary>
/// 窗口消息 打开文件
/// </summary>
......@@ -268,7 +268,7 @@ public static Area ReadArea(string key)
/// <returns></returns>
public static bool ReadBoolean(string key, bool def = false)
{
string val= ReadString(key);
string val = ReadString(key);
if ("true".Equals(val, StringComparison.OrdinalIgnoreCase))
{
return true;
......
......@@ -18,7 +18,7 @@ public class DataConfig
{
public DataConfig()
{
this.InitMember(MyPath.Combine(Application.StartupPath, MyConfig.TAG_CARDINFO + ".txt"));
this.InitMember(MyPath.Combine(Application.StartupPath, DEXConfig.TAG_CARDINFO + ".txt"));
}
public DataConfig(string conf)
{
......@@ -45,14 +45,14 @@ public void InitMember(string conf)
}
//提取内容
string text = File.ReadAllText(conf);
this.dicCardRules = DataManager.Read(text, MyConfig.TAG_RULE);
this.dicSetnames = DataManager.Read(text, MyConfig.TAG_SETNAME);
this.dicCardTypes = DataManager.Read(text, MyConfig.TAG_TYPE);
this.dicLinkMarkers = DataManager.Read(text, MyConfig.TAG_MARKER);
this.dicCardcategorys = DataManager.Read(text, MyConfig.TAG_CATEGORY);
this.dicCardAttributes = DataManager.Read(text, MyConfig.TAG_ATTRIBUTE);
this.dicCardRaces = DataManager.Read(text, MyConfig.TAG_RACE);
this.dicCardLevels = DataManager.Read(text, MyConfig.TAG_LEVEL);
this.dicCardRules = DataManager.Read(text, DEXConfig.TAG_RULE);
this.dicSetnames = DataManager.Read(text, DEXConfig.TAG_SETNAME);
this.dicCardTypes = DataManager.Read(text, DEXConfig.TAG_TYPE);
this.dicLinkMarkers = DataManager.Read(text, DEXConfig.TAG_MARKER);
this.dicCardcategorys = DataManager.Read(text, DEXConfig.TAG_CATEGORY);
this.dicCardAttributes = DataManager.Read(text, DEXConfig.TAG_ATTRIBUTE);
this.dicCardRaces = DataManager.Read(text, DEXConfig.TAG_RACE);
this.dicCardLevels = DataManager.Read(text, DEXConfig.TAG_LEVEL);
}
/// <summary>
......
......@@ -21,20 +21,20 @@ public ImageSet()
//初始化
void Init()
{
this.normalArea = MyConfig.ReadArea(MyConfig.TAG_IMAGE_OTHER);
this.normalArea = DEXConfig.ReadArea(DEXConfig.TAG_IMAGE_OTHER);
this.xyzArea = MyConfig.ReadArea(MyConfig.TAG_IMAGE_XYZ);
this.xyzArea = DEXConfig.ReadArea(DEXConfig.TAG_IMAGE_XYZ);
this.pendulumArea = MyConfig.ReadArea(MyConfig.TAG_IMAGE_PENDULUM);
this.pendulumArea = DEXConfig.ReadArea(DEXConfig.TAG_IMAGE_PENDULUM);
int[] ints = MyConfig.ReadIntegers(MyConfig.TAG_IMAGE_SIZE, 4);
int[] ints = DEXConfig.ReadIntegers(DEXConfig.TAG_IMAGE_SIZE, 4);
this.w = ints[0];
this.h = ints[1];
this.W = ints[2];
this.H = ints[3];
this.quilty = MyConfig.ReadInteger(MyConfig.TAG_IMAGE_QUILTY, 95);
this.quilty = DEXConfig.ReadInteger(DEXConfig.TAG_IMAGE_QUILTY, 95);
}
/// <summary>
/// jpeg质量
......
......@@ -7,7 +7,6 @@
*/
using System;
using System.Drawing;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace FastColoredTextBoxNS
......
......@@ -57,7 +57,7 @@ void AddHistorys(string[] lines)
{
if (YGOUtil.IsScript(line))
{
if (this.luahistory.Count < MyConfig.MAX_HISTORY
if (this.luahistory.Count < DEXConfig.MAX_HISTORY
&& this.luahistory.IndexOf(line) < 0)
{
this.luahistory.Add(line);
......@@ -65,7 +65,7 @@ void AddHistorys(string[] lines)
}
else
{
if (this.cdbhistory.Count < MyConfig.MAX_HISTORY
if (this.cdbhistory.Count < DEXConfig.MAX_HISTORY
&& this.cdbhistory.IndexOf(line) < 0)
{
this.cdbhistory.Add(line);
......
......@@ -222,7 +222,7 @@ public bool EqualsData(Card other)
/// <returns>结果</returns>
public bool Equals(Card other)
{
bool equalBool=this.EqualsData(other);
bool equalBool = this.EqualsData(other);
if (!equalBool)
{
return false;
......
......@@ -334,7 +334,7 @@ public bool OpenScript(bool openinthis, string addrequire)
{
if (openinthis)//是否用本程序打开
{
MyConfig.OpenFileInThis(lua);
DEXConfig.OpenFileInThis(lua);
}
else
{
......
......@@ -185,8 +185,8 @@ public static Card[] Read(string DB, bool reNewLine, params long[] ids)
/// <param name="SQLs">SQL/密码语句集合集合</param>
public static Card[] Read(string DB, bool reNewLine, params string[] SQLs)
{
List<Card> list=new List<Card>();
List<long> idlist=new List<long>();
List<Card> list = new List<Card>();
List<long> idlist = new List<long>();
if (File.Exists(DB) && SQLs != null)
{
using (SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + DB))
......@@ -227,7 +227,7 @@ public static Card[] Read(string DB, bool reNewLine, params string[] SQLs)
{
while (reader.Read())
{
Card c=ReadCard(reader,reNewLine);
Card c = ReadCard(reader, reNewLine);
if (idlist.IndexOf(c.id) < 0)
{//不存在,则添加
idlist.Add(c.id);
......@@ -346,7 +346,7 @@ static string toInt(long l)
}
public static string GetSelectSQL(Card c)
{
StringBuilder sb=new StringBuilder();
StringBuilder sb = new StringBuilder();
sb.Append("SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ");
if (c == null)
{
......@@ -592,7 +592,7 @@ public static void ExportSql(string file, params Card[] cards)
public static CardPack FindPack(string db, long id)
{
CardPack cardpack=null;
CardPack cardpack = null;
if (File.Exists(db) && id >= 0)
{
using (SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + db))
......
......@@ -20,7 +20,7 @@ public static class CardLink
0x40 ↖
0x80 ↑
0x100 ↗*/
public const int DownLeft=0x1;
public const int DownLeft = 0x1;
public const int Down = 0x2;
public const int DownRight = 0x4;
public const int Left = 0x8;
......
......@@ -6,7 +6,7 @@ public enum CardRule : int
/// <summary>无</summary>
NONE = 0,
/// <summary>OCG</summary>
OCG =1,
OCG = 1,
/// <summary>TCG</summary>
TCG = 2,
/// <summary>OT</summary>
......
......@@ -15,58 +15,58 @@ namespace DataEditorX.Core.Info
public enum CardType : long
{
///<summary>怪兽卡</summary>
TYPE_MONSTER =0x1,
TYPE_MONSTER = 0x1,
///<summary>魔法卡</summary>
TYPE_SPELL =0x2,
TYPE_SPELL = 0x2,
///<summary>陷阱卡</summary>
TYPE_TRAP =0x4,
TYPE_TRAP = 0x4,
///<summary>通常</summary>
TYPE_NORMAL =0x10,
TYPE_NORMAL = 0x10,
///<summary>效果</summary>
TYPE_EFFECT =0x20,
TYPE_EFFECT = 0x20,
///<summary>融合</summary>
TYPE_FUSION =0x40,
TYPE_FUSION = 0x40,
///<summary>仪式</summary>
TYPE_RITUAL =0x80,
TYPE_RITUAL = 0x80,
///<summary>陷阱怪兽</summary>
TYPE_TRAPMONSTER =0x100,
TYPE_TRAPMONSTER = 0x100,
///<summary>灵魂</summary>
TYPE_SPIRIT =0x200,
TYPE_SPIRIT = 0x200,
///<summary>同盟</summary>
TYPE_UNION =0x400,
TYPE_UNION = 0x400,
///<summary>二重</summary>
TYPE_DUAL =0x800,
TYPE_DUAL = 0x800,
///<summary>调整</summary>
TYPE_TUNER =0x1000,
TYPE_TUNER = 0x1000,
///<summary>同调</summary>
TYPE_SYNCHRO =0x2000,
TYPE_SYNCHRO = 0x2000,
///<summary>衍生物</summary>
TYPE_TOKEN =0x4000,
TYPE_TOKEN = 0x4000,
///<summary>速攻</summary>
TYPE_QUICKPLAY =0x10000,
TYPE_QUICKPLAY = 0x10000,
///<summary>永续</summary>
TYPE_CONTINUOUS =0x20000,
TYPE_CONTINUOUS = 0x20000,
///<summary>装备</summary>
TYPE_EQUIP =0x40000,
TYPE_EQUIP = 0x40000,
///<summary>场地</summary>
TYPE_FIELD =0x80000,
TYPE_FIELD = 0x80000,
///<summary>反击</summary>
TYPE_COUNTER =0x100000,
TYPE_COUNTER = 0x100000,
///<summary>反转</summary>
TYPE_FLIP =0x200000,
TYPE_FLIP = 0x200000,
///<summary>卡通</summary>
TYPE_TOON =0x400000,
TYPE_TOON = 0x400000,
///<summary>超量</summary>
TYPE_XYZ =0x800000,
TYPE_XYZ = 0x800000,
///<summary>灵摆</summary>
TYPE_PENDULUM =0x1000000,
TYPE_PENDULUM = 0x1000000,
///<summary>特殊召唤</summary>
TYPE_SPSUMMON =0x2000000,
TYPE_SPSUMMON = 0x2000000,
///<summary>连接</summary>
TYPE_LINK =0x4000000,
TYPE_LINK = 0x4000000,
}
public static class CardTypes
......@@ -160,7 +160,7 @@ public static class CardTypes
public static CardType[] GetMonsterTypes(long type, bool no10 = false)
{
var list = new List<CardType>(5);
var typeList=new List<CardType[]>(5);
var typeList = new List<CardType[]>(5);
if (no10)
{
typeList.Add(TYPE1_10);
......
......@@ -33,7 +33,7 @@ static void Log(string str)
static string _oldfun;
static string _logtxt;
static string _funclisttxt;
static readonly SortedList<string,string> _funclist=new SortedList<string,string>();
static readonly SortedList<string, string> _funclist = new SortedList<string, string>();
//读取旧函数
public static void Read(string funtxt)
{
......@@ -41,10 +41,10 @@ public static void Read(string funtxt)
_oldfun = funtxt;
if (File.Exists(funtxt))
{
string[] lines=File.ReadAllLines(funtxt);
bool isFind=false;
string name="";
string desc="";
string[] lines = File.ReadAllLines(funtxt);
bool isFind = false;
string name = "";
string desc = "";
foreach (string line in lines)
{
if (string.IsNullOrEmpty(line)
......@@ -58,8 +58,8 @@ public static void Read(string funtxt)
{
//添加之前的函数
AddOldFun(name, desc);
int w=line.IndexOf("(");
int t=line.IndexOf(" ");
int w = line.IndexOf("(");
int t = line.IndexOf(" ");
//获取当前名字
if (t < w && t > 0)
{
......@@ -101,9 +101,9 @@ static void AddOldFun(string name, string desc)
/// <returns></returns>
public static bool Find(string path)
{
string name="interpreter.cpp";
string file=Path.Combine(path,name);
string file2=Path.Combine(Path.Combine(path, "ocgcore"), name);
string name = "interpreter.cpp";
string file = Path.Combine(path, name);
string file2 = Path.Combine(Path.Combine(path, "ocgcore"), name);
_logtxt = Path.Combine(path, "find_functions.log");
ResetLog();
_funclisttxt = Path.Combine(path, "_functions.txt");
......@@ -122,16 +122,16 @@ public static bool Find(string path)
return false;
}
}
string texts=File.ReadAllText(file);
Regex libRex=new Regex(@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
,RegexOptions.Multiline);
MatchCollection libsMatch=libRex.Matches(texts);
string texts = File.ReadAllText(file);
Regex libRex = new Regex(@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
, RegexOptions.Multiline);
MatchCollection libsMatch = libRex.Matches(texts);
Log("log:count " + libsMatch.Count.ToString());
foreach (Match m in libsMatch)//获取lib函数库
{
if (m.Groups.Count > 2)
{
string word=m.Groups[1].Value;
string word = m.Groups[1].Value;
Log("log:find " + word);
//分别去获取函数库的函数
GetFunctions(word, m.Groups[2].Value,
......@@ -172,16 +172,16 @@ static string ToTitle(string str)
//获取函数库的lua函数名,和对应的c++函数
static Dictionary<string, string> GetFunctionNames(string texts, string name)
{
Dictionary<string,string> dic=new Dictionary<string, string>();
Regex funcRex=new Regex("\"(\\S*?)\",\\s*?(\\S*?::\\S*?)\\s");
MatchCollection funcsMatch=funcRex.Matches(texts);
Dictionary<string, string> dic = new Dictionary<string, string>();
Regex funcRex = new Regex("\"(\\S*?)\",\\s*?(\\S*?::\\S*?)\\s");
MatchCollection funcsMatch = funcRex.Matches(texts);
Log("log: functions count " + name + ":" + funcsMatch.Count.ToString());
foreach (Match m in funcsMatch)
{
if (m.Groups.Count > 2)
{
string k=ToTitle(name)+"."+m.Groups[1].Value;
string v=m.Groups[2].Value;
string k = ToTitle(name) + "." + m.Groups[1].Value;
string v = m.Groups[2].Value;
if (!dic.ContainsKey(k))
{
dic.Add(k, v);
......@@ -196,10 +196,10 @@ static string ToTitle(string str)
//查找c++代码
static string FindCode(string texts, string name)
{
Regex reg=new Regex(@"int32\s+?"+name
+@"[\s\S]+?\{([\s\S]*?^)\}",
Regex reg = new Regex(@"int32\s+?" + name
+ @"[\s\S]+?\{([\s\S]*?^)\}",
RegexOptions.Multiline);
Match mc=reg.Match(texts);
Match mc = reg.Match(texts);
if (mc.Success)
{
if (mc.Groups.Count > 1)
......@@ -218,7 +218,7 @@ static string FindCode(string texts, string name)
//查找返回类型
static string FindReturn(string texts)
{
string restr="";
string restr = "";
if (texts.IndexOf("lua_pushboolean") >= 0)
{
return "bool ";
......@@ -292,14 +292,14 @@ static string getUserType(string str)
static void AddArgs(string texts, string regx, string arg, SortedList<int, string> dic)
{
//function
Regex reg=new Regex(regx);
MatchCollection mcs=reg.Matches(texts);
Regex reg = new Regex(regx);
MatchCollection mcs = reg.Matches(texts);
foreach (Match m in mcs)
{
if (m.Groups.Count > 1)
{
string v=arg;
int k=int.Parse(m.Groups[1].Value);
string v = arg;
int k = int.Parse(m.Groups[1].Value);
if (dic.ContainsKey(k))
{
dic[k] = dic[k] + "|" + v;
......@@ -313,17 +313,17 @@ static void AddArgs(string texts, string regx, string arg, SortedList<int, strin
}
static string FindArgs(string texts)
{
SortedList<int,string> dic=new SortedList<int, string>();
SortedList<int, string> dic = new SortedList<int, string>();
//card effect ggroup
Regex reg=new Regex(@"\((\S+?)\)\s+?lua_touserdata\(L,\s+(\d+)\)");
MatchCollection mcs=reg.Matches(texts);
Regex reg = new Regex(@"\((\S+?)\)\s+?lua_touserdata\(L,\s+(\d+)\)");
MatchCollection mcs = reg.Matches(texts);
foreach (Match m in mcs)
{
if (m.Groups.Count > 2)
{
string v=m.Groups[1].Value.ToLower();
string v = m.Groups[1].Value.ToLower();
v = getUserType(v);
int k=int.Parse(m.Groups[2].Value);
int k = int.Parse(m.Groups[2].Value);
if (dic.ContainsKey(k))
{
dic[k] = dic[k] + "|" + v;
......@@ -345,7 +345,7 @@ static string FindArgs(string texts)
//bool
AddArgs(texts, @"lua_toboolean\(L,\s+(\d+)\)", "boolean", dic);
string args="(";
string args = "(";
foreach (int i in dic.Keys)
{
args += dic[i] + ", ";
......@@ -382,9 +382,9 @@ public static void GetFunctions(string name, string texts, string file)
Log("error:no find file " + file);
return;
}
string cpps=File.ReadAllText(file);
string cpps = File.ReadAllText(file);
//lua name /cpp name
Dictionary<string,string> fun=GetFunctionNames(texts,name);
Dictionary<string, string> fun = GetFunctionNames(texts, name);
if (fun == null || fun.Count == 0)
{
Log("warning: no find functions of " + name);
......@@ -396,18 +396,18 @@ public static void GetFunctions(string name, string texts, string file)
FileMode.Create,
FileAccess.Write))
{
StreamWriter sw=new StreamWriter(fs, Encoding.UTF8);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine("========== " + name + " ==========");
File.AppendAllText(_funclisttxt, "========== " + name + " ==========" + Environment.NewLine);
foreach (string k in fun.Keys)
{
string v=fun[k];
string code=FindCode(cpps, v);
string txt="●"+FindReturn(code)+k+FindArgs(code)
+Environment.NewLine
+FindOldDesc(k)
+Environment.NewLine
+code;
string v = fun[k];
string code = FindCode(cpps, v);
string txt = "●" + FindReturn(code) + k + FindArgs(code)
+ Environment.NewLine
+ FindOldDesc(k)
+ Environment.NewLine
+ code;
sw.WriteLine(txt);
File.AppendAllText(_funclisttxt, txt + Environment.NewLine);
......
......@@ -36,7 +36,7 @@ public string GetMseRarity()
return "common";
}
string rarity=this.rarity.Trim().ToLower();
string rarity = this.rarity.Trim().ToLower();
if (rarity.Equals("common") || rarity.Equals("short print"))
{
return "common";
......
......@@ -35,12 +35,12 @@ public class MSEConfig
public const string TAG_MAXCOUNT = "maxcount";
public const string TAG_RACE = "race";
public const string TAG_TYPE = "type";
public const string TAG_WIDTH="width";
public const string TAG_HEIGHT="height";
public const string TAG_WIDTH = "width";
public const string TAG_HEIGHT = "height";
public const string TAG_REIMAGE="reimage";
public const string TAG_PEND_WIDTH="pwidth";
public const string TAG_PEND_HEIGHT="pheight";
public const string TAG_REIMAGE = "reimage";
public const string TAG_PEND_WIDTH = "pwidth";
public const string TAG_PEND_HEIGHT = "pheight";
public const string TAG_IMAGE = "imagepath";
public const string TAG_REPALCE = "replace";
......@@ -48,7 +48,7 @@ public class MSEConfig
public const string TAG_NO_TEN = "no10";
public const string TAG_NO_START_CARDS="no_star_cards";
public const string TAG_NO_START_CARDS = "no_star_cards";
public const string TAG_REP = "%%";
public const string SEP_LINE = " ";
......@@ -146,7 +146,7 @@ public void SetConfig(string config, string path)
string val = ConfHelper.GetValue(line);
string[] cs = val.Split(',');
this.noStartCards = new long[cs.Length];
int i=0;
int i = 0;
foreach (string str in cs)
{
long.TryParse(str, out long l);
......@@ -190,7 +190,7 @@ public void Init(string path)
this.Iscn2tw = false;
//读取配置
string tmp = MyPath.Combine(path, MyPath.GetFileName(TAG, MyConfig.ReadString(MyConfig.TAG_MSE)));
string tmp = MyPath.Combine(path, MyPath.GetFileName(TAG, DEXConfig.ReadString(DEXConfig.TAG_MSE)));
if (!File.Exists(tmp))
{
......
......@@ -305,8 +305,8 @@ public string GetType(CardType ctype)
public string[] GetTypes(Card c)
{
//卡片类型,效果1,效果2,效果3
int MAX_TYPE= 5;
var types = new string[MAX_TYPE+1];
int MAX_TYPE = 5;
var types = new string[MAX_TYPE + 1];
types[0] = MseCardType.CARD_NORMAL;
for (int i = 1; i < types.Length; i++)
{
......@@ -393,7 +393,7 @@ public string[] GetTypes(Card c)
list.Add(c, jpg);
jpg = Path.GetFileName(jpg);
}
CardPack cardpack=DataBase.FindPack(cardpack_db, c.id);
CardPack cardpack = DataBase.FindPack(cardpack_db, c.id);
if (c.IsType(CardType.TYPE_SPELL) || c.IsType(CardType.TYPE_TRAP))
{
sw.WriteLine(this.getSpellTrap(c, jpg, c.IsType(CardType.TYPE_SPELL), cardpack, rarity));
......@@ -412,7 +412,7 @@ public string[] GetTypes(Card c)
int getLinkNumber(long link)
{
string str = Convert.ToString(link, 2);
char[] cs = str.ToCharArray();
char[] cs = str.ToCharArray();
int i = 0;
foreach (char c in cs)
{
......@@ -911,7 +911,7 @@ public string GetImageCache(string img, Card card)
return img;
}
}
string md5=MyUtils.GetMD5HashFromFile(img);
string md5 = MyUtils.GetMD5HashFromFile(img);
if (MyUtils.Md5isEmpty(md5) || this.cfg.imagecache == null)
{
//md5为空
......@@ -921,7 +921,7 @@ public string GetImageCache(string img, Card card)
if (!File.Exists(file))
{
//生成缓存
Bitmap bmp=MyBitmap.ReadImage(img);
Bitmap bmp = MyBitmap.ReadImage(img);
//缩放
if (isPendulum)
{
......@@ -943,15 +943,15 @@ public string GetImageCache(string img, Card card)
static EventHandler _exitHandler;
private static void exportSetThread(object obj)
{
string[] args=(string[])obj;
string[] args = (string[])obj;
if (args == null || args.Length < 3)
{
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return;
}
string mse_path=args[0];
string setfile=args[1];
string path=args[2];
string mse_path = args[0];
string setfile = args[1];
string path = args[2];
if (string.IsNullOrEmpty(mse_path) || string.IsNullOrEmpty(setfile))
{
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
......@@ -959,7 +959,7 @@ private static void exportSetThread(object obj)
}
else
{
string cmd=" --export "+setfile.Replace("\\\\","\\").Replace("\\","/")+" {card.gamecode}.png";
string cmd = " --export " + setfile.Replace("\\\\", "\\").Replace("\\", "/") + " {card.gamecode}.png";
_mseProcess = new System.Diagnostics.Process();
_mseProcess.StartInfo.FileName = mse_path;
_mseProcess.StartInfo.Arguments = cmd;
......
......@@ -30,7 +30,7 @@ public class CardInfo
public int icon;
public string description;
public string pendulum_description;
public int[] pendulum_scales ;
public int[] pendulum_scales;
public string[] subtypes;
public string atk;
public string def;
......@@ -57,7 +57,7 @@ public static void Test()
CardSet cardset = JsonConvert.DeserializeObject<CardSet>(json);
if (cardset.cards != null)
{
int index=0;
int index = 0;
foreach (string key in cardset.cards.Keys)
{
Console.WriteLine(key);
......
......@@ -133,7 +133,7 @@ public void ToImg(string img, string saveimg1)
#region 检查更新
public static void CheckVersion(bool showNew)
{
string newver = CheckUpdate.GetNewVersion(MyConfig.ReadString(MyConfig.TAG_UPDATE_URL));
string newver = CheckUpdate.GetNewVersion(DEXConfig.ReadString(DEXConfig.TAG_UPDATE_URL));
if (newver == CheckUpdate.DEFAULT)
{ //检查失败
if (!showNew)
......@@ -284,8 +284,8 @@ public void SaveMSEs(string file, Card[] cards, bool isUpdate)
return;
}
string pack_db=MyPath.GetRealPath(MyConfig.ReadString("pack_db"));
bool rarity=MyConfig.ReadBoolean("mse_auto_rarity", false);
string pack_db = MyPath.GetRealPath(DEXConfig.ReadString("pack_db"));
bool rarity = DEXConfig.ReadBoolean("mse_auto_rarity", false);
#if DEBUG
MessageBox.Show("db = " + pack_db + ",auto rarity=" + rarity);
#endif
......@@ -325,7 +325,7 @@ public void SaveMSEs(string file, Card[] cards, bool isUpdate)
public void SaveMSE(int num, string file, Card[] cards, string pack_db, bool rarity, bool isUpdate)
{
string setFile = file + ".txt";
Dictionary<Card, string> images = this.mseHelper.WriteSet(setFile, cards,pack_db,rarity);
Dictionary<Card, string> images = this.mseHelper.WriteSet(setFile, cards, pack_db, rarity);
if (isUpdate)//仅更新文字
{
return;
......@@ -339,7 +339,7 @@ public void SaveMSE(int num, string file, Card[] cards, string pack_db, bool rar
zips.AddFile(setFile, "set", "");
foreach (Card c in images.Keys)
{
string img=images[c];
string img = images[c];
if (this.isCancel)
{
break;
......
This diff is collapsed.
......@@ -45,8 +45,8 @@ private void EffectCreatorForm_Load(object sender, EventArgs e)
{
return;
}
char[] sepChars = new char[]{' ','\t',' '};
FileStream fs = new FileStream(config,FileMode.Open);
char[] sepChars = new char[] { ' ', '\t', ' ' };
FileStream fs = new FileStream(config, FileMode.Open);
StreamReader sr = new StreamReader(fs);
string nowType = "";
for (string line = sr.ReadLine(); line != null; line = sr.ReadLine())
......@@ -65,7 +65,7 @@ private void EffectCreatorForm_Load(object sender, EventArgs e)
{
continue;
}
string[] split = line.Split(sepChars,StringSplitOptions.RemoveEmptyEntries);
string[] split = line.Split(sepChars, StringSplitOptions.RemoveEmptyEntries);
if (split.Length == 2)
{
itemDic[nowType].Add(new EffectCreatorItem(split[0], split[1]));
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DataEditorX
......
......@@ -51,11 +51,11 @@ public enum LMSG : uint
ydkType = 0x22,
Setcode_error = 0x23,
SelectImage = 0x24,
ImageType =0x25,
ImageType = 0x25,
RunError = 0x26,
checkUpdate = 0x27,
CopyCardsToDB = 0x28,
CopyCardsToDBIsOK =0x29,
CopyCardsToDBIsOK = 0x29,
selectMseset = 0x2a,
MseType = 0x2b,
SaveMse = 0x2c,
......@@ -83,10 +83,10 @@ public enum LMSG : uint
CheckText = 0x40,
CompareOK = 0x41,
OpenFile = 0x42,
ScriptFilter =0x43,
ScriptFilter = 0x43,
NewFile = 0x44,
SaveFileOK = 0x45,
IfSaveScript =0x46,
IfSaveScript = 0x46,
ReadMSE = 0x47,
ReadMSEisOK = 0x48,
......
......@@ -78,6 +78,8 @@ private void InitializeComponent()
this.dockPanel.Size = new System.Drawing.Size(992, 725);
this.dockPanel.TabIndex = 0;
this.dockPanel.Theme = this.theme;
this.dockPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.dockPanel_DragDrop);
this.dockPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.dockPanel_DragEnter);
//
// mainMenu
//
......@@ -277,6 +279,7 @@ private void InitializeComponent()
//
// MainForm
//
this.AllowDrop = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(992, 749);
......
......@@ -54,7 +54,7 @@ public void SetDataPath(string datapath)
this.tCards = null;
//数据目录
this.datapath = datapath;
if (MyConfig.ReadBoolean(MyConfig.TAG_ASYNC))
if (DEXConfig.ReadBoolean(DEXConfig.TAG_ASYNC))
{
//后台加载数据
this.bgWorker1.RunWorkerAsync();
......@@ -76,16 +76,16 @@ public void SetOpenFile(string file)
void Init()
{
//文件路径
this.conflang = MyConfig.GetLanguageFile(this.datapath);
this.conflang = DEXConfig.GetLanguageFile(this.datapath);
//游戏数据,MSE数据
this.datacfg = new DataConfig(MyConfig.GetCardInfoFile(this.datapath));
this.datacfg = new DataConfig(DEXConfig.GetCardInfoFile(this.datapath));
//初始化YGOUtil的数据
YGOUtil.SetConfig(this.datacfg);
//代码提示
string funtxt = MyPath.Combine(this.datapath, MyConfig.FILE_FUNCTION);
string conlua = MyPath.Combine(this.datapath, MyConfig.FILE_CONSTANT);
string confstring = MyPath.Combine(this.datapath, MyConfig.FILE_STRINGS);
string funtxt = MyPath.Combine(this.datapath, DEXConfig.FILE_FUNCTION);
string conlua = MyPath.Combine(this.datapath, DEXConfig.FILE_CONSTANT);
string confstring = MyPath.Combine(this.datapath, DEXConfig.FILE_STRINGS);
this.codecfg = new CodeConfig();
//添加函数
this.codecfg.AddFunction(funtxt);
......@@ -98,7 +98,7 @@ void Init()
this.codecfg.InitAutoMenus();
this.history = new History(this);
//读取历史记录
this.history.ReadHistory(MyPath.Combine(this.datapath, MyConfig.FILE_HISTORY));
this.history.ReadHistory(MyPath.Combine(this.datapath, DEXConfig.FILE_HISTORY));
//加载多语言
LanguageHelper.LoadFormLabels(this.conflang);
}
......@@ -158,8 +158,8 @@ protected override void DefWndProc(ref Message m)
{
switch (m.Msg)
{
case MyConfig.WM_OPEN://处理消息
string file = MyPath.Combine(Application.StartupPath, MyConfig.FILE_TEMP);
case DEXConfig.WM_OPEN://处理消息
string file = MyPath.Combine(Application.StartupPath, DEXConfig.FILE_TEMP);
if (File.Exists(file))
{
this.Activate();
......@@ -180,7 +180,7 @@ protected override void DefWndProc(ref Message m)
//打开脚本
void OpenScript(string file)
{
if (MyConfig.ReadString(MyConfig.USE_EDITOR) == "Avalon")
if (DEXConfig.ReadString(DEXConfig.USE_EDITOR) == "Avalon")
{
CodeEditForm_Avalon cf = new CodeEditForm_Avalon();
//设置界面语言
......@@ -577,10 +577,27 @@ private void bgWorker1_RunWorkerCompleted(object sender, System.ComponentModel.R
}
#endregion
private void dockPanel_DragEnter(object sender, DragEventArgs e)
{
string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];
if (files != null)
{
foreach (string file in files)
{
this.Open(file);
}
}
}
private void dockPanel_DragDrop(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void MainForm_Load(object sender, EventArgs e)
{
//检查更新
if (MyConfig.ReadBoolean(MyConfig.TAG_AUTO_CHECK_UPDATE))
if (DEXConfig.ReadBoolean(DEXConfig.TAG_AUTO_CHECK_UPDATE))
{
Thread th = new Thread(this.CheckUpdate)
{
......
......@@ -47,17 +47,17 @@ public class Location
public int LocationInt;
enum LocationStrings
{
LOCATION_DECK =0x01,
LOCATION_HAND =0x02,
LOCATION_MZONE =0x04,
LOCATION_SZONE =0x08,
LOCATION_GRAVE =0x10,
LOCATION_REMOVED =0x20,
LOCATION_EXTRA =0x40,
LOCATION_OVERLAY =0x80,
LOCATION_ONFIELD =0x0c,
LOCATION_DECKBOT =0x10001,
LOCATION_DECKSHF =0x20001
LOCATION_DECK = 0x01,
LOCATION_HAND = 0x02,
LOCATION_MZONE = 0x04,
LOCATION_SZONE = 0x08,
LOCATION_GRAVE = 0x10,
LOCATION_REMOVED = 0x20,
LOCATION_EXTRA = 0x40,
LOCATION_OVERLAY = 0x80,
LOCATION_ONFIELD = 0x0c,
LOCATION_DECKBOT = 0x10001,
LOCATION_DECKSHF = 0x20001
}
public override string ToString()
......
......@@ -20,14 +20,14 @@ internal sealed class Program
private static void Main(string[] args)
{
string arg = (args.Length > 0) ? args[0] : "";
if (arg == MyConfig.TAG_SAVE_LAGN || arg == MyConfig.TAG_SAVE_LAGN2)
if (arg == DEXConfig.TAG_SAVE_LAGN || arg == DEXConfig.TAG_SAVE_LAGN2)
{
//保存语言
SaveLanguage();
MessageBox.Show("Save Language OK.");
Environment.Exit(1);
}
if (MyConfig.OpenOnExistForm(arg))//在已经存在的窗口打开文件
if (DEXConfig.OpenOnExistForm(arg))//在已经存在的窗口打开文件
{
Environment.Exit(1);
}
......@@ -39,15 +39,15 @@ private static void Main(string[] args)
//设置将要打开的文件
mainForm.SetOpenFile(arg);
//数据目录
mainForm.SetDataPath(MyPath.Combine(Application.StartupPath, MyConfig.TAG_DATA));
mainForm.SetDataPath(MyPath.Combine(Application.StartupPath, DEXConfig.TAG_DATA));
Application.Run(mainForm);
}
}
static void SaveLanguage()
{
string datapath = MyPath.Combine(Application.StartupPath, MyConfig.TAG_DATA);
string conflang = MyConfig.GetLanguageFile(datapath);
string datapath = MyPath.Combine(Application.StartupPath, DEXConfig.TAG_DATA);
string conflang = DEXConfig.GetLanguageFile(datapath);
LanguageHelper.LoadFormLabels(conflang);
LanguageHelper langhelper = new LanguageHelper();
MainForm form1 = new MainForm();
......
......@@ -45,7 +45,7 @@
<add key="image_xyz" value="24,51,128,128"/>
<add key="image_pendulum" value="16,50,147,109"/>
<add key="editor" value="Avalon"/>
<!-- CodeEdiotr Setting
<!-- CodeEditor Setting
IME = true 使用輸入法,正常顯示文字,反應變慢
IME = false English
-->
......@@ -53,7 +53,7 @@
<add key="wordwrap" value="true"/>
<add key="tabisspace" value="false"/>
<add key="fontname" value="Consolas"/>
<add key="fontsize" value="18.5"/>
<add key="fontsize" value="16"/>
<!-- MSE path-->
<add key="mse_path" value="./MagicSetEditor2/mse.exe"/>
<add key="mse_exprotpath" value="./exprot"/>
......
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