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;
}
}
......
......@@ -71,6 +71,7 @@ private void InitializeComponent()
this.host = new System.Windows.Forms.Integration.ElementHost();
this.editor = new ICSharpCode.AvalonEdit.TextEditor();
this.lbTooltip = new System.Windows.Forms.Label();
this.setCodeEditorFontToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mainMenu.SuspendLayout();
this.SuspendLayout();
//
......@@ -140,7 +141,8 @@ private void InitializeComponent()
this.menuitem_showinput,
this.menuitem_find,
this.menuitem_replace,
this.menuitem_tooltipFont});
this.menuitem_tooltipFont,
this.setCodeEditorFontToolStripMenuItem});
this.menuitem_setting.Name = "menuitem_setting";
this.menuitem_setting.Size = new System.Drawing.Size(75, 20);
this.menuitem_setting.Text = "Settings(&S)";
......@@ -190,7 +192,7 @@ private void InitializeComponent()
//
this.menuitem_testlua.Name = "menuitem_testlua";
this.menuitem_testlua.ShortcutKeys = System.Windows.Forms.Keys.F5;
this.menuitem_testlua.Size = new System.Drawing.Size(164, 22);
this.menuitem_testlua.Size = new System.Drawing.Size(180, 22);
this.menuitem_testlua.Text = "Syntax Check";
this.menuitem_testlua.Click += new System.EventHandler(this.menuitem_testlua_Click);
//
......@@ -198,7 +200,7 @@ private void InitializeComponent()
//
this.menuitem_effectcreator.Name = "menuitem_effectcreator";
this.menuitem_effectcreator.ShortcutKeys = System.Windows.Forms.Keys.F3;
this.menuitem_effectcreator.Size = new System.Drawing.Size(164, 22);
this.menuitem_effectcreator.Size = new System.Drawing.Size(180, 22);
this.menuitem_effectcreator.Text = "Effect Creator";
this.menuitem_effectcreator.Visible = false;
this.menuitem_effectcreator.Click += new System.EventHandler(this.effectCreatorToolStripMenuItem_Click);
......@@ -231,6 +233,7 @@ private void InitializeComponent()
//
// documentMap1
//
this.documentMap1.AllowDrop = true;
this.documentMap1.BackColor = System.Drawing.Color.DimGray;
this.documentMap1.Dock = System.Windows.Forms.DockStyle.Right;
this.documentMap1.ForeColor = System.Drawing.Color.Maroon;
......@@ -244,6 +247,7 @@ private void InitializeComponent()
//
// host
//
this.host.AllowDrop = true;
this.host.Dock = System.Windows.Forms.DockStyle.Fill;
this.host.Location = new System.Drawing.Point(0, 24);
this.host.Name = "host";
......@@ -264,6 +268,13 @@ private void InitializeComponent()
this.lbTooltip.TabIndex = 6;
this.lbTooltip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lbTooltip_MouseMove);
//
// setCodeEditorFontToolStripMenuItem
//
this.setCodeEditorFontToolStripMenuItem.Name = "setCodeEditorFontToolStripMenuItem";
this.setCodeEditorFontToolStripMenuItem.Size = new System.Drawing.Size(184, 22);
this.setCodeEditorFontToolStripMenuItem.Text = "Set CodeEditor Font";
this.setCodeEditorFontToolStripMenuItem.Click += new System.EventHandler(this.setCodeEditorFontToolStripMenuItem_Click);
//
// CodeEditForm_Avalon
//
this.AllowDrop = true;
......@@ -297,10 +308,67 @@ private void InitializeComponent()
CompletionWindow completionWindowUse = null;
int lastOffset = 0;
List<FunctionParamsAutoCompletion> functionCompletions = new List<FunctionParamsAutoCompletion>()
{
new FunctionParamsAutoCompletion("con(e,tp,eg,ep,ev,re,r,rp)\n\nend", "condition默认参数", 3),
new FunctionParamsAutoCompletion("cond(e,tp,eg,ep,ev,re,r,rp)\n\nend", "condition默认参数", 4),
new FunctionParamsAutoCompletion("cost(e,tp,eg,ep,ev,re,r,rp,chk)\n\nend", "cost默认参数", 4),
new FunctionParamsAutoCompletion("op(e,tp,eg,ep,ev,re,r,rp)\n\nend", "operation默认参数", 2),
new FunctionParamsAutoCompletion("tg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)\n\nend", "target默认参数", 2),
new FunctionParamsAutoCompletion("filter(c,e,tp)\n\nend", "filter常用参数", 6),
new FunctionParamsAutoCompletion("con2(e,tp,eg,ep,ev,re,r,rp)\n\nend", "condition默认参数", 3),
new FunctionParamsAutoCompletion("cond2(e,tp,eg,ep,ev,re,r,rp)\n\nend", "condition默认参数", 4),
new FunctionParamsAutoCompletion("cost2(e,tp,eg,ep,ev,re,r,rp,chk)\n\nend", "cost默认参数", 4),
new FunctionParamsAutoCompletion("op2(e,tp,eg,ep,ev,re,r,rp)\n\nend", "operation默认参数", 2),
new FunctionParamsAutoCompletion("tg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)\n\nend", "target默认参数", 2),
new FunctionParamsAutoCompletion("filter2(c,e,tp)\n\nend", "filter常用参数", 6),
new FunctionParamsAutoCompletion("con3(e,tp,eg,ep,ev,re,r,rp)\n\nend", "condition默认参数", 3),
new FunctionParamsAutoCompletion("cond3(e,tp,eg,ep,ev,re,r,rp)\n\nend", "condition默认参数", 4),
new FunctionParamsAutoCompletion("cost3(e,tp,eg,ep,ev,re,r,rp,chk)\n\nend", "cost默认参数", 4),
new FunctionParamsAutoCompletion("op3(e,tp,eg,ep,ev,re,r,rp)\n\nend", "operation默认参数", 2),
new FunctionParamsAutoCompletion("tg3(e,tp,eg,ep,ev,re,r,rp,chk,chkc)\n\nend", "target默认参数", 2),
new FunctionParamsAutoCompletion("filter3(c,e,tp)\n\nend", "filter常用参数", 6),
};
private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
{
// Open code completion after the user has pressed dot:
if (sep.Contains(e.Text) || e.Text.Length > 1)
{
return;
}
IList<ICompletionData> data = new List<ICompletionData>();
string find = editor.Document.GetText(Math.Min(lastOffset, editor.Document.TextLength)
, Math.Max(0, editor.CaretOffset - lastOffset));
if (string.IsNullOrEmpty(find) || find.Length < 2)
{
return;
}
bool found = false;
foreach (var cp in functionCompletions)
{
if (find.EndsWith(cp.Text.Substring(0, cp.SuffixLength)))
{
found = true;
break;
}
}
if (!found)
{
find = find.ToLower();
foreach (var d in tooltipDic)
{
if (d.Key.ToLower().StartsWith(find))
{
found = true;
break;
}
}
}
if (!found)
{
return;
}
completionWindowUse = new CompletionWindow(editor.TextArea);
data = completionWindowUse.CompletionList.CompletionData;
completionWindowUse.Closed += delegate
{
completionWindowUse = null;
......@@ -311,15 +379,16 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs
{
completionWindowUse.EndOffset = completionWindowUse.StartOffset;
}
IList<ICompletionData> data = completionWindowUse.CompletionList.CompletionData;
string find = editor.Document.GetText(lastOffset, completionWindowUse.EndOffset - completionWindowUse.StartOffset);
if (string.IsNullOrEmpty(find))
foreach (var cp in functionCompletions)
{
return;
if (find.EndsWith(cp.Text.Substring(0, cp.SuffixLength)))
{
data.Add(cp);
}
}
foreach (var d in tooltipDic)
{
if (d.Key.ToLower().StartsWith(find.ToLower()))
if (d.Key.ToLower().StartsWith(find))
{
data.Add(new YGOProAutoCompletion(d.Key, d.Value));
}
......@@ -334,16 +403,52 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs
lbTooltip.Text = find2 + "\n" + tooltipDic[find2];
lbTooltip.Location = new System.Drawing.Point(Math.Min((int)ePos.X + 800, host.Width - 500), Math.Min((int)ePos.Y, this.Height - lbTooltip.Height - 20));
}
completionWindowUse.Closed += delegate {
completionWindowUse = null;
};
}
}
internal class FunctionParamsAutoCompletion : ICompletionData
{
public FunctionParamsAutoCompletion(string text, string description, int suffixLength)
{
this.Text = text;
this.SuffixLength = suffixLength;
_description = description;
}
public System.Windows.Media.ImageSource Image
{
get { return null; }
}
public string Text { get; private set; }
private string _description;
// Use this property if you want to show a fancy UIElement in the list.
public object Content
{
get { return this.Text; }
}
public object Description
{
get { return _description; }
}
public double Priority
{
get { return 0; }
}
public int SuffixLength = 0;
public void Complete(TextArea textArea, ISegment completionSegment,
EventArgs insertionRequestEventArgs)
{
textArea.Document.Replace(completionSegment.Offset + completionSegment.Length - SuffixLength, SuffixLength, this.Text);
}
}
private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
CompletionListBox lb = (CompletionListBox)sender;
if (lb.SelectedItem == null)
if (lb.SelectedItem == null || !(lb.SelectedItem is YGOProAutoCompletion))
{
return;
}
......@@ -443,5 +548,6 @@ public double Priority
ICSharpCode.AvalonEdit.TextEditor editor;
private Label lbTooltip;
private ToolStripMenuItem menuitem_tooltipFont;
private ToolStripMenuItem setCodeEditorFontToolStripMenuItem;
}
}
......@@ -10,22 +10,21 @@
using DataEditorX.Core;
using DataEditorX.Language;
using FastColoredTextBoxNS;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using ICSharpCode.AvalonEdit.Search;
using Neo.IronLua;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using System.Xml;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Search;
using System.Windows.Threading;
using System.Text.RegularExpressions;
using ICSharpCode.AvalonEdit.CodeCompletion;
using WeifenLuo.WinFormsUI.Docking;
namespace DataEditorX
{
......@@ -60,19 +59,38 @@ void InitForm()
editor.TextArea.TextEntered += editor_TextArea_TextEntered;
editor.TextArea.TextEntering += editor_TextArea_TextEntering;
editor.PreviewKeyDown += TextArea_KeyDown;
//editor.TextArea.KeyDown += TextArea_KeyDown;
//editor.KeyDown += TextArea_KeyDown;
editor.TextChanged += Editor_TextChanged;
editor.MouseMove += Editor_MouseMove;
editor.FontFamily = new System.Windows.Media.FontFamily(MyConfig.TAG_FONT_NAME);
editor.FontSize = MyConfig.ReadFloat(MyConfig.TAG_FONT_SIZE, (float)editor.FontSize);
editor.WordWrap = MyConfig.ReadBoolean(MyConfig.TAG_WORDWRAP);
editor.PreviewMouseWheel += Editor_MouseWheel;
editor.FontFamily = new System.Windows.Media.FontFamily(DEXConfig.ReadString(DEXConfig.TAG_FONT_NAME));
editor.FontSize = DEXConfig.ReadFloat(DEXConfig.TAG_FONT_SIZE, (float)editor.FontSize);
editor.TextArea.FontFamily = editor.FontFamily;
editor.TextArea.FontSize = editor.FontSize;
editor.WordWrap = DEXConfig.ReadBoolean(DEXConfig.TAG_WORDWRAP);
editor.Background = System.Windows.Media.Brushes.Black;
editor.Foreground = System.Windows.Media.Brushes.GhostWhite;
this.RefreshHighlighting();
}
private void Editor_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
{
double add = editor.TextArea.FontSize + (e.Delta > 0 ? 1 : -1);
if (add > 100)
{
add = 100;
}
if (add < 8)
{
add = 8;
}
editor.TextArea.FontSize = add;
editor.FontSize = add;
DEXConfig.Save(DEXConfig.TAG_FONT_SIZE, ((int)add).ToString());
}
}
private void Editor_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
var ePos = e.GetPosition(editor);
......@@ -175,21 +193,6 @@ private int FindMainRuleSetIndex(XshdSyntaxDefinition definition)
}
return -1;
}
private int FindXshdColorByName(XshdSyntaxDefinition definition, string name)
{
if (definition == null)
{
return -1;
}
for (int i = 0; i < definition.Elements.Count; i++)
{
if (definition.Elements[i] is XshdRuleSet && definition.Elements[i] != null && (definition.Elements[i] as XshdRuleSet).Name == null)
{
return i;
}
}
return -1;
}
private void RefreshHighlighting()
{
using (XmlReader reader = new XmlTextReader("data\\avalon.xshd"))
......@@ -200,19 +203,25 @@ private void RefreshHighlighting()
string cName = this.Text.Substring(0, this.Text.Length - 4);
var cRule = new XshdKeywords();
cRule.Words.Add(cName);
XshdColor color = new XshdColor();
color.Name = "cFunction";
color.Foreground = new SimpleHighlightingBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x92, 0x1A, 0xFF));
color.FontWeight = System.Windows.FontWeights.Bold;
XshdColor color = new XshdColor
{
Name = "cFunction",
Foreground = new SimpleHighlightingBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x92, 0x1A, 0xFF)),
FontWeight = System.Windows.FontWeights.Bold
};
cRule.ColorReference = new XshdReference<XshdColor>(color);
(gLua.Elements[this.FindMainRuleSetIndex(gLua)] as XshdRuleSet).Elements.Insert(0, cRule);
var cRule2 = new XshdRule();
cRule2.Regex = @"\b(" + cName + @"\.[A-Za-z0-9_]+)";
XshdColor color2 = new XshdColor();
color2.Name = "cFunction2";
color2.Foreground = new SimpleHighlightingBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x92, 0x1A, 0xFF));
color2.FontWeight = System.Windows.FontWeights.Bold;
var cRule2 = new XshdRule
{
Regex = @"\b(" + cName + @"\.[A-Za-z0-9_]+)"
};
XshdColor color2 = new XshdColor
{
Name = "cFunction2",
Foreground = new SimpleHighlightingBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x92, 0x1A, 0xFF)),
FontWeight = System.Windows.FontWeights.Bold
};
cRule2.ColorReference = new XshdReference<XshdColor>(color2);
(gLua.Elements[this.FindMainRuleSetIndex(gLua)] as XshdRuleSet).Elements.Insert(0, cRule2);
}
......@@ -223,11 +232,7 @@ private void RefreshHighlighting()
internal void InitTooltip(CodeConfig codecfg)
{
this.tooltipDic = codecfg.TooltipDic;
foreach(var item in this.tooltipDic)
{
AutocompleteItem it = new AutocompleteItem();
this.items = codecfg.Items;
}
this.items = codecfg.Items;
}
#endregion
......@@ -250,7 +255,7 @@ public bool Create(string file)
}
public bool Save()
{
return savefile(string.IsNullOrEmpty(nowFile));
return SaveFile(string.IsNullOrEmpty(nowFile));
}
public bool Open(string file)
{
......@@ -268,10 +273,14 @@ public bool Open(string file)
//(this.fctb.SyntaxHighlighter as MySyntaxHighlighter).cCode
// = fi.Name.Substring(0, fi.Name.Length - 4);
}
string cdb = MyPath.Combine(
Path.GetDirectoryName(file), "../cards.cdb");
//SetCardDB(cdb);//后台加载卡片数据
editor.Text = File.ReadAllText(file, new UTF8Encoding(false));
Regex regex = new Regex(@"c([0-9]+)\.lua");
var match = regex.Match(fi.Name.ToLower());
if (match.Success)
{
string code = match.Groups[1].Value;
functionCompletions.Add(new FunctionParamsAutoCompletion($"e1=Effect.CreateEffect(c)\n\te1:SetType(EFFECT_TYPE_)\n\te1:SetCode()\n\te1:SetCategory(CATEGORY_)\n\te1:SetRange(LOCATION_)\n\te1:SetDescription(aux.Stringid({code},0))\n\te1:SetCondition(c{code}.con)\n\te1:SetProperty(EFFECT_FLAG_)\n\te1:SetCost(c{code}.cost)\n\te1:SetTarget(c{code}.tg)\n\te1:SetOperation(c{code}.op)\n\tc:RegisterEffect(e1)", "效果模板", 2));
}
oldtext = editor.Text;
this.SetTitle();
this.RefreshHighlighting();
......@@ -380,7 +389,7 @@ void FctbToolTipNeeded(object sender, ToolTipNeededEventArgs e)
#endregion
#region 保存文件
bool savefile(bool saveas)
bool SaveFile(bool saveas)
{
string alltext = this.editor.Text;
if (!tabisspaces)
......@@ -415,7 +424,7 @@ bool savefile(bool saveas)
public bool SaveAs()
{
return savefile(true);
return SaveFile(true);
}
void SaveToolStripMenuItemClick(object sender, EventArgs e)
......@@ -443,33 +452,23 @@ void Menuitem_showinputClick(object sender, EventArgs e)
tb_input.Visible = true;
}
}
//如果是作为mdi,则隐藏菜单
void HideMenu()
{
if (MdiParent == null)
{
return;
}
mainMenu.Visible = false;
menuitem_file.Visible = false;
menuitem_file.Enabled = false;
}
void CodeEditFormLoad(object sender, EventArgs e)
{
ICSharpCode.AvalonEdit.TextEditor editor = new ICSharpCode.AvalonEdit.TextEditor();
ICSharpCode.AvalonEdit.Rendering.TextView eView = new ICSharpCode.AvalonEdit.Rendering.TextView();
Font f = new Font("微软雅黑", 14, FontStyle.Bold);
string fontJson = MyConfig.ReadString(MyConfig.TOOLTIP_FONT);
string fontJson = DEXConfig.ReadString(DEXConfig.TOOLTIP_FONT);
JavaScriptSerializer jss = new JavaScriptSerializer();
try
{
f = jss.Deserialize<FontHelper>(fontJson).ToFont();
}
catch { }
catch
{
DEXConfig.Save(DEXConfig.TOOLTIP_FONT, jss.Serialize(f));
}
lbTooltip.Font = f;
}
SearchPanel sp = null;
void Menuitem_findClick(object sender, EventArgs e)
{
......@@ -531,8 +530,10 @@ private void BtnFind_Click(object sender, EventArgs e)
{
string text = editor.Text;
string findStr = frForm.txtFind.Text;
var rtxt = new RichTextBox();
rtxt.Text = text;
var rtxt = new RichTextBox
{
Text = text
};
if (findStart < 0)
{
......@@ -544,7 +545,7 @@ private void BtnFind_Click(object sender, EventArgs e)
var line = editor.Document.GetLineByOffset(findStart).LineNumber;
editor.ScrollTo(line, 0);
editor.Select(findStart, findStr.Length);
findStart = findStart + findStr.Length;
findStart += findStr.Length;
}
}
void QuitToolStripMenuItemClick(object sender, EventArgs e)
......@@ -594,9 +595,11 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
list.Add(item);
}
}
completionWindowUse = new CompletionWindow(editor.TextArea);
completionWindowUse.StartOffset = editor.CaretOffset;
completionWindowUse.EndOffset = editor.CaretOffset;
completionWindowUse = new CompletionWindow(editor.TextArea)
{
StartOffset = editor.CaretOffset,
EndOffset = editor.CaretOffset
};
IList<ICompletionData> data = completionWindowUse.CompletionList.CompletionData;
if (string.IsNullOrEmpty(key))
{
......@@ -619,7 +622,8 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
lbTooltip.Text = find2 + "\n" + tooltipDic[find2];
lbTooltip.Location = new Point(Math.Min((int)ePos.X + 800, host.Width - 500), Math.Min((int)ePos.Y, this.Height - lbTooltip.Height - 20));
}
completionWindowUse.Closed += delegate {
completionWindowUse.Closed += delegate
{
completionWindowUse = null;
};
}
......@@ -722,12 +726,11 @@ 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);
JavaScriptSerializer jss = new JavaScriptSerializer();
fd.Font = lbTooltip.Font;
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));
lbTooltip.Font = fd.Font;
}
}
......@@ -763,5 +766,24 @@ private void CodeEditForm_Avalon_KeyDown(object sender, KeyEventArgs e)
{
;
}
private void setCodeEditorFontToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
fd.MaxSize = 100;
fd.MinSize = 8;
fd.Font = new Font(DEXConfig.ReadString(DEXConfig.TAG_FONT_NAME), (float)editor.FontSize);
if (fd.ShowDialog() == DialogResult.OK)
{
try
{
editor.TextArea.FontFamily = new System.Windows.Media.FontFamily(fd.Font.FontFamily.Name);
editor.TextArea.FontSize = fd.Font.Size;
DEXConfig.Save(DEXConfig.TAG_FONT_NAME, fd.Font.FontFamily.Name);
DEXConfig.Save(DEXConfig.TAG_FONT_SIZE, fd.Font.Size.ToString());
}
catch { }
}
}
}
}
......@@ -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 source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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