Commit bc0829bf authored by JoyJ's avatar JoyJ

code format

parent c95bd343
This diff is collapsed.
......@@ -8,10 +8,10 @@ public class Area
{
public Area()
{
left = 0;
top = 0;
width = 0;
height = 0;
this.left = 0;
this.top = 0;
this.width = 0;
this.height = 0;
}
/// <summary>
/// 左
......
......@@ -78,16 +78,18 @@ public static bool CheckVersion(string ver, string oldver)
string[] oldvers = oldver.Split('.');
if (vers.Length == oldvers.Length)
{
int j, k;//从左到右比较数字
//从左到右比较数字
for (int i = 0; i < oldvers.Length; i++)
{
int.TryParse(vers[i], out j);
int.TryParse(oldvers[i], out k);
int.TryParse(vers[i], out int j);
int.TryParse(oldvers[i], out int k);
if (j > k)//新的版本号大于旧的
{
hasNew = true;
break;
}else if(j < k){
}
else if (j < k)
{
hasNew = false;
break;
}
......@@ -147,7 +149,10 @@ public static bool DownLoad(string filename)
try
{
if (File.Exists(filename))
{
File.Delete(filename);
}
HttpWebRequest Myrq = (HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
HttpWebResponse myrp = (HttpWebResponse)Myrq.GetResponse();
long totalBytes = myrp.ContentLength;
......
......@@ -20,7 +20,10 @@ public static string getValue(string line)
{
int t = line.IndexOf('=');
if (t > 0)
{
return line.Substring(t + 1).Trim();
}
return "";
}
/// <summary>
......@@ -32,7 +35,10 @@ public static string getValue1(string word)
{
int i = word.IndexOf(SEP_LINE);
if (i > 0)
{
return word.Substring(0, i);
}
return word;
}
/// <summary>
......@@ -44,7 +50,10 @@ public static string getValue2(string word)
{
int i = word.IndexOf(SEP_LINE);
if (i > 0)
{
return word.Substring(i + SEP_LINE.Length);
}
return "";
}
/// <summary>
......@@ -78,10 +87,14 @@ public static string getRegex(string word)
public static bool getBooleanValue(string line)
{
if (getValue(line).ToLower() == "true")
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 获取int值
/// </summary>
......@@ -113,11 +126,12 @@ public static void DicAdd(SortedList<long, string> dic, string line)
{
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);
long.TryParse(strkey, NumberStyles.HexNumber, null, out long key);
if (!dic.ContainsKey(key))
{
dic.Add(key, strval.Trim());
}
}
}
}
}
......@@ -17,7 +17,10 @@ public static class MyBitmap
public static Bitmap readImage(string file)
{
if (!File.Exists(file))
{
return null;
}
MemoryStream ms = new MemoryStream(File.ReadAllBytes(file));
return (Bitmap)Image.FromStream(ms);
}
......@@ -124,9 +127,15 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
{
string path=Path.GetDirectoryName(filename);
if(!Directory.Exists(path))//创建文件夹
{
Directory.CreateDirectory(path);
if(File.Exists(filename))//删除旧文件
}
if (File.Exists(filename))//删除旧文件
{
File.Delete(filename);
}
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo ici = null;
foreach ( ImageCodecInfo codec in codecs )
......@@ -138,7 +147,10 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
}
}
if (quality < 0 || quality > 100)
{
quality = 60;
}
EncoderParameters encoderParams = new EncoderParameters();
encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, (long)quality);
if (ici != null)
......
......@@ -52,7 +52,7 @@ public static string Combine(params string[] paths)
}
if (!firstPath.EndsWith(spliter))
{
firstPath = firstPath + spliter;
firstPath += spliter;
}
builder.Append(firstPath);
for (int i = 1; i < paths.Length; i++)
......@@ -70,7 +70,7 @@ public static string Combine(params string[] paths)
}
else
{
nextPath = nextPath + spliter;
nextPath += spliter;
}
}
builder.Append(nextPath);
......@@ -96,7 +96,10 @@ public static string CheckDir(string dir,string defalut)
fo = new DirectoryInfo(defalut);
}
if (!fo.Exists)
{
fo.Create();
}
dir = fo.FullName;
return dir;
}
......@@ -121,21 +124,29 @@ public static string getFullFileName(string tag, string file)
{
string name = Path.GetFileNameWithoutExtension(file);
if (!name.StartsWith(tag + "_"))
{
return "";
}
else
{
return name.Replace(tag + "_", "");
}
}
public static void CreateDir(string dir)
{
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
}
public static void CreateDirByFile(string file)
{
string dir = Path.GetDirectoryName(file);
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
}
}
}
......@@ -32,7 +32,9 @@ public new void Add(K key, V value)
}
}
if (flag == 1)
{
return; //跳出函数
}
//否则就加入
base.Add(key, value);
}
......
......@@ -9,10 +9,13 @@ public class StrUtil
public static string AutoEnter(string str, int lineNum, char re)
{
if (str == null || str.Length == 0)
{
return "";
}
str = " "+str.Replace("\r\n", "\n");
char[] ch = str.ToCharArray();
int count = ch.Length;
_ = ch.Length;
StringBuilder sb = new StringBuilder();
......@@ -21,9 +24,14 @@ public static string AutoEnter(string str, int lineNum, char re)
{
int ic = c;
if (ic > 128)
{
i += 2;
}
else
{
i += 1;
}
if (c == '\n' || c == '\r')
{
sb.Append(re);
......
......@@ -25,7 +25,9 @@ public static void Save(string appKey, string appValue)
XmlElement xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
if (xElem != null) //存在,则更新
{
xElem.SetAttribute("value", appValue);
}
else//不存在,则插入
{
XmlElement xNewElem = xDoc.CreateElement("add");
......
This diff is collapsed.
......@@ -15,29 +15,29 @@ public class CodeConfig
#region 成员
public CodeConfig()
{
tooltipDic = new SortedList<string, string>();
longTooltipDic = new SortedList<string, string>();
items = new List<AutocompleteItem>();
this.tooltipDic = new SortedList<string, string>();
this.longTooltipDic = new SortedList<string, string>();
this.items = new List<AutocompleteItem>();
}
//函数提示
SortedList<string, string> tooltipDic;
SortedList<string, string> longTooltipDic;
List<AutocompleteItem> items;
readonly SortedList<string, string> tooltipDic;
readonly SortedList<string, string> longTooltipDic;
readonly List<AutocompleteItem> items;
/// <summary>
/// 输入提示
/// </summary>
public SortedList<string, string> TooltipDic
{
get { return tooltipDic; }
get { return this.tooltipDic; }
}
public SortedList<string, string> LongTooltipDic
{
get { return longTooltipDic; }
get { return this.longTooltipDic; }
}
public AutocompleteItem[] Items
{
get { return items.ToArray(); }
get { return this.items.ToArray(); }
}
#endregion
......@@ -51,9 +51,9 @@ public void SetNames(Dictionary<long, string> dic)
foreach (long k in dic.Keys)
{
string key = "0x" + k.ToString("x");
if (!tooltipDic.ContainsKey(key))
if (!this.tooltipDic.ContainsKey(key))
{
AddToolIipDic(key, dic[k]);
this.AddToolIipDic(key, dic[k]);
}
}
}
......@@ -75,7 +75,7 @@ public void AddStrings(string file)
string[] ws = line.Split(' ');
if (ws.Length > 2)
{
AddToolIipDic(ws[1], ws[2]);
this.AddToolIipDic(ws[1], ws[2]);
}
}
}
......@@ -88,7 +88,10 @@ public void AddStrings(string file)
public void AddFunction(string funtxt)
{
if (!File.Exists(funtxt))
{
return;
}
string[] lines = File.ReadAllLines(funtxt);
bool isFind = false;
string name = "";
......@@ -98,11 +101,14 @@ public void AddFunction(string funtxt)
if (string.IsNullOrEmpty(line)
|| line.StartsWith("==")
|| line.StartsWith("#"))
{
continue;
}
if (line.StartsWith("●"))
{
//add
AddToolIipDic(name, desc);
this.AddToolIipDic(name, desc);
int w = line.IndexOf("(");
int t = line.IndexOf(" ");
......@@ -119,7 +125,7 @@ public void AddFunction(string funtxt)
desc += Environment.NewLine + line;
}
}
AddToolIipDic(name, desc);
this.AddToolIipDic(name, desc);
}
#endregion
......@@ -128,21 +134,26 @@ public void AddConstant(string conlua)
{
//conList.Add("con");
if (!File.Exists(conlua))
{
return;
}
string[] lines = File.ReadAllLines(conlua);
foreach (string line in lines)
{
if (line.StartsWith("--"))
{
continue;
string k = line, desc = line;
}
int t = line.IndexOf("=");
int t2 = line.IndexOf("--");
_ = line.IndexOf("--");
//常量 = 0x1 ---注释
k = (t > 0) ? line.Substring(0, t).TrimEnd(new char[] { ' ', '\t' })
string k = (t > 0) ? line.Substring(0, t).TrimEnd(new char[] { ' ', '\t' })
: line;
desc = (t > 0) ? line.Substring(t + 1).Replace("--", "\n")
string desc = (t > 0) ? line.Substring(t + 1).Replace("--", "\n")
: line;
AddToolIipDic(k, desc);
this.AddToolIipDic(k, desc);
}
}
#endregion
......@@ -150,60 +161,81 @@ public void AddConstant(string conlua)
#region 处理
public void InitAutoMenus()
{
items.Clear();
foreach (string k in tooltipDic.Keys)
this.items.Clear();
foreach (string k in this.tooltipDic.Keys)
{
AutocompleteItem item = new AutocompleteItem(k);
item.ToolTipTitle = k;
item.ToolTipText = tooltipDic[k];
items.Add(item);
AutocompleteItem item = new AutocompleteItem(k)
{
ToolTipTitle = k,
ToolTipText = this.tooltipDic[k]
};
this.items.Add(item);
}
foreach (string k in longTooltipDic.Keys)
foreach (string k in this.longTooltipDic.Keys)
{
if (this.tooltipDic.ContainsKey(k))
{
if (tooltipDic.ContainsKey(k))
continue;
AutocompleteItem item = new AutocompleteItem(k);
item.ToolTipTitle = k;
item.ToolTipText = longTooltipDic[k];
items.Add(item);
}
AutocompleteItem item = new AutocompleteItem(k)
{
ToolTipTitle = k,
ToolTipText = this.longTooltipDic[k]
};
this.items.Add(item);
}
}
string GetShortName(string name)
{
int t = name.IndexOf(".");
if (t > 0)
{
return name.Substring(t + 1);
}
else
{
return name;
}
}
void AddToolIipDic(string key, string val)
{
string skey = GetShortName(key);
if (tooltipDic.ContainsKey(skey))//存在
string skey = this.GetShortName(key);
if (this.tooltipDic.ContainsKey(skey))//存在
{
string nval = tooltipDic[skey];
string nval = this.tooltipDic[skey];
if (!nval.EndsWith(Environment.NewLine))
{
nval += Environment.NewLine;
}
nval += Environment.NewLine +val;
tooltipDic[skey] = nval;
this.tooltipDic[skey] = nval;
}
else
tooltipDic.Add(skey, val);
{
this.tooltipDic.Add(skey, val);
}
//
AddLongToolIipDic(key, val);
this.AddLongToolIipDic(key, val);
}
void AddLongToolIipDic(string key, string val)
{
if (longTooltipDic.ContainsKey(key))//存在
if (this.longTooltipDic.ContainsKey(key))//存在
{
string nval = longTooltipDic[key];
string nval = this.longTooltipDic[key];
if (!nval.EndsWith(Environment.NewLine))
{
nval += Environment.NewLine;
}
nval += Environment.NewLine + val;
longTooltipDic[key] = nval;
this.longTooltipDic[key] = nval;
}
else
longTooltipDic.Add(key, val);
{
this.longTooltipDic.Add(key, val);
}
}
#endregion
}
......
......@@ -18,11 +18,11 @@ public class DataConfig
{
public DataConfig()
{
InitMember(MyPath.Combine(Application.StartupPath, MyConfig.TAG_CARDINFO+".txt"));
this.InitMember(MyPath.Combine(Application.StartupPath, MyConfig.TAG_CARDINFO+".txt"));
}
public DataConfig(string conf)
{
InitMember(conf);
this.InitMember(conf);
}
/// <summary>
/// 初始化成员
......@@ -33,26 +33,26 @@ public void InitMember(string conf)
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
if(!File.Exists(conf))
{
dicCardRules = new Dictionary<long, string>();
dicSetnames = new Dictionary<long, string>();
dicCardTypes = new Dictionary<long, string>();
dicLinkMarkers = new Dictionary<long, string>();
dicCardcategorys = new Dictionary<long, string>();
dicCardAttributes = new Dictionary<long, string>();
dicCardRaces = new Dictionary<long, string>();
dicCardLevels = new Dictionary<long, string>();
this.dicCardRules = new Dictionary<long, string>();
this.dicSetnames = new Dictionary<long, string>();
this.dicCardTypes = new Dictionary<long, string>();
this.dicLinkMarkers = new Dictionary<long, string>();
this.dicCardcategorys = new Dictionary<long, string>();
this.dicCardAttributes = new Dictionary<long, string>();
this.dicCardRaces = new Dictionary<long, string>();
this.dicCardLevels = new Dictionary<long, string>();
return;
}
//提取内容
string text = File.ReadAllText(conf);
dicCardRules = DataManager.Read(text, MyConfig.TAG_RULE);
dicSetnames = DataManager.Read(text, MyConfig.TAG_SETNAME);
dicCardTypes = DataManager.Read(text, MyConfig.TAG_TYPE);
dicLinkMarkers = DataManager.Read(text, MyConfig.TAG_MARKER);
dicCardcategorys = DataManager.Read(text, MyConfig.TAG_CATEGORY);
dicCardAttributes = DataManager.Read(text, MyConfig.TAG_ATTRIBUTE);
dicCardRaces = DataManager.Read(text, MyConfig.TAG_RACE);
dicCardLevels = DataManager.Read(text, MyConfig.TAG_LEVEL);
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);
}
/// <summary>
......
......@@ -77,6 +77,8 @@ public static string subString(string content, string tag)
public static Dictionary<long, string> Read(string content)
{
string text = reReturn(content);
text = text.Replace("\r", "\n");
text = text.Replace("\n\n", "\n"); //Linux & MacOS 适配 190324 by JoyJ
return Read(text.Split('\n'));
}
/// <summary>
......@@ -90,19 +92,32 @@ public static string subString(string content, string tag)
long lkey;
foreach (string line in lines)
{
if (line.StartsWith("#"))
string l = line.Trim(); //姑且做一下Trim 190324 by JoyJ
if (l.StartsWith("#"))
{
continue;
string[] words = line.Split(SEP_LINE);
}
string[] words = l.Split(SEP_LINE);
if (words.Length < 2)
{
continue;
}
if (words[0].StartsWith("0x"))
{
long.TryParse(words[0].Replace("0x", ""), NumberStyles.HexNumber, null, out lkey);
}
else
{
long.TryParse(words[0], out lkey);
}
// N/A 的数据不显示
if (!tempDic.ContainsKey(lkey) && words[1] != "N/A")
{
tempDic.Add(lkey, words[1]);
}
}
return tempDic;
}
......@@ -136,7 +151,10 @@ public static string[] GetValues(Dictionary<long, string> dic)
public static string GetValue(Dictionary<long, string> dic, long key)
{
if(dic.ContainsKey(key))
{
return dic[key].Trim();
}
return key.ToString("x");
}
#endregion
......
......@@ -18,7 +18,7 @@ namespace DataEditorX.Config
public class ImageSet
{
public ImageSet(){
Init();
this.Init();
}
//初始化
void Init()
......
......@@ -193,9 +193,11 @@ public static string readString(string key)
/// <returns></returns>
public static int readInteger(string key, int def)
{
int i;
if (int.TryParse(readString(key), out i))
if (int.TryParse(readString(key), out int i))
{
return i;
}
return def;
}
/// <summary>
......@@ -206,9 +208,11 @@ public static int readInteger(string key, int def)
/// <returns></returns>
public static float readFloat(string key, float def)
{
float i;
if (float.TryParse(readString(key), out i))
if (float.TryParse(readString(key), out float i))
{
return i;
}
return def;
}
/// <summary>
......@@ -286,7 +290,10 @@ public static string GetLanguageFile(string path)
{
string name = MyPath.getFullFileName(MyConfig.TAG_LANGUAGE, file);
if (string.IsNullOrEmpty(name))
{
continue;
}
if (syslang.Equals(name, StringComparison.OrdinalIgnoreCase))
{
Save(MyConfig.TAG_LANGUAGE, syslang);
......
......@@ -9,17 +9,17 @@ public class YgoPath
{
public YgoPath(string gamepath)
{
SetPath(gamepath);
this.SetPath(gamepath);
}
public void SetPath(string gamepath)
{
this.gamepath = gamepath;
picpath = MyPath.Combine(gamepath, "pics");
fieldpath = MyPath.Combine(picpath, "field");
picpath2 = MyPath.Combine(picpath, "thumbnail");
luapath = MyPath.Combine(gamepath, "script");
ydkpath = MyPath.Combine(gamepath, "deck");
replaypath = MyPath.Combine(gamepath, "replay");
this.picpath = MyPath.Combine(gamepath, "pics");
this.fieldpath = MyPath.Combine(this.picpath, "field");
this.picpath2 = MyPath.Combine(this.picpath, "thumbnail");
this.luapath = MyPath.Combine(gamepath, "script");
this.ydkpath = MyPath.Combine(gamepath, "deck");
this.replaypath = MyPath.Combine(gamepath, "replay");
}
/// <summary>游戏目录</summary>
public string gamepath;
......@@ -38,7 +38,7 @@ public void SetPath(string gamepath)
public string GetImage(long id)
{
return GetImage(id.ToString());
return this.GetImage(id.ToString());
}
//public string GetImageThum(long id)
//{
......@@ -46,20 +46,20 @@ public string GetImage(long id)
//}
public string GetImageField(long id)
{
return GetImageField(id.ToString());//场地图
return this.GetImageField(id.ToString());//场地图
}
public string GetScript(long id)
{
return GetScript(id.ToString());
return this.GetScript(id.ToString());
}
public string GetYdk(string name)
{
return MyPath.Combine(ydkpath, name + ".ydk");
return MyPath.Combine(this.ydkpath, name + ".ydk");
}
//字符串id
public string GetImage(string id)
{
return MyPath.Combine(picpath, id + ".jpg");
return MyPath.Combine(this.picpath, id + ".jpg");
}
//public string GetImageThum(string id)
//{
......@@ -67,34 +67,34 @@ public string GetImage(string id)
//}
public string GetImageField(string id)
{
return MyPath.Combine(fieldpath, id+ ".png");//场地图
return MyPath.Combine(this.fieldpath, id+ ".png");//场地图
}
public string GetScript(string id)
{
return MyPath.Combine(luapath, "c" + id + ".lua");
return MyPath.Combine(this.luapath, "c" + id + ".lua");
}
public string GetModuleScript(string modulescript)
{
return MyPath.Combine(luapath, modulescript + ".lua");
return MyPath.Combine(this.luapath, modulescript + ".lua");
}
public string[] GetCardfiles(long id)
{
string[] files = new string[]{
GetImage(id),//大图
this.GetImage(id),//大图
//GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
this.GetImageField(id),//场地图
this.GetScript(id)
};
return files;
}
public string[] GetCardfiles(string id)
{
string[] files = new string[]{
GetImage(id),//大图
this.GetImage(id),//大图
//GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
this.GetImageField(id),//场地图
this.GetScript(id)
};
return files;
}
......
......@@ -9,10 +9,10 @@ public class DFlowLayoutPanel : FlowLayoutPanel
{
public DFlowLayoutPanel()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer |
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint,
true);
UpdateStyles();
this.UpdateStyles();
}
}
}
......@@ -9,10 +9,10 @@ public class DListBox : ListBox
{
public DListBox()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer |
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint,
true);
UpdateStyles();
this.UpdateStyles();
}
}
}
......@@ -9,10 +9,10 @@ public class DListView : ListView
{
public DListView()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer |
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint,
true);
UpdateStyles();
this.UpdateStyles();
}
}
}
......@@ -20,31 +20,38 @@ public class FastColoredTextBoxEx : FastColoredTextBox
public FastColoredTextBoxEx() : base()
{
this.SyntaxHighlighter = new MySyntaxHighlighter();
this.TextChangedDelayed += FctbTextChangedDelayed;
this.TextChangedDelayed += this.FctbTextChangedDelayed;
}
public new event EventHandler<ToolTipNeededEventArgs> ToolTipNeeded;
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
lastMouseCoord = e.Location;
this.lastMouseCoord = e.Location;
}
//函数悬停提示
protected override void OnToolTip()
{
if (ToolTip == null)
if (this.ToolTip == null)
{
return;
}
if (ToolTipNeeded == null)
{
return;
}
//get place under mouse
Place place = PointToPlace(lastMouseCoord);
Place place = this.PointToPlace(this.lastMouseCoord);
//check distance
Point p = PlaceToPoint(place);
if (Math.Abs(p.X - lastMouseCoord.X) > CharWidth*2 ||
Math.Abs(p.Y - lastMouseCoord.Y) > CharHeight*2)
Point p = this.PlaceToPoint(place);
if (Math.Abs(p.X - this.lastMouseCoord.X) > this.CharWidth *2 ||
Math.Abs(p.Y - this.lastMouseCoord.Y) > this.CharHeight *2)
{
return;
}
//get word under mouse
var r = new Range(this, place, place);
string hoveredWord = r.GetFragment("[a-zA-Z0-9_]").Text;
......@@ -55,10 +62,10 @@ protected override void OnToolTip()
if (ea.ToolTipText != null)
{
//show tooltip
ToolTip.ToolTipTitle = ea.ToolTipTitle;
ToolTip.ToolTipIcon = ea.ToolTipIcon;
this.ToolTip.ToolTipTitle = ea.ToolTipTitle;
this.ToolTip.ToolTipIcon = ea.ToolTipIcon;
//ToolTip.SetToolTip(this, ea.ToolTipText);
ToolTip.Show(ea.ToolTipText, this, new Point(lastMouseCoord.X, lastMouseCoord.Y + CharHeight));
this.ToolTip.Show(ea.ToolTipText, this, new Point(this.lastMouseCoord.X, this.lastMouseCoord.Y + this.CharHeight));
}
}
//高亮当前词
......@@ -75,13 +82,21 @@ void FctbTextChangedDelayed(object sender, TextChangedEventArgs e)
var line = this[i];
var spacesCount = line.StartSpacesCount;
if (spacesCount == line.Count) //empty line
{
continue;
}
if (currentIndent < spacesCount)
{
//append start folding marker
this[lastNonEmptyLine].FoldingStartMarker = "m" + currentIndent;
}
else if (currentIndent > spacesCount)
{
//append end folding marker
this[lastNonEmptyLine].FoldingEndMarker = "m" + spacesCount;
}
currentIndent = spacesCount;
lastNonEmptyLine = i;
}
......
......@@ -11,55 +11,65 @@ namespace DataEditorX.Controls
public class History
{
IMainForm mainForm;
readonly IMainForm mainForm;
string historyFile;
List<string> cdbhistory;
List<string> luahistory;
readonly List<string> cdbhistory;
readonly List<string> luahistory;
public string[] GetcdbHistory()
{
return cdbhistory.ToArray();
return this.cdbhistory.ToArray();
}
public string[] GetluaHistory()
{
return luahistory.ToArray();
return this.luahistory.ToArray();
}
public History(IMainForm mainForm)
{
this.mainForm = mainForm;
cdbhistory = new List<string>();
luahistory = new List<string>();
this.cdbhistory = new List<string>();
this.luahistory = new List<string>();
}
//读取历史记录
public void ReadHistory(string historyFile)
{
this.historyFile = historyFile;
if (!File.Exists(historyFile))
{
return;
}
string[] lines = File.ReadAllLines(historyFile);
AddHistorys(lines);
this.AddHistorys(lines);
}
//添加历史记录
void AddHistorys(string[] lines)
{
luahistory.Clear();
cdbhistory.Clear();
this.luahistory.Clear();
this.cdbhistory.Clear();
foreach (string line in lines)
{
if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
{
continue;
}
if (File.Exists(line))
{
if (YGOUtil.isScript(line))
if (YGOUtil.IsScript(line))
{
if (this.luahistory.Count < MyConfig.MAX_HISTORY
&& this.luahistory.IndexOf(line) < 0)
{
if (luahistory.Count < MyConfig.MAX_HISTORY
&& luahistory.IndexOf(line) < 0)
luahistory.Add(line);
this.luahistory.Add(line);
}
}
else
{
if (cdbhistory.Count < MyConfig.MAX_HISTORY
&& cdbhistory.IndexOf(line) < 0)
cdbhistory.Add(line);
if (this.cdbhistory.Count < MyConfig.MAX_HISTORY
&& this.cdbhistory.IndexOf(line) < 0)
{
this.cdbhistory.Add(line);
}
}
}
}
......@@ -70,81 +80,89 @@ public void AddHistory(string file)
//添加到开始
tmplist.Add(file);
//添加旧记录
tmplist.AddRange(cdbhistory.ToArray());
tmplist.AddRange(luahistory.ToArray());
tmplist.AddRange(this.cdbhistory.ToArray());
tmplist.AddRange(this.luahistory.ToArray());
//
AddHistorys(tmplist.ToArray());
SaveHistory();
MenuHistory();
this.AddHistorys(tmplist.ToArray());
this.SaveHistory();
this.MenuHistory();
}
//保存历史
void SaveHistory()
{
string texts = "# database history";
foreach (string str in cdbhistory)
foreach (string str in this.cdbhistory)
{
if (File.Exists(str))
{
texts += Environment.NewLine + str;
}
}
texts += Environment.NewLine + "# script history";
foreach (string str in luahistory)
foreach (string str in this.luahistory)
{
if (File.Exists(str))
{
texts += Environment.NewLine + str;
}
if(File.Exists(historyFile))
File.Delete(historyFile);
File.WriteAllText(historyFile, texts);
}
if(File.Exists(this.historyFile))
{
File.Delete(this.historyFile);
}
File.WriteAllText(this.historyFile, texts);
}
//添加历史记录菜单
public void MenuHistory()
{
//cdb历史
mainForm.CdbMenuClear();
foreach (string str in cdbhistory)
this.mainForm.CdbMenuClear();
foreach (string str in this.cdbhistory)
{
ToolStripMenuItem tsmi = new ToolStripMenuItem(str);
tsmi.Click += MenuHistoryItem_Click;
mainForm.AddCdbMenu(tsmi);
tsmi.Click += this.MenuHistoryItem_Click;
this.mainForm.AddCdbMenu(tsmi);
}
mainForm.AddCdbMenu(new ToolStripSeparator());
this.mainForm.AddCdbMenu(new ToolStripSeparator());
ToolStripMenuItem tsmiclear = new ToolStripMenuItem(LanguageHelper.GetMsg(LMSG.ClearHistory));
tsmiclear.Click += MenuHistoryClear_Click;
mainForm.AddCdbMenu(tsmiclear);
tsmiclear.Click += this.MenuHistoryClear_Click;
this.mainForm.AddCdbMenu(tsmiclear);
//lua历史
mainForm.LuaMenuClear();
foreach (string str in luahistory)
this.mainForm.LuaMenuClear();
foreach (string str in this.luahistory)
{
ToolStripMenuItem tsmi = new ToolStripMenuItem(str);
tsmi.Click += MenuHistoryItem_Click;
mainForm.AddLuaMenu(tsmi);
tsmi.Click += this.MenuHistoryItem_Click;
this.mainForm.AddLuaMenu(tsmi);
}
mainForm.AddLuaMenu(new ToolStripSeparator());
this.mainForm.AddLuaMenu(new ToolStripSeparator());
ToolStripMenuItem tsmiclear2 = new ToolStripMenuItem(LanguageHelper.GetMsg(LMSG.ClearHistory));
tsmiclear2.Click += MenuHistoryClear2_Click;
mainForm.AddLuaMenu(tsmiclear2);
tsmiclear2.Click += this.MenuHistoryClear2_Click;
this.mainForm.AddLuaMenu(tsmiclear2);
}
void MenuHistoryClear2_Click(object sender, EventArgs e)
{
luahistory.Clear();
MenuHistory();
SaveHistory();
this.luahistory.Clear();
this.MenuHistory();
this.SaveHistory();
}
void MenuHistoryClear_Click(object sender, EventArgs e)
{
cdbhistory.Clear();
MenuHistory();
SaveHistory();
this.cdbhistory.Clear();
this.MenuHistory();
this.SaveHistory();
}
void MenuHistoryItem_Click(object sender, EventArgs e)
{
ToolStripMenuItem tsmi = sender as ToolStripMenuItem;
if (tsmi != null)
if (sender is ToolStripMenuItem tsmi)
{
string file = tsmi.Text;
if(File.Exists(file))
mainForm.Open(file);
if (File.Exists(file))
{
this.mainForm.Open(file);
}
}
}
}
......
......@@ -20,13 +20,12 @@ namespace FastColoredTextBoxNS
/// </summary>
public class MySyntaxHighlighter : SyntaxHighlighter
{
TextStyle mBoldStyle = new TextStyle(Brushes.MediumSlateBlue, null, FontStyle.Regular);
TextStyle mNumberStyle = new TextStyle(Brushes.Orange, null, FontStyle.Regular);
TextStyle mStrStyle = new TextStyle(Brushes.Gold, null, FontStyle.Regular);
TextStyle ConStyle = new TextStyle(Brushes.YellowGreen, null, FontStyle.Regular);
TextStyle mKeywordStyle = new TextStyle(Brushes.DeepSkyBlue, null, FontStyle.Regular);
TextStyle mGrayStyle = new TextStyle(Brushes.Gray, null, FontStyle.Regular);
TextStyle mFunStyle = new TextStyle(Brushes.LightGray, null, FontStyle.Bold);
readonly TextStyle mNumberStyle = new TextStyle(Brushes.Orange, null, FontStyle.Regular);
readonly TextStyle mStrStyle = new TextStyle(Brushes.Gold, null, FontStyle.Regular);
readonly TextStyle conStyle = new TextStyle(Brushes.YellowGreen, null, FontStyle.Regular);
readonly TextStyle mKeywordStyle = new TextStyle(Brushes.DeepSkyBlue, null, FontStyle.Regular);
readonly TextStyle mGrayStyle = new TextStyle(Brushes.Gray, null, FontStyle.Regular);
readonly TextStyle mFunStyle = new TextStyle(Brushes.LightGray, null, FontStyle.Bold);
/// <summary>
......@@ -46,26 +45,28 @@ public override void LuaSyntaxHighlight(Range range)
= @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>.+)";
//clear style of changed range
range.ClearStyle(mStrStyle, mGrayStyle,ConStyle, mNumberStyle, mKeywordStyle, mFunStyle);
range.ClearStyle(this.mStrStyle, this.mGrayStyle, this.conStyle, this.mNumberStyle, this.mKeywordStyle, this.mFunStyle);
//
if (base.LuaStringRegex == null)
{
base.InitLuaRegex();
}
//string highlighting
range.SetStyle(mStrStyle, base.LuaStringRegex);
range.SetStyle(this.mStrStyle, base.LuaStringRegex);
//comment highlighting
range.SetStyle(mGrayStyle, base.LuaCommentRegex1);
range.SetStyle(mGrayStyle, base.LuaCommentRegex2);
range.SetStyle(mGrayStyle, base.LuaCommentRegex3);
range.SetStyle(this.mGrayStyle, base.LuaCommentRegex1);
range.SetStyle(this.mGrayStyle, base.LuaCommentRegex2);
range.SetStyle(this.mGrayStyle, base.LuaCommentRegex3);
//number highlighting
range.SetStyle(mNumberStyle, base.LuaNumberRegex);
range.SetStyle(this.mNumberStyle, base.LuaNumberRegex);
//keyword highlighting
range.SetStyle(mKeywordStyle, base.LuaKeywordRegex);
range.SetStyle(this.mKeywordStyle, base.LuaKeywordRegex);
//functions highlighting
range.SetStyle(mFunStyle, base.LuaFunctionsRegex);
range.SetStyle(mNumberStyle, @"\bc\d+\b");
range.SetStyle(this.mFunStyle, base.LuaFunctionsRegex);
range.SetStyle(this.mNumberStyle, @"\bc\d+\b");
range.SetStyle(ConStyle, @"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]");
range.SetStyle(this.conStyle, @"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]");
//range.SetStyle(mFunStyle, @"[:|\.|\s](?<range>[a-zA-Z0-9_]*?)[\(|\)|\s]");
//clear folding markers
......
......@@ -38,7 +38,9 @@ public Card(long cardCode)
this.desc = "";
this.str = new string[STR_MAX];
for (int i = 0; i < STR_MAX; i++)
{
this.str[i] = "";
}
}
#endregion
......@@ -78,8 +80,10 @@ public string[] Str
{
this.str = new string[STR_MAX];
for (int i = 0; i < STR_MAX; i++)
{
this.str[i] = "";
}
}
return this.str;
}
set { this.str = value; }
......@@ -110,12 +114,11 @@ public void SetSetCode(params string[] setcodes)
{
int i = 0;
this.setcode = 0;
long temp;
if (setcodes != null)
{
foreach (string sc in setcodes)
{
long.TryParse(sc, NumberStyles.HexNumber, null, out temp);
long.TryParse(sc, NumberStyles.HexNumber, null, out long temp);
this.setcode += (temp << i);
i += 0x10;
}
......@@ -140,9 +143,13 @@ public long GetRightScale()
public override bool Equals(object obj)
{
if (obj is Card)
return Equals((Card)obj); // use Equals method below
{
return this.Equals((Card)obj); // use Equals method below
}
else
{
return false;
}
}
/// <summary>
/// 比较卡片,除脚本提示文本
......@@ -153,31 +160,58 @@ public bool EqualsData(Card other)
{
bool equalBool = true;
if (this.id != other.id)
{
equalBool = false;
}
else if (this.ot != other.ot)
{
equalBool = false;
}
else if (this.alias != other.alias)
{
equalBool = false;
}
else if (this.setcode != other.setcode)
{
equalBool = false;
}
else if (this.type != other.type)
{
equalBool = false;
}
else if (this.atk != other.atk)
{
equalBool = false;
}
else if (this.def != other.def)
{
equalBool = false;
}
else if (this.level != other.level)
{
equalBool = false;
}
else if (this.race != other.race)
{
equalBool = false;
}
else if (this.attribute != other.attribute)
{
equalBool = false;
}
else if (this.category != other.category)
{
equalBool = false;
}
else if (!this.name.Equals(other.name))
{
equalBool = false;
}
else if (!this.desc.Equals(other.desc))
{
equalBool = false;
}
return equalBool;
}
/// <summary>
......@@ -187,11 +221,15 @@ public bool EqualsData(Card other)
/// <returns>结果</returns>
public bool Equals(Card other)
{
bool equalBool=EqualsData(other);
bool equalBool=this.EqualsData(other);
if(!equalBool)
{
return false;
}
else if (this.str.Length != other.str.Length)
{
equalBool = false;
}
else
{
int l = this.str.Length;
......@@ -213,7 +251,7 @@ public bool Equals(Card other)
public override int GetHashCode()
{
// combine the hash codes of all members here (e.g. with XOR operator ^)
int hashCode = id.GetHashCode() + name.GetHashCode();
int hashCode = this.id.GetHashCode() + this.name.GetHashCode();
return hashCode;//member.GetHashCode();
}
/// <summary>
......@@ -230,7 +268,10 @@ public override int GetHashCode()
/// <returns></returns>
public bool IsType(CardType type){
if((this.type & (long)type) == (long)type)
{
return true;
}
return false;
}
/// <summary>
......@@ -246,8 +287,11 @@ public bool IsSetCode(long sc)
while (setcode != 0)
{
if ((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype)
{
return true;
setcode = setcode >> 0x10;
}
setcode >>= 0x10;
}
return false;
}
......@@ -264,47 +308,54 @@ public bool IsSetCode(long sc)
/// <summary>
/// 密码字符串
/// </summary>
public string idString
public string IdString
{
get { return id.ToString("00000000"); }
get { return this.id.ToString("00000000"); }
}
/// <summary>
/// 字符串化
/// </summary>
public override string ToString()
{
string str = "";
if (IsType(CardType.TYPE_MONSTER)){
str = name + "[" + idString + "]\n["
+ YGOUtil.GetTypeString(type) + "] "
+ YGOUtil.GetRace(race) + "/" + YGOUtil.GetAttributeString(attribute)
+ "\n" + levelString() + " " + atk + "/" + def + "\n" + redesc();
string str;
if (this.IsType(CardType.TYPE_MONSTER)){
str = this.name + "[" + this.IdString + "]\n["
+ YGOUtil.GetTypeString(this.type) + "] "
+ YGOUtil.GetRace(this.race) + "/" + YGOUtil.GetAttributeString(this.attribute)
+ "\n" + this.levelString() + " " + this.atk + "/" + this.def + "\n" + this.redesc();
}else
str = name +"[" +idString +"]\n["+YGOUtil.GetTypeString(type)+"]\n"+redesc();
{
str = this.name +"[" + this.IdString +"]\n["+YGOUtil.GetTypeString(this.type)+"]\n"+ this.redesc();
}
return str;
}
public string ToShortString(){
return this.name+" ["+idString+"]";
return this.name+" ["+ this.IdString +"]";
}
public string ToLongString(){
return ToString();
return this.ToString();
}
string levelString()
{
string star = "[";
long i = 0, j = level & 0xff;
long j = this.level & 0xff;
long i;
for (i = 0; i < j; i++)
{
if (i > 0 && (i % 4) == 0)
{
star += " ";
}
star += "★";
}
return star + "]";
}
string redesc()
{
string str = desc.Replace(Environment.NewLine, "\n");
string str = this.desc.Replace(Environment.NewLine, "\n");
str = Regex.Replace(str, "([。|?|?])", "$1\n");
str = str.Replace("\n\n", "\n");
return str;
......
This diff is collapsed.
......@@ -22,15 +22,15 @@ public interface ICommandManager
}
public class CommandManager : ICommandManager
{
private Stack<ICommand> undoStack = new Stack<ICommand>();
private Stack<ICommand> reverseStack = new Stack<ICommand>();
private readonly Stack<ICommand> undoStack = new Stack<ICommand>();
private readonly Stack<ICommand> reverseStack = new Stack<ICommand>();
public event StatusBool UndoStateChanged;
public CommandManager()
{
UndoStateChanged += new StatusBool(CommandManager_UndoStateChanged);
UndoStateChanged += new StatusBool(CommandManager_ReverseUndoStateChanged);
UndoStateChanged += new StatusBool(this.CommandManager_UndoStateChanged);
UndoStateChanged += new StatusBool(this.CommandManager_ReverseUndoStateChanged);
}
private void CommandManager_UndoStateChanged(bool val)
......@@ -46,48 +46,52 @@ private void CommandManager_ReverseUndoStateChanged(bool val)
#region ICommandManager 成员
public void ExcuteCommand(ICommand command, params object[] args)
{
if(!command.Excute(args)) return;
reverseStack.Clear();
if(!command.Excute(args))
{
return;
}
this.reverseStack.Clear();
if (command is IBackableCommand)
{
undoStack.Push((ICommand)command.Clone());
this.undoStack.Push((ICommand)command.Clone());
}
else
{
undoStack.Clear();
this.undoStack.Clear();
}
UndoStateChanged(undoStack.Count > 0);
UndoStateChanged(this.undoStack.Count > 0);
}
public void Undo()
{
IBackableCommand command = (IBackableCommand)undoStack.Pop();
IBackableCommand command = (IBackableCommand)this.undoStack.Pop();
if (command == null)
{
return;
}
command.Undo();
reverseStack.Push((ICommand)command.Clone());
this.reverseStack.Push((ICommand)command.Clone());
UndoStateChanged(undoStack.Count > 0);
UndoStateChanged(this.undoStack.Count > 0);
//UndoStateChanged(reverseStack.Count > 0);
}
public void ReverseUndo()
{
IBackableCommand command = (IBackableCommand)reverseStack.Pop();
IBackableCommand command = (IBackableCommand)this.reverseStack.Pop();
if (command == null)
{
return;
}
command.Excute();
undoStack.Push((ICommand)command.Clone());
this.undoStack.Push((ICommand)command.Clone());
UndoStateChanged(undoStack.Count > 0);
UndoStateChanged(this.undoStack.Count > 0);
}
#endregion
}
......
This diff is collapsed.
......@@ -19,26 +19,26 @@ namespace DataEditorX
public class LuaFunction
{
#region 日志log
static void ResetLog(string file)
static void ResetLog()
{
File.Delete(logtxt);
File.Delete(_logtxt);
}
static void Log(string str)
{
File.AppendAllText(logtxt, str+Environment.NewLine);
File.AppendAllText(_logtxt, str+Environment.NewLine);
}
#endregion
#region old functions
static string oldfun;
static string logtxt;
static string funclisttxt;
static SortedList<string,string> funclist=new SortedList<string,string>();
static string _oldfun;
static string _logtxt;
static string _funclisttxt;
static readonly SortedList<string,string> _funclist=new SortedList<string,string>();
//读取旧函数
public static void Read(string funtxt)
{
funclist.Clear();
oldfun=funtxt;
_funclist.Clear();
_oldfun=funtxt;
if(File.Exists(funtxt))
{
string[] lines=File.ReadAllLines(funtxt);
......@@ -50,8 +50,11 @@ public static void Read(string funtxt)
if(string.IsNullOrEmpty(line)
|| line.StartsWith("==")
|| line.StartsWith("#"))
{
continue;
if(line.StartsWith("●"))
}
if (line.StartsWith("●"))
{
//添加之前的函数
AddOldFun(name, desc);
......@@ -76,13 +79,13 @@ static void AddOldFun(string name, string desc)
{
if (!string.IsNullOrEmpty(name))
{
if (funclist.ContainsKey(name))//存在,则添加注释
if (_funclist.ContainsKey(name))//存在,则添加注释
{
funclist[name] += Environment.NewLine + desc;
_funclist[name] += Environment.NewLine + desc;
}
else
{//不存在,则添加函数
funclist.Add(name, desc);
_funclist.Add(name, desc);
}
}
}
......@@ -99,10 +102,10 @@ 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);
logtxt=Path.Combine(path, "find_functions.log");
ResetLog(logtxt);
funclisttxt =Path.Combine(path, "_functions.txt");
File.Delete(funclisttxt);
_logtxt=Path.Combine(path, "find_functions.log");
ResetLog();
_funclisttxt =Path.Combine(path, "_functions.txt");
File.Delete(_funclisttxt);
if(!File.Exists(file)){//判断用户选择的目录
Log("error: no find file "+file);
if(File.Exists(file2)){
......@@ -135,16 +138,19 @@ public static bool Find(string path)
//保存
static void Save()
{
if (string.IsNullOrEmpty(oldfun))
if (string.IsNullOrEmpty(_oldfun))
{
return;
using (FileStream fs = new FileStream(oldfun + "_sort.txt",
}
using (FileStream fs = new FileStream(_oldfun + "_sort.txt",
FileMode.Create,
FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
foreach (string k in funclist.Keys)
foreach (string k in _funclist.Keys)
{
sw.WriteLine("●" + funclist[k]);
sw.WriteLine("●" + _funclist[k]);
}
sw.Close();
}
......@@ -171,7 +177,9 @@ static string ToTitle(string str)
string k=ToTitle(name)+"."+m.Groups[1].Value;
string v=m.Groups[2].Value;
if(!dic.ContainsKey(k))
{
dic.Add(k,v);
}
}
}
return dic;
......@@ -189,10 +197,12 @@ static string FindCode(string texts,string name)
if(mc.Success)
{
if(mc.Groups.Count>1)
{
return mc.Groups[0].Value
.Replace("\r\n","\n")
.Replace("\r","\n")
.Replace("\n",Environment.NewLine);
}
}
return "";
}
......@@ -200,30 +210,50 @@ static string FindCode(string texts,string name)
#region find return
//查找返回类型
static string FindReturn(string texts,string name)
static string FindReturn(string texts)
{
string restr="";
if(texts.IndexOf("lua_pushboolean")>=0)
{
return "bool ";
}
else
{
if(texts.IndexOf("interpreter::card2value")>=0)
{
restr += "Card ";
if(texts.IndexOf("interpreter::group2value")>=0)
}
if (texts.IndexOf("interpreter::group2value")>=0)
{
restr += "Group ";
if(texts.IndexOf("interpreter::effect2value")>=0)
}
if (texts.IndexOf("interpreter::effect2value")>=0)
{
restr += "Effect ";
}
else if(texts.IndexOf("interpreter::function2value")>=0)
{
restr += "function ";
}
if(texts.IndexOf("lua_pushinteger")>=0)
if (texts.IndexOf("lua_pushinteger")>=0)
{
restr += "int ";
if(texts.IndexOf("lua_pushstring")>=0)
}
if (texts.IndexOf("lua_pushstring")>=0)
{
restr += "string ";
}
}
if(string.IsNullOrEmpty(restr))
restr="void ";
if(restr.IndexOf(" ") !=restr.Length-1){
{
restr ="void ";
}
if (restr.IndexOf(" ") !=restr.Length-1){
restr = restr.Replace(" ","|").Substring(0,restr.Length-1)+" ";
}
return restr;
......@@ -235,11 +265,19 @@ static string FindReturn(string texts,string name)
static string getUserType(string str)
{
if(str.IndexOf("card")>=0)
{
return "Card";
if(str.IndexOf("effect")>=0)
}
if (str.IndexOf("effect")>=0)
{
return "Effect";
if(str.IndexOf("group")>=0)
}
if (str.IndexOf("group")>=0)
{
return "Group";
}
return "Any";
}
......@@ -256,13 +294,17 @@ static void AddArgs(string texts,string regx,string arg,SortedList<int,string> d
string v=arg;
int k=int.Parse(m.Groups[1].Value);
if(dic.ContainsKey(k))
{
dic[k] = dic[k]+"|"+v;
}
else
{
dic.Add(k,v);
}
}
}
static string FindArgs(string texts,string name)
}
static string FindArgs(string texts)
{
SortedList<int,string> dic=new SortedList<int, string>();
//card effect ggroup
......@@ -276,9 +318,13 @@ static string FindArgs(string texts,string name)
v = getUserType(v);
int k=int.Parse(m.Groups[2].Value);
if(dic.ContainsKey(k))
{
dic[k] = dic[k]+"|"+v;
}
else
{
dic.Add(k,v);
}
}
}
//function
......@@ -298,7 +344,10 @@ static string FindArgs(string texts,string name)
args +=dic[i]+", ";
}
if(args.Length>1)
{
args = args.Substring(0,args.Length-2);
}
args += ")";
return args;
}
......@@ -308,8 +357,11 @@ static string FindArgs(string texts,string name)
//查找旧函数的描述
static string FindOldDesc(string name)
{
if(funclist.ContainsKey(name))
return funclist[name];
if(_funclist.ContainsKey(name))
{
return _funclist[name];
}
return "";
}
#endregion
......@@ -337,19 +389,19 @@ public static void GetFunctions(string name,string texts,string file)
{
StreamWriter sw=new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine("========== "+name+" ==========");
File.AppendAllText(funclisttxt, "========== " + name + " ==========" + Environment.NewLine);
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,v)+k+FindArgs(code,v)
string txt="●"+FindReturn(code)+k+FindArgs(code)
+Environment.NewLine
+FindOldDesc(k)
+Environment.NewLine
+code;
sw.WriteLine(txt);
File.AppendAllText(funclisttxt,txt + Environment.NewLine);
File.AppendAllText(_funclisttxt,txt + Environment.NewLine);
}
sw.Close();
}
......
......@@ -31,7 +31,10 @@ public CardPack(long id)
public string getMseRarity(){
if(this.rarity==null)
{
return "common";
}
string rarity=this.rarity.Trim().ToLower();
if(rarity.Equals("common") || rarity.Equals("short print"))
{
......
......@@ -63,76 +63,99 @@ public class MSEConfig
#endregion
public MSEConfig(string path)
{
init(path);
this.init(path);
}
public void SetConfig(string config, string path)
{
if (!File.Exists(config))
{
return;
regx_monster = "(\\s\\S*?)";
regx_pendulum = "(\\s\\S*?)";
}
this.regx_monster = "(\\s\\S*?)";
this.regx_pendulum = "(\\s\\S*?)";
//设置文件名
configName = MyPath.getFullFileName(MSEConfig.TAG, config);
this.configName = MyPath.getFullFileName(MSEConfig.TAG, config);
replaces = new SortedList<string, string>();
this.replaces = new SortedList<string, string>();
typeDic = new SortedList<long, string>();
raceDic = new SortedList<long, string>();
this.typeDic = new SortedList<long, string>();
this.raceDic = new SortedList<long, string>();
string[] lines = File.ReadAllLines(config, Encoding.UTF8);
foreach (string line in lines)
{
if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
{
continue;
}
if (line.StartsWith(TAG_CN2TW))
Iscn2tw = ConfHelper.getBooleanValue(line);
{
this.Iscn2tw = ConfHelper.getBooleanValue(line);
}
else if (line.StartsWith(TAG_SPELL))
str_spell = ConfHelper.getValue(line);
{
this.str_spell = ConfHelper.getValue(line);
}
else if (line.StartsWith(TAG_HEAD))
head = ConfHelper.getMultLineValue(line);
{
this.head = ConfHelper.getMultLineValue(line);
}
else if (line.StartsWith(TAG_END))
end = ConfHelper.getMultLineValue(line);
{
this.end = ConfHelper.getMultLineValue(line);
}
else if (line.StartsWith(TAG_TEXT))
temp_text = ConfHelper.getMultLineValue(line);
{
this.temp_text = ConfHelper.getMultLineValue(line);
}
else if (line.StartsWith(TAG_TRAP))
str_trap = ConfHelper.getValue(line);
{
this.str_trap = ConfHelper.getValue(line);
}
else if (line.StartsWith(TAG_REG_PENDULUM))
regx_pendulum = ConfHelper.getValue(line);
{
this.regx_pendulum = ConfHelper.getValue(line);
}
else if (line.StartsWith(TAG_REG_MONSTER))
regx_monster = ConfHelper.getValue(line);
{
this.regx_monster = ConfHelper.getValue(line);
}
else if (line.StartsWith(TAG_MAXCOUNT))
maxcount = ConfHelper.getIntegerValue(line, 0);
{
this.maxcount = ConfHelper.getIntegerValue(line, 0);
}
else if (line.StartsWith(TAG_WIDTH)){
width=ConfHelper.getIntegerValue(line,0);
this.width =ConfHelper.getIntegerValue(line,0);
}
else if (line.StartsWith(TAG_HEIGHT)){
height=ConfHelper.getIntegerValue(line,0);
this.height =ConfHelper.getIntegerValue(line,0);
}
else if (line.StartsWith(TAG_PEND_WIDTH)){
pwidth=ConfHelper.getIntegerValue(line,0);
this.pwidth =ConfHelper.getIntegerValue(line,0);
}
else if (line.StartsWith(TAG_PEND_HEIGHT)){
pheight=ConfHelper.getIntegerValue(line,0);
this.pheight =ConfHelper.getIntegerValue(line,0);
}
else if(line.StartsWith(TAG_NO_TEN)){
no10 = ConfHelper.getBooleanValue(line);
this.no10 = ConfHelper.getBooleanValue(line);
}else if(line.StartsWith(TAG_NO_START_CARDS)){
string val = ConfHelper.getValue(line);
string[] cs = val.Split(',');
noStartCards=new long[cs.Length];
this.noStartCards =new long[cs.Length];
int i=0;
foreach(string str in cs){
long l = 0;
long.TryParse(str, out l);
noStartCards[i++] = l;
long.TryParse(str, out long l);
this.noStartCards[i++] = l;
}
}
else if (line.StartsWith(TAG_IMAGE))
{
//如果路径不合法,则为后面的路径
imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, PATH_IMAGE));
this.imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, PATH_IMAGE));
//图片缓存目录
imagecache = MyPath.Combine(imagepath, "cache");
MyPath.CreateDir(imagecache);
this.imagecache = MyPath.Combine(this.imagepath, "cache");
MyPath.CreateDir(this.imagecache);
}
else if (line.StartsWith(TAG_REPALCE))
{//特数字替换
......@@ -140,24 +163,25 @@ public void SetConfig(string config, string path)
string p = ConfHelper.getRegex(ConfHelper.getValue1(word));
string r = ConfHelper.getRegex(ConfHelper.getValue2(word));
if (!string.IsNullOrEmpty(p))
replaces.Add(p, r);
{
this.replaces.Add(p, r);
}
}
else if (line.StartsWith(TAG_RACE))
{//种族
ConfHelper.DicAdd(raceDic, line);
ConfHelper.DicAdd(this.raceDic, line);
}
else if (line.StartsWith(TAG_TYPE))
{//类型
ConfHelper.DicAdd(typeDic, line);
ConfHelper.DicAdd(this.typeDic, line);
}else if(line.StartsWith(TAG_REIMAGE)){
reimage = ConfHelper.getBooleanValue(line);
this.reimage = ConfHelper.getBooleanValue(line);
}
}
}
public void init(string path)
{
Iscn2tw = false;
this.Iscn2tw = false;
//读取配置
string tmp = MyPath.Combine(path, MyPath.getFileName(MSEConfig.TAG, MyConfig.readString(MyConfig.TAG_MSE)));
......@@ -166,9 +190,11 @@ public void init(string path)
{
tmp = MyPath.Combine(path, MyPath.getFileName(MSEConfig.TAG, FILE_CONFIG_NAME));
if(!File.Exists(tmp))
{
return;//如果默认的也不存在
}
SetConfig(tmp, path);
}
this.SetConfig(tmp, path);
}
/// <summary>
/// 是否调整图片
......
This diff is collapsed.
......@@ -43,7 +43,7 @@ public class CardInfo{
public string copyright;
public override string ToString()
{
return string.Format("[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]", title, artwork, artwork_crop, background, rarity, attribute, level, icon, description, pendulum_description, pendulum_scales, subtypes, atk, def, edition, set, card_number, limitation, sticker, copyright);
return string.Format("[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]", this.title, this.artwork, this.artwork_crop, this.background, this.rarity, this.attribute, this.level, this.icon, this.description, this.pendulum_description, this.pendulum_scales, this.subtypes, this.atk, this.def, this.edition, this.set, this.card_number, this.limitation, this.sticker, this.copyright);
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -520,7 +520,7 @@ private void InitializeComponent()
this.tb_cardname.Location = new System.Drawing.Point(5, 3);
this.tb_cardname.Name = "tb_cardname";
this.tb_cardname.Size = new System.Drawing.Size(339, 21);
this.tb_cardname.TabIndex = 4;
this.tb_cardname.TabIndex = 1;
this.tb_cardname.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.tb_cardname.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Tb_cardnameKeyDown);
//
......@@ -643,7 +643,8 @@ private void InitializeComponent()
this.tb_cardtext.Name = "tb_cardtext";
this.tb_cardtext.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tb_cardtext.Size = new System.Drawing.Size(340, 200);
this.tb_cardtext.TabIndex = 4;
this.tb_cardtext.TabIndex = 121;
this.tb_cardtext.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tb_cardtext_KeyDown);
//
// tb_edittext
//
......@@ -675,7 +676,7 @@ private void InitializeComponent()
this.tb_pleft.MaxLength = 12;
this.tb_pleft.Name = "tb_pleft";
this.tb_pleft.Size = new System.Drawing.Size(40, 21);
this.tb_pleft.TabIndex = 8;
this.tb_pleft.TabIndex = 115;
this.tb_pleft.Text = "0";
this.tb_pleft.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
......@@ -685,7 +686,7 @@ private void InitializeComponent()
this.tb_pright.MaxLength = 12;
this.tb_pright.Name = "tb_pright";
this.tb_pright.Size = new System.Drawing.Size(40, 21);
this.tb_pright.TabIndex = 8;
this.tb_pright.TabIndex = 116;
this.tb_pright.Text = "0";
this.tb_pright.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
......@@ -780,7 +781,7 @@ private void InitializeComponent()
this.tb_atk.MaxLength = 12;
this.tb_atk.Name = "tb_atk";
this.tb_atk.Size = new System.Drawing.Size(40, 21);
this.tb_atk.TabIndex = 8;
this.tb_atk.TabIndex = 117;
this.tb_atk.Text = "0";
this.tb_atk.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
......@@ -790,7 +791,7 @@ private void InitializeComponent()
this.tb_def.MaxLength = 12;
this.tb_def.Name = "tb_def";
this.tb_def.Size = new System.Drawing.Size(40, 21);
this.tb_def.TabIndex = 8;
this.tb_def.TabIndex = 118;
this.tb_def.Text = "0";
this.tb_def.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
......@@ -801,7 +802,7 @@ private void InitializeComponent()
this.tb_cardcode.MaxLength = 12;
this.tb_cardcode.Name = "tb_cardcode";
this.tb_cardcode.Size = new System.Drawing.Size(67, 21);
this.tb_cardcode.TabIndex = 8;
this.tb_cardcode.TabIndex = 120;
this.tb_cardcode.Text = "0";
this.tb_cardcode.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tb_cardcode.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Tb_cardcodeKeyPress);
......@@ -823,7 +824,7 @@ private void InitializeComponent()
this.tb_cardalias.MaxLength = 12;
this.tb_cardalias.Name = "tb_cardalias";
this.tb_cardalias.Size = new System.Drawing.Size(67, 21);
this.tb_cardalias.TabIndex = 8;
this.tb_cardalias.TabIndex = 119;
this.tb_cardalias.Text = "0";
this.tb_cardalias.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
......@@ -984,7 +985,7 @@ private void InitializeComponent()
this.tb_setcode1.MaxLength = 4;
this.tb_setcode1.Name = "tb_setcode1";
this.tb_setcode1.Size = new System.Drawing.Size(30, 21);
this.tb_setcode1.TabIndex = 18;
this.tb_setcode1.TabIndex = 111;
this.tb_setcode1.Text = "0";
this.tb_setcode1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tb_setcode1.TextChanged += new System.EventHandler(this.tb_setcode1_TextChanged);
......@@ -996,7 +997,7 @@ private void InitializeComponent()
this.tb_setcode2.MaxLength = 4;
this.tb_setcode2.Name = "tb_setcode2";
this.tb_setcode2.Size = new System.Drawing.Size(30, 21);
this.tb_setcode2.TabIndex = 18;
this.tb_setcode2.TabIndex = 112;
this.tb_setcode2.Text = "0";
this.tb_setcode2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tb_setcode2.TextChanged += new System.EventHandler(this.tb_setcode2_TextChanged);
......@@ -1008,7 +1009,7 @@ private void InitializeComponent()
this.tb_setcode3.MaxLength = 4;
this.tb_setcode3.Name = "tb_setcode3";
this.tb_setcode3.Size = new System.Drawing.Size(30, 21);
this.tb_setcode3.TabIndex = 18;
this.tb_setcode3.TabIndex = 113;
this.tb_setcode3.Text = "0";
this.tb_setcode3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tb_setcode3.TextChanged += new System.EventHandler(this.tb_setcode3_TextChanged);
......@@ -1020,7 +1021,7 @@ private void InitializeComponent()
this.tb_setcode4.MaxLength = 4;
this.tb_setcode4.Name = "tb_setcode4";
this.tb_setcode4.Size = new System.Drawing.Size(30, 21);
this.tb_setcode4.TabIndex = 18;
this.tb_setcode4.TabIndex = 114;
this.tb_setcode4.Text = "0";
this.tb_setcode4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.tb_setcode4.TextChanged += new System.EventHandler(this.tb_setcode4_TextChanged);
......@@ -1248,7 +1249,7 @@ private void InitializeComponent()
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "DataEditorX";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DataEditFormFormClosing);
this.Load += new System.EventHandler(this.DataEditFormLoad);
this.Load += new System.EventHandler(this.DataEditForm_Load);
this.SizeChanged += new System.EventHandler(this.DataEditFormSizeChanged);
this.Enter += new System.EventHandler(this.DataEditFormEnter);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DataEditForm_KeyDown);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -31,14 +31,16 @@ private static void Main(string[] args)
Environment.Exit(1);
}
if (MyConfig.OpenOnExistForm(arg))//在已经存在的窗口打开文件
{
Environment.Exit(1);
}
else//新建窗口
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MainForm mainForm = new MainForm();
//设置将要打开的文件
mainForm.setOpenFile(arg);
mainForm.SetOpenFile(arg);
//数据目录
mainForm.SetDataPath(MyPath.Combine(Application.StartupPath, MyConfig.TAG_DATA));
......
★更新历史
2.4.3.7
增加了一些自动完成
2.4.3.6
UI位置调整
2.4.3.5
......
This diff is collapsed.
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