Commit 8f7dac84 authored by JoyJ's avatar JoyJ

cleanup and fixes

parent 84ca87cb
...@@ -54,15 +54,15 @@ void InitForm() ...@@ -54,15 +54,15 @@ void InitForm()
this.tooltipDic = new SortedList<string, string>(); this.tooltipDic = new SortedList<string, string>();
this.InitializeComponent(); this.InitializeComponent();
//设置字体,大小 //设置字体,大小
string fontname = MyConfig.ReadString(MyConfig.TAG_FONT_NAME); string fontname = DEXConfig.ReadString(DEXConfig.TAG_FONT_NAME);
float fontsize = MyConfig.ReadFloat(MyConfig.TAG_FONT_SIZE, this.fctb.Font.Size); float fontsize = DEXConfig.ReadFloat(DEXConfig.TAG_FONT_SIZE, this.fctb.Font.Size);
this.fctb.Font = new Font(fontname, fontsize); this.fctb.Font = new Font(fontname, fontsize);
if (MyConfig.ReadBoolean(MyConfig.TAG_IME)) if (DEXConfig.ReadBoolean(DEXConfig.TAG_IME))
{ {
this.fctb.ImeMode = ImeMode.On; this.fctb.ImeMode = ImeMode.On;
} }
if (MyConfig.ReadBoolean(MyConfig.TAG_WORDWRAP)) if (DEXConfig.ReadBoolean(DEXConfig.TAG_WORDWRAP))
{ {
this.fctb.WordWrap = true; this.fctb.WordWrap = true;
} }
...@@ -71,7 +71,7 @@ void InitForm() ...@@ -71,7 +71,7 @@ void InitForm()
this.fctb.WordWrap = false; this.fctb.WordWrap = false;
} }
if (MyConfig.ReadBoolean(MyConfig.TAG_TAB2SPACES)) if (DEXConfig.ReadBoolean(DEXConfig.TAG_TAB2SPACES))
{ {
this.tabisspaces = true; this.tabisspaces = true;
} }
...@@ -406,18 +406,6 @@ void Menuitem_showinputClick(object sender, EventArgs e) ...@@ -406,18 +406,6 @@ void Menuitem_showinputClick(object sender, EventArgs e)
this.tb_input.Visible = true; 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) void CodeEditFormLoad(object sender, EventArgs e)
{ {
...@@ -472,7 +460,7 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e) ...@@ -472,7 +460,7 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.Enter) if (e.KeyCode == Keys.Enter)
{ {
string key = this.tb_input.Text; string key = this.tb_input.Text;
List<AutocompleteItem> list =new List<AutocompleteItem>(); List<AutocompleteItem> list = new List<AutocompleteItem>();
foreach (AutocompleteItem item in this.items) foreach (AutocompleteItem item in this.items)
{ {
if (item.ToolTipText.Contains(key)) if (item.ToolTipText.Contains(key))
...@@ -619,8 +607,8 @@ private void menuitem_testlua_Click(object sender, EventArgs e) ...@@ -619,8 +607,8 @@ private void menuitem_testlua_Click(object sender, EventArgs e)
{ {
return; return;
} }
string cCode = fn.Substring(0,fn.Length - 4); string cCode = fn.Substring(0, fn.Length - 4);
bool error=false; bool error = false;
try try
{ {
Directory.SetCurrentDirectory(fi.DirectoryName); Directory.SetCurrentDirectory(fi.DirectoryName);
...@@ -683,8 +671,8 @@ private void OnDragDtop(object sender, DragEventArgs e) ...@@ -683,8 +671,8 @@ private void OnDragDtop(object sender, DragEventArgs e)
private void menuitem_tooltipFont_Click(object sender, EventArgs e) private void menuitem_tooltipFont_Click(object sender, EventArgs e)
{ {
FontDialog fd = new FontDialog(); FontDialog fd = new FontDialog();
string fontJson = MyConfig.ReadString(MyConfig.TOOLTIP_FONT); string fontJson = DEXConfig.ReadString(DEXConfig.TOOLTIP_FONT);
Font f = new Font("微软雅黑",10); Font f = new Font("微软雅黑", 10);
JavaScriptSerializer jss = new JavaScriptSerializer(); JavaScriptSerializer jss = new JavaScriptSerializer();
try try
{ {
...@@ -694,7 +682,7 @@ private void menuitem_tooltipFont_Click(object sender, EventArgs e) ...@@ -694,7 +682,7 @@ private void menuitem_tooltipFont_Click(object sender, EventArgs e)
fd.Font = f; fd.Font = f;
if (fd.ShowDialog() == DialogResult.OK) if (fd.ShowDialog() == DialogResult.OK)
{ {
Common.XMLReader.Save(MyConfig.TOOLTIP_FONT, jss.Serialize(fd.Font)); Common.XMLReader.Save(DEXConfig.TOOLTIP_FONT, jss.Serialize(fd.Font));
this.fctb.lbTooltip.Font = fd.Font; this.fctb.lbTooltip.Font = fd.Font;
} }
} }
......
...@@ -71,6 +71,7 @@ private void InitializeComponent() ...@@ -71,6 +71,7 @@ private void InitializeComponent()
this.host = new System.Windows.Forms.Integration.ElementHost(); this.host = new System.Windows.Forms.Integration.ElementHost();
this.editor = new ICSharpCode.AvalonEdit.TextEditor(); this.editor = new ICSharpCode.AvalonEdit.TextEditor();
this.lbTooltip = new System.Windows.Forms.Label(); this.lbTooltip = new System.Windows.Forms.Label();
this.setCodeEditorFontToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mainMenu.SuspendLayout(); this.mainMenu.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
...@@ -140,7 +141,8 @@ private void InitializeComponent() ...@@ -140,7 +141,8 @@ private void InitializeComponent()
this.menuitem_showinput, this.menuitem_showinput,
this.menuitem_find, this.menuitem_find,
this.menuitem_replace, this.menuitem_replace,
this.menuitem_tooltipFont}); this.menuitem_tooltipFont,
this.setCodeEditorFontToolStripMenuItem});
this.menuitem_setting.Name = "menuitem_setting"; this.menuitem_setting.Name = "menuitem_setting";
this.menuitem_setting.Size = new System.Drawing.Size(75, 20); this.menuitem_setting.Size = new System.Drawing.Size(75, 20);
this.menuitem_setting.Text = "Settings(&S)"; this.menuitem_setting.Text = "Settings(&S)";
...@@ -190,7 +192,7 @@ private void InitializeComponent() ...@@ -190,7 +192,7 @@ private void InitializeComponent()
// //
this.menuitem_testlua.Name = "menuitem_testlua"; this.menuitem_testlua.Name = "menuitem_testlua";
this.menuitem_testlua.ShortcutKeys = System.Windows.Forms.Keys.F5; 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.Text = "Syntax Check";
this.menuitem_testlua.Click += new System.EventHandler(this.menuitem_testlua_Click); this.menuitem_testlua.Click += new System.EventHandler(this.menuitem_testlua_Click);
// //
...@@ -198,7 +200,7 @@ private void InitializeComponent() ...@@ -198,7 +200,7 @@ private void InitializeComponent()
// //
this.menuitem_effectcreator.Name = "menuitem_effectcreator"; this.menuitem_effectcreator.Name = "menuitem_effectcreator";
this.menuitem_effectcreator.ShortcutKeys = System.Windows.Forms.Keys.F3; 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.Text = "Effect Creator";
this.menuitem_effectcreator.Visible = false; this.menuitem_effectcreator.Visible = false;
this.menuitem_effectcreator.Click += new System.EventHandler(this.effectCreatorToolStripMenuItem_Click); this.menuitem_effectcreator.Click += new System.EventHandler(this.effectCreatorToolStripMenuItem_Click);
...@@ -231,6 +233,7 @@ private void InitializeComponent() ...@@ -231,6 +233,7 @@ private void InitializeComponent()
// //
// documentMap1 // documentMap1
// //
this.documentMap1.AllowDrop = true;
this.documentMap1.BackColor = System.Drawing.Color.DimGray; this.documentMap1.BackColor = System.Drawing.Color.DimGray;
this.documentMap1.Dock = System.Windows.Forms.DockStyle.Right; this.documentMap1.Dock = System.Windows.Forms.DockStyle.Right;
this.documentMap1.ForeColor = System.Drawing.Color.Maroon; this.documentMap1.ForeColor = System.Drawing.Color.Maroon;
...@@ -244,6 +247,7 @@ private void InitializeComponent() ...@@ -244,6 +247,7 @@ private void InitializeComponent()
// //
// host // host
// //
this.host.AllowDrop = true;
this.host.Dock = System.Windows.Forms.DockStyle.Fill; this.host.Dock = System.Windows.Forms.DockStyle.Fill;
this.host.Location = new System.Drawing.Point(0, 24); this.host.Location = new System.Drawing.Point(0, 24);
this.host.Name = "host"; this.host.Name = "host";
...@@ -264,6 +268,13 @@ private void InitializeComponent() ...@@ -264,6 +268,13 @@ private void InitializeComponent()
this.lbTooltip.TabIndex = 6; this.lbTooltip.TabIndex = 6;
this.lbTooltip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lbTooltip_MouseMove); 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 // CodeEditForm_Avalon
// //
this.AllowDrop = true; this.AllowDrop = true;
...@@ -297,10 +308,67 @@ private void InitializeComponent() ...@@ -297,10 +308,67 @@ private void InitializeComponent()
CompletionWindow completionWindowUse = null; CompletionWindow completionWindowUse = null;
int lastOffset = 0; 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) 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); completionWindowUse = new CompletionWindow(editor.TextArea);
data = completionWindowUse.CompletionList.CompletionData;
completionWindowUse.Closed += delegate completionWindowUse.Closed += delegate
{ {
completionWindowUse = null; completionWindowUse = null;
...@@ -311,15 +379,16 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs ...@@ -311,15 +379,16 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs
{ {
completionWindowUse.EndOffset = completionWindowUse.StartOffset; completionWindowUse.EndOffset = completionWindowUse.StartOffset;
} }
IList<ICompletionData> data = completionWindowUse.CompletionList.CompletionData; foreach (var cp in functionCompletions)
string find = editor.Document.GetText(lastOffset, completionWindowUse.EndOffset - completionWindowUse.StartOffset);
if (string.IsNullOrEmpty(find))
{ {
return; if (find.EndsWith(cp.Text.Substring(0, cp.SuffixLength)))
{
data.Add(cp);
}
} }
foreach (var d in tooltipDic) 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)); data.Add(new YGOProAutoCompletion(d.Key, d.Value));
} }
...@@ -334,16 +403,52 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs ...@@ -334,16 +403,52 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs
lbTooltip.Text = find2 + "\n" + tooltipDic[find2]; 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)); 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) private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{ {
CompletionListBox lb = (CompletionListBox)sender; CompletionListBox lb = (CompletionListBox)sender;
if (lb.SelectedItem == null) if (lb.SelectedItem == null || !(lb.SelectedItem is YGOProAutoCompletion))
{ {
return; return;
} }
...@@ -443,5 +548,6 @@ public double Priority ...@@ -443,5 +548,6 @@ public double Priority
ICSharpCode.AvalonEdit.TextEditor editor; ICSharpCode.AvalonEdit.TextEditor editor;
private Label lbTooltip; private Label lbTooltip;
private ToolStripMenuItem menuitem_tooltipFont; private ToolStripMenuItem menuitem_tooltipFont;
private ToolStripMenuItem setCodeEditorFontToolStripMenuItem;
} }
} }
...@@ -10,22 +10,21 @@ ...@@ -10,22 +10,21 @@
using DataEditorX.Core; using DataEditorX.Core;
using DataEditorX.Language; using DataEditorX.Language;
using FastColoredTextBoxNS; using FastColoredTextBoxNS;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using ICSharpCode.AvalonEdit.Search;
using Neo.IronLua; using Neo.IronLua;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization; using System.Web.Script.Serialization;
using System.Windows.Forms; using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using System.Xml; using System.Xml;
using ICSharpCode.AvalonEdit.Highlighting; using WeifenLuo.WinFormsUI.Docking;
using ICSharpCode.AvalonEdit.Search;
using System.Windows.Threading;
using System.Text.RegularExpressions;
using ICSharpCode.AvalonEdit.CodeCompletion;
namespace DataEditorX namespace DataEditorX
{ {
...@@ -60,19 +59,38 @@ void InitForm() ...@@ -60,19 +59,38 @@ void InitForm()
editor.TextArea.TextEntered += editor_TextArea_TextEntered; editor.TextArea.TextEntered += editor_TextArea_TextEntered;
editor.TextArea.TextEntering += editor_TextArea_TextEntering; editor.TextArea.TextEntering += editor_TextArea_TextEntering;
editor.PreviewKeyDown += TextArea_KeyDown; editor.PreviewKeyDown += TextArea_KeyDown;
//editor.TextArea.KeyDown += TextArea_KeyDown;
//editor.KeyDown += TextArea_KeyDown;
editor.TextChanged += Editor_TextChanged; editor.TextChanged += Editor_TextChanged;
editor.MouseMove += Editor_MouseMove; editor.MouseMove += Editor_MouseMove;
editor.PreviewMouseWheel += Editor_MouseWheel;
editor.FontFamily = new System.Windows.Media.FontFamily(MyConfig.TAG_FONT_NAME); editor.FontFamily = new System.Windows.Media.FontFamily(DEXConfig.ReadString(DEXConfig.TAG_FONT_NAME));
editor.FontSize = MyConfig.ReadFloat(MyConfig.TAG_FONT_SIZE, (float)editor.FontSize); editor.FontSize = DEXConfig.ReadFloat(DEXConfig.TAG_FONT_SIZE, (float)editor.FontSize);
editor.WordWrap = MyConfig.ReadBoolean(MyConfig.TAG_WORDWRAP); 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.Background = System.Windows.Media.Brushes.Black;
editor.Foreground = System.Windows.Media.Brushes.GhostWhite; editor.Foreground = System.Windows.Media.Brushes.GhostWhite;
this.RefreshHighlighting(); 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) private void Editor_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{ {
var ePos = e.GetPosition(editor); var ePos = e.GetPosition(editor);
...@@ -175,21 +193,6 @@ private int FindMainRuleSetIndex(XshdSyntaxDefinition definition) ...@@ -175,21 +193,6 @@ private int FindMainRuleSetIndex(XshdSyntaxDefinition definition)
} }
return -1; 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() private void RefreshHighlighting()
{ {
using (XmlReader reader = new XmlTextReader("data\\avalon.xshd")) using (XmlReader reader = new XmlTextReader("data\\avalon.xshd"))
...@@ -200,19 +203,25 @@ private void RefreshHighlighting() ...@@ -200,19 +203,25 @@ private void RefreshHighlighting()
string cName = this.Text.Substring(0, this.Text.Length - 4); string cName = this.Text.Substring(0, this.Text.Length - 4);
var cRule = new XshdKeywords(); var cRule = new XshdKeywords();
cRule.Words.Add(cName); cRule.Words.Add(cName);
XshdColor color = new XshdColor(); XshdColor color = new XshdColor
color.Name = "cFunction"; {
color.Foreground = new SimpleHighlightingBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x92, 0x1A, 0xFF)); Name = "cFunction",
color.FontWeight = System.Windows.FontWeights.Bold; Foreground = new SimpleHighlightingBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x92, 0x1A, 0xFF)),
FontWeight = System.Windows.FontWeights.Bold
};
cRule.ColorReference = new XshdReference<XshdColor>(color); cRule.ColorReference = new XshdReference<XshdColor>(color);
(gLua.Elements[this.FindMainRuleSetIndex(gLua)] as XshdRuleSet).Elements.Insert(0, cRule); (gLua.Elements[this.FindMainRuleSetIndex(gLua)] as XshdRuleSet).Elements.Insert(0, cRule);
var cRule2 = new XshdRule(); var cRule2 = new XshdRule
cRule2.Regex = @"\b(" + cName + @"\.[A-Za-z0-9_]+)"; {
XshdColor color2 = new XshdColor(); Regex = @"\b(" + cName + @"\.[A-Za-z0-9_]+)"
color2.Name = "cFunction2"; };
color2.Foreground = new SimpleHighlightingBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x92, 0x1A, 0xFF)); XshdColor color2 = new XshdColor
color2.FontWeight = System.Windows.FontWeights.Bold; {
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); cRule2.ColorReference = new XshdReference<XshdColor>(color2);
(gLua.Elements[this.FindMainRuleSetIndex(gLua)] as XshdRuleSet).Elements.Insert(0, cRule2); (gLua.Elements[this.FindMainRuleSetIndex(gLua)] as XshdRuleSet).Elements.Insert(0, cRule2);
} }
...@@ -223,11 +232,7 @@ private void RefreshHighlighting() ...@@ -223,11 +232,7 @@ private void RefreshHighlighting()
internal void InitTooltip(CodeConfig codecfg) internal void InitTooltip(CodeConfig codecfg)
{ {
this.tooltipDic = codecfg.TooltipDic; this.tooltipDic = codecfg.TooltipDic;
foreach(var item in this.tooltipDic) this.items = codecfg.Items;
{
AutocompleteItem it = new AutocompleteItem();
this.items = codecfg.Items;
}
} }
#endregion #endregion
...@@ -250,7 +255,7 @@ public bool Create(string file) ...@@ -250,7 +255,7 @@ public bool Create(string file)
} }
public bool Save() public bool Save()
{ {
return savefile(string.IsNullOrEmpty(nowFile)); return SaveFile(string.IsNullOrEmpty(nowFile));
} }
public bool Open(string file) public bool Open(string file)
{ {
...@@ -268,10 +273,14 @@ public bool Open(string file) ...@@ -268,10 +273,14 @@ public bool Open(string file)
//(this.fctb.SyntaxHighlighter as MySyntaxHighlighter).cCode //(this.fctb.SyntaxHighlighter as MySyntaxHighlighter).cCode
// = fi.Name.Substring(0, fi.Name.Length - 4); // = 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)); 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; oldtext = editor.Text;
this.SetTitle(); this.SetTitle();
this.RefreshHighlighting(); this.RefreshHighlighting();
...@@ -380,7 +389,7 @@ void FctbToolTipNeeded(object sender, ToolTipNeededEventArgs e) ...@@ -380,7 +389,7 @@ void FctbToolTipNeeded(object sender, ToolTipNeededEventArgs e)
#endregion #endregion
#region 保存文件 #region 保存文件
bool savefile(bool saveas) bool SaveFile(bool saveas)
{ {
string alltext = this.editor.Text; string alltext = this.editor.Text;
if (!tabisspaces) if (!tabisspaces)
...@@ -415,7 +424,7 @@ bool savefile(bool saveas) ...@@ -415,7 +424,7 @@ bool savefile(bool saveas)
public bool SaveAs() public bool SaveAs()
{ {
return savefile(true); return SaveFile(true);
} }
void SaveToolStripMenuItemClick(object sender, EventArgs e) void SaveToolStripMenuItemClick(object sender, EventArgs e)
...@@ -443,33 +452,23 @@ void Menuitem_showinputClick(object sender, EventArgs e) ...@@ -443,33 +452,23 @@ void Menuitem_showinputClick(object sender, EventArgs e)
tb_input.Visible = true; 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) 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); 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(); JavaScriptSerializer jss = new JavaScriptSerializer();
try try
{ {
f = jss.Deserialize<FontHelper>(fontJson).ToFont(); f = jss.Deserialize<FontHelper>(fontJson).ToFont();
} }
catch { } catch
{
DEXConfig.Save(DEXConfig.TOOLTIP_FONT, jss.Serialize(f));
}
lbTooltip.Font = f; lbTooltip.Font = f;
} }
SearchPanel sp = null; SearchPanel sp = null;
void Menuitem_findClick(object sender, EventArgs e) void Menuitem_findClick(object sender, EventArgs e)
{ {
...@@ -531,8 +530,10 @@ private void BtnFind_Click(object sender, EventArgs e) ...@@ -531,8 +530,10 @@ private void BtnFind_Click(object sender, EventArgs e)
{ {
string text = editor.Text; string text = editor.Text;
string findStr = frForm.txtFind.Text; string findStr = frForm.txtFind.Text;
var rtxt = new RichTextBox(); var rtxt = new RichTextBox
rtxt.Text = text; {
Text = text
};
if (findStart < 0) if (findStart < 0)
{ {
...@@ -544,7 +545,7 @@ private void BtnFind_Click(object sender, EventArgs e) ...@@ -544,7 +545,7 @@ private void BtnFind_Click(object sender, EventArgs e)
var line = editor.Document.GetLineByOffset(findStart).LineNumber; var line = editor.Document.GetLineByOffset(findStart).LineNumber;
editor.ScrollTo(line, 0); editor.ScrollTo(line, 0);
editor.Select(findStart, findStr.Length); editor.Select(findStart, findStr.Length);
findStart = findStart + findStr.Length; findStart += findStr.Length;
} }
} }
void QuitToolStripMenuItemClick(object sender, EventArgs e) void QuitToolStripMenuItemClick(object sender, EventArgs e)
...@@ -594,9 +595,11 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e) ...@@ -594,9 +595,11 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
list.Add(item); list.Add(item);
} }
} }
completionWindowUse = new CompletionWindow(editor.TextArea); completionWindowUse = new CompletionWindow(editor.TextArea)
completionWindowUse.StartOffset = editor.CaretOffset; {
completionWindowUse.EndOffset = editor.CaretOffset; StartOffset = editor.CaretOffset,
EndOffset = editor.CaretOffset
};
IList<ICompletionData> data = completionWindowUse.CompletionList.CompletionData; IList<ICompletionData> data = completionWindowUse.CompletionList.CompletionData;
if (string.IsNullOrEmpty(key)) if (string.IsNullOrEmpty(key))
{ {
...@@ -619,7 +622,8 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e) ...@@ -619,7 +622,8 @@ void Tb_inputKeyDown(object sender, KeyEventArgs e)
lbTooltip.Text = find2 + "\n" + tooltipDic[find2]; 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)); 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; completionWindowUse = null;
}; };
} }
...@@ -722,12 +726,11 @@ private void OnDragDtop(object sender, DragEventArgs e) ...@@ -722,12 +726,11 @@ private void OnDragDtop(object sender, DragEventArgs e)
private void menuitem_tooltipFont_Click(object sender, EventArgs e) private void menuitem_tooltipFont_Click(object sender, EventArgs e)
{ {
FontDialog fd = new FontDialog(); FontDialog fd = new FontDialog();
string fontJson = MyConfig.ReadString(MyConfig.TOOLTIP_FONT);
JavaScriptSerializer jss = new JavaScriptSerializer(); JavaScriptSerializer jss = new JavaScriptSerializer();
fd.Font = lbTooltip.Font; fd.Font = lbTooltip.Font;
if (fd.ShowDialog() == DialogResult.OK) 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; lbTooltip.Font = fd.Font;
} }
} }
...@@ -763,5 +766,24 @@ private void CodeEditForm_Avalon_KeyDown(object sender, KeyEventArgs e) ...@@ -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) ...@@ -125,7 +125,7 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality = 90)
{ {
if (bitmap != null) if (bitmap != null)
{ {
string path=Path.GetDirectoryName(filename); string path = Path.GetDirectoryName(filename);
if (!Directory.Exists(path))//创建文件夹 if (!Directory.Exists(path))//创建文件夹
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
......
...@@ -196,7 +196,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access) ...@@ -196,7 +196,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
/// <param name="_comment">Comment for stored file</param> /// <param name="_comment">Comment for stored file</param>
public void AddFile(string _pathname, string _filenameInZip, string _comment) public void AddFile(string _pathname, string _filenameInZip, string _comment)
{ {
Compression _method=Compression.Deflate; Compression _method = Compression.Deflate;
if (this.access == FileAccess.Read) if (this.access == FileAccess.Read)
{ {
throw new InvalidOperationException("Writing is not alowed"); throw new InvalidOperationException("Writing is not alowed");
...@@ -244,7 +244,7 @@ public void AddStream(Compression _method, string _filenameInZip, Stream _source ...@@ -244,7 +244,7 @@ public void AddStream(Compression _method, string _filenameInZip, Stream _source
} }
else else
{ {
ZipFileEntry last = this.files[this.files.Count-1]; ZipFileEntry last = this.files[this.files.Count - 1];
_ = last.HeaderOffset + last.HeaderSize; _ = last.HeaderOffset + last.HeaderSize;
} }
...@@ -345,7 +345,7 @@ public List<ZipFileEntry> ReadCentralDir() ...@@ -345,7 +345,7 @@ public List<ZipFileEntry> ReadCentralDir()
ushort extraSize = BitConverter.ToUInt16(this.centralDirImage, pointer + 30); ushort extraSize = BitConverter.ToUInt16(this.centralDirImage, pointer + 30);
ushort commentSize = BitConverter.ToUInt16(this.centralDirImage, pointer + 32); ushort commentSize = BitConverter.ToUInt16(this.centralDirImage, pointer + 32);
uint headerOffset = BitConverter.ToUInt32(this.centralDirImage, pointer + 42); 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; Encoding encoder = encodeUTF8 ? Encoding.UTF8 : _defaultEncoding;
......
...@@ -11,14 +11,14 @@ namespace DataEditorX.Config ...@@ -11,14 +11,14 @@ namespace DataEditorX.Config
/// <summary> /// <summary>
/// 配置 /// 配置
/// </summary> /// </summary>
public class MyConfig : XMLReader public class DEXConfig : XMLReader
{ {
#region 常量 #region 常量
public const string TAG_SAVE_LAGN = "-savelanguage"; public const string TAG_SAVE_LAGN = "-savelanguage";
public const string TAG_SAVE_LAGN2 = "-sl"; public const string TAG_SAVE_LAGN2 = "-sl";
public const string TAG_MSE_PATH="mse_path"; public const string TAG_MSE_PATH = "mse_path";
public const string TAG_MSE_EXPORT="mse_exprotpath"; public const string TAG_MSE_EXPORT = "mse_exprotpath";
public const string TAG_AUTO_LEN ="autolength"; public const string TAG_AUTO_LEN = "autolength";
/// <summary> /// <summary>
/// 窗口消息 打开文件 /// 窗口消息 打开文件
/// </summary> /// </summary>
...@@ -268,7 +268,7 @@ public static Area ReadArea(string key) ...@@ -268,7 +268,7 @@ public static Area ReadArea(string key)
/// <returns></returns> /// <returns></returns>
public static bool ReadBoolean(string key, bool def = false) public static bool ReadBoolean(string key, bool def = false)
{ {
string val= ReadString(key); string val = ReadString(key);
if ("true".Equals(val, StringComparison.OrdinalIgnoreCase)) if ("true".Equals(val, StringComparison.OrdinalIgnoreCase))
{ {
return true; return true;
......
...@@ -18,7 +18,7 @@ public class DataConfig ...@@ -18,7 +18,7 @@ public class DataConfig
{ {
public 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) public DataConfig(string conf)
{ {
...@@ -45,14 +45,14 @@ public void InitMember(string conf) ...@@ -45,14 +45,14 @@ public void InitMember(string conf)
} }
//提取内容 //提取内容
string text = File.ReadAllText(conf); string text = File.ReadAllText(conf);
this.dicCardRules = DataManager.Read(text, MyConfig.TAG_RULE); this.dicCardRules = DataManager.Read(text, DEXConfig.TAG_RULE);
this.dicSetnames = DataManager.Read(text, MyConfig.TAG_SETNAME); this.dicSetnames = DataManager.Read(text, DEXConfig.TAG_SETNAME);
this.dicCardTypes = DataManager.Read(text, MyConfig.TAG_TYPE); this.dicCardTypes = DataManager.Read(text, DEXConfig.TAG_TYPE);
this.dicLinkMarkers = DataManager.Read(text, MyConfig.TAG_MARKER); this.dicLinkMarkers = DataManager.Read(text, DEXConfig.TAG_MARKER);
this.dicCardcategorys = DataManager.Read(text, MyConfig.TAG_CATEGORY); this.dicCardcategorys = DataManager.Read(text, DEXConfig.TAG_CATEGORY);
this.dicCardAttributes = DataManager.Read(text, MyConfig.TAG_ATTRIBUTE); this.dicCardAttributes = DataManager.Read(text, DEXConfig.TAG_ATTRIBUTE);
this.dicCardRaces = DataManager.Read(text, MyConfig.TAG_RACE); this.dicCardRaces = DataManager.Read(text, DEXConfig.TAG_RACE);
this.dicCardLevels = DataManager.Read(text, MyConfig.TAG_LEVEL); this.dicCardLevels = DataManager.Read(text, DEXConfig.TAG_LEVEL);
} }
/// <summary> /// <summary>
......
...@@ -21,20 +21,20 @@ public ImageSet() ...@@ -21,20 +21,20 @@ public ImageSet()
//初始化 //初始化
void Init() 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.w = ints[0];
this.h = ints[1]; this.h = ints[1];
this.W = ints[2]; this.W = ints[2];
this.H = ints[3]; this.H = ints[3];
this.quilty = MyConfig.ReadInteger(MyConfig.TAG_IMAGE_QUILTY, 95); this.quilty = DEXConfig.ReadInteger(DEXConfig.TAG_IMAGE_QUILTY, 95);
} }
/// <summary> /// <summary>
/// jpeg质量 /// jpeg质量
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
*/ */
using System; using System;
using System.Drawing; using System.Drawing;
using System.Web.Script.Serialization;
using System.Windows.Forms; using System.Windows.Forms;
namespace FastColoredTextBoxNS namespace FastColoredTextBoxNS
......
...@@ -57,7 +57,7 @@ void AddHistorys(string[] lines) ...@@ -57,7 +57,7 @@ void AddHistorys(string[] lines)
{ {
if (YGOUtil.IsScript(line)) 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.IndexOf(line) < 0)
{ {
this.luahistory.Add(line); this.luahistory.Add(line);
...@@ -65,7 +65,7 @@ void AddHistorys(string[] lines) ...@@ -65,7 +65,7 @@ void AddHistorys(string[] lines)
} }
else else
{ {
if (this.cdbhistory.Count < MyConfig.MAX_HISTORY if (this.cdbhistory.Count < DEXConfig.MAX_HISTORY
&& this.cdbhistory.IndexOf(line) < 0) && this.cdbhistory.IndexOf(line) < 0)
{ {
this.cdbhistory.Add(line); this.cdbhistory.Add(line);
......
...@@ -222,7 +222,7 @@ public bool EqualsData(Card other) ...@@ -222,7 +222,7 @@ public bool EqualsData(Card other)
/// <returns>结果</returns> /// <returns>结果</returns>
public bool Equals(Card other) public bool Equals(Card other)
{ {
bool equalBool=this.EqualsData(other); bool equalBool = this.EqualsData(other);
if (!equalBool) if (!equalBool)
{ {
return false; return false;
......
...@@ -334,7 +334,7 @@ public bool OpenScript(bool openinthis, string addrequire) ...@@ -334,7 +334,7 @@ public bool OpenScript(bool openinthis, string addrequire)
{ {
if (openinthis)//是否用本程序打开 if (openinthis)//是否用本程序打开
{ {
MyConfig.OpenFileInThis(lua); DEXConfig.OpenFileInThis(lua);
} }
else else
{ {
......
...@@ -185,8 +185,8 @@ public static Card[] Read(string DB, bool reNewLine, params long[] ids) ...@@ -185,8 +185,8 @@ public static Card[] Read(string DB, bool reNewLine, params long[] ids)
/// <param name="SQLs">SQL/密码语句集合集合</param> /// <param name="SQLs">SQL/密码语句集合集合</param>
public static Card[] Read(string DB, bool reNewLine, params string[] SQLs) public static Card[] Read(string DB, bool reNewLine, params string[] SQLs)
{ {
List<Card> list=new List<Card>(); List<Card> list = new List<Card>();
List<long> idlist=new List<long>(); List<long> idlist = new List<long>();
if (File.Exists(DB) && SQLs != null) if (File.Exists(DB) && SQLs != null)
{ {
using (SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + DB)) using (SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + DB))
...@@ -227,7 +227,7 @@ public static Card[] Read(string DB, bool reNewLine, params string[] SQLs) ...@@ -227,7 +227,7 @@ public static Card[] Read(string DB, bool reNewLine, params string[] SQLs)
{ {
while (reader.Read()) while (reader.Read())
{ {
Card c=ReadCard(reader,reNewLine); Card c = ReadCard(reader, reNewLine);
if (idlist.IndexOf(c.id) < 0) if (idlist.IndexOf(c.id) < 0)
{//不存在,则添加 {//不存在,则添加
idlist.Add(c.id); idlist.Add(c.id);
...@@ -346,7 +346,7 @@ static string toInt(long l) ...@@ -346,7 +346,7 @@ static string toInt(long l)
} }
public static string GetSelectSQL(Card c) 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 "); sb.Append("SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ");
if (c == null) if (c == null)
{ {
...@@ -592,7 +592,7 @@ public static void ExportSql(string file, params Card[] cards) ...@@ -592,7 +592,7 @@ public static void ExportSql(string file, params Card[] cards)
public static CardPack FindPack(string db, long id) public static CardPack FindPack(string db, long id)
{ {
CardPack cardpack=null; CardPack cardpack = null;
if (File.Exists(db) && id >= 0) if (File.Exists(db) && id >= 0)
{ {
using (SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + db)) using (SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + db))
......
...@@ -20,7 +20,7 @@ public static class CardLink ...@@ -20,7 +20,7 @@ public static class CardLink
0x40 ↖ 0x40 ↖
0x80 ↑ 0x80 ↑
0x100 ↗*/ 0x100 ↗*/
public const int DownLeft=0x1; public const int DownLeft = 0x1;
public const int Down = 0x2; public const int Down = 0x2;
public const int DownRight = 0x4; public const int DownRight = 0x4;
public const int Left = 0x8; public const int Left = 0x8;
......
...@@ -6,7 +6,7 @@ public enum CardRule : int ...@@ -6,7 +6,7 @@ public enum CardRule : int
/// <summary>无</summary> /// <summary>无</summary>
NONE = 0, NONE = 0,
/// <summary>OCG</summary> /// <summary>OCG</summary>
OCG =1, OCG = 1,
/// <summary>TCG</summary> /// <summary>TCG</summary>
TCG = 2, TCG = 2,
/// <summary>OT</summary> /// <summary>OT</summary>
......
...@@ -15,58 +15,58 @@ namespace DataEditorX.Core.Info ...@@ -15,58 +15,58 @@ namespace DataEditorX.Core.Info
public enum CardType : long public enum CardType : long
{ {
///<summary>怪兽卡</summary> ///<summary>怪兽卡</summary>
TYPE_MONSTER =0x1, TYPE_MONSTER = 0x1,
///<summary>魔法卡</summary> ///<summary>魔法卡</summary>
TYPE_SPELL =0x2, TYPE_SPELL = 0x2,
///<summary>陷阱卡</summary> ///<summary>陷阱卡</summary>
TYPE_TRAP =0x4, TYPE_TRAP = 0x4,
///<summary>通常</summary> ///<summary>通常</summary>
TYPE_NORMAL =0x10, TYPE_NORMAL = 0x10,
///<summary>效果</summary> ///<summary>效果</summary>
TYPE_EFFECT =0x20, TYPE_EFFECT = 0x20,
///<summary>融合</summary> ///<summary>融合</summary>
TYPE_FUSION =0x40, TYPE_FUSION = 0x40,
///<summary>仪式</summary> ///<summary>仪式</summary>
TYPE_RITUAL =0x80, TYPE_RITUAL = 0x80,
///<summary>陷阱怪兽</summary> ///<summary>陷阱怪兽</summary>
TYPE_TRAPMONSTER =0x100, TYPE_TRAPMONSTER = 0x100,
///<summary>灵魂</summary> ///<summary>灵魂</summary>
TYPE_SPIRIT =0x200, TYPE_SPIRIT = 0x200,
///<summary>同盟</summary> ///<summary>同盟</summary>
TYPE_UNION =0x400, TYPE_UNION = 0x400,
///<summary>二重</summary> ///<summary>二重</summary>
TYPE_DUAL =0x800, TYPE_DUAL = 0x800,
///<summary>调整</summary> ///<summary>调整</summary>
TYPE_TUNER =0x1000, TYPE_TUNER = 0x1000,
///<summary>同调</summary> ///<summary>同调</summary>
TYPE_SYNCHRO =0x2000, TYPE_SYNCHRO = 0x2000,
///<summary>衍生物</summary> ///<summary>衍生物</summary>
TYPE_TOKEN =0x4000, TYPE_TOKEN = 0x4000,
///<summary>速攻</summary> ///<summary>速攻</summary>
TYPE_QUICKPLAY =0x10000, TYPE_QUICKPLAY = 0x10000,
///<summary>永续</summary> ///<summary>永续</summary>
TYPE_CONTINUOUS =0x20000, TYPE_CONTINUOUS = 0x20000,
///<summary>装备</summary> ///<summary>装备</summary>
TYPE_EQUIP =0x40000, TYPE_EQUIP = 0x40000,
///<summary>场地</summary> ///<summary>场地</summary>
TYPE_FIELD =0x80000, TYPE_FIELD = 0x80000,
///<summary>反击</summary> ///<summary>反击</summary>
TYPE_COUNTER =0x100000, TYPE_COUNTER = 0x100000,
///<summary>反转</summary> ///<summary>反转</summary>
TYPE_FLIP =0x200000, TYPE_FLIP = 0x200000,
///<summary>卡通</summary> ///<summary>卡通</summary>
TYPE_TOON =0x400000, TYPE_TOON = 0x400000,
///<summary>超量</summary> ///<summary>超量</summary>
TYPE_XYZ =0x800000, TYPE_XYZ = 0x800000,
///<summary>灵摆</summary> ///<summary>灵摆</summary>
TYPE_PENDULUM =0x1000000, TYPE_PENDULUM = 0x1000000,
///<summary>特殊召唤</summary> ///<summary>特殊召唤</summary>
TYPE_SPSUMMON =0x2000000, TYPE_SPSUMMON = 0x2000000,
///<summary>连接</summary> ///<summary>连接</summary>
TYPE_LINK =0x4000000, TYPE_LINK = 0x4000000,
} }
public static class CardTypes public static class CardTypes
...@@ -160,7 +160,7 @@ public static class CardTypes ...@@ -160,7 +160,7 @@ public static class CardTypes
public static CardType[] GetMonsterTypes(long type, bool no10 = false) public static CardType[] GetMonsterTypes(long type, bool no10 = false)
{ {
var list = new List<CardType>(5); var list = new List<CardType>(5);
var typeList=new List<CardType[]>(5); var typeList = new List<CardType[]>(5);
if (no10) if (no10)
{ {
typeList.Add(TYPE1_10); typeList.Add(TYPE1_10);
......
...@@ -33,7 +33,7 @@ static void Log(string str) ...@@ -33,7 +33,7 @@ static void Log(string str)
static string _oldfun; static string _oldfun;
static string _logtxt; static string _logtxt;
static string _funclisttxt; 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) public static void Read(string funtxt)
{ {
...@@ -41,10 +41,10 @@ public static void Read(string funtxt) ...@@ -41,10 +41,10 @@ public static void Read(string funtxt)
_oldfun = funtxt; _oldfun = funtxt;
if (File.Exists(funtxt)) if (File.Exists(funtxt))
{ {
string[] lines=File.ReadAllLines(funtxt); string[] lines = File.ReadAllLines(funtxt);
bool isFind=false; bool isFind = false;
string name=""; string name = "";
string desc=""; string desc = "";
foreach (string line in lines) foreach (string line in lines)
{ {
if (string.IsNullOrEmpty(line) if (string.IsNullOrEmpty(line)
...@@ -58,8 +58,8 @@ public static void Read(string funtxt) ...@@ -58,8 +58,8 @@ public static void Read(string funtxt)
{ {
//添加之前的函数 //添加之前的函数
AddOldFun(name, desc); AddOldFun(name, desc);
int w=line.IndexOf("("); int w = line.IndexOf("(");
int t=line.IndexOf(" "); int t = line.IndexOf(" ");
//获取当前名字 //获取当前名字
if (t < w && t > 0) if (t < w && t > 0)
{ {
...@@ -101,9 +101,9 @@ static void AddOldFun(string name, string desc) ...@@ -101,9 +101,9 @@ static void AddOldFun(string name, string desc)
/// <returns></returns> /// <returns></returns>
public static bool Find(string path) public static bool Find(string path)
{ {
string name="interpreter.cpp"; string name = "interpreter.cpp";
string file=Path.Combine(path,name); string file = Path.Combine(path, name);
string file2=Path.Combine(Path.Combine(path, "ocgcore"), name); string file2 = Path.Combine(Path.Combine(path, "ocgcore"), name);
_logtxt = Path.Combine(path, "find_functions.log"); _logtxt = Path.Combine(path, "find_functions.log");
ResetLog(); ResetLog();
_funclisttxt = Path.Combine(path, "_functions.txt"); _funclisttxt = Path.Combine(path, "_functions.txt");
...@@ -122,16 +122,16 @@ public static bool Find(string path) ...@@ -122,16 +122,16 @@ public static bool Find(string path)
return false; return false;
} }
} }
string texts=File.ReadAllText(file); string texts = File.ReadAllText(file);
Regex libRex=new Regex(@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}" Regex libRex = new Regex(@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
,RegexOptions.Multiline); , RegexOptions.Multiline);
MatchCollection libsMatch=libRex.Matches(texts); MatchCollection libsMatch = libRex.Matches(texts);
Log("log:count " + libsMatch.Count.ToString()); Log("log:count " + libsMatch.Count.ToString());
foreach (Match m in libsMatch)//获取lib函数库 foreach (Match m in libsMatch)//获取lib函数库
{ {
if (m.Groups.Count > 2) if (m.Groups.Count > 2)
{ {
string word=m.Groups[1].Value; string word = m.Groups[1].Value;
Log("log:find " + word); Log("log:find " + word);
//分别去获取函数库的函数 //分别去获取函数库的函数
GetFunctions(word, m.Groups[2].Value, GetFunctions(word, m.Groups[2].Value,
...@@ -172,16 +172,16 @@ static string ToTitle(string str) ...@@ -172,16 +172,16 @@ static string ToTitle(string str)
//获取函数库的lua函数名,和对应的c++函数 //获取函数库的lua函数名,和对应的c++函数
static Dictionary<string, string> GetFunctionNames(string texts, string name) static Dictionary<string, string> GetFunctionNames(string texts, string name)
{ {
Dictionary<string,string> dic=new Dictionary<string, string>(); Dictionary<string, string> dic = new Dictionary<string, string>();
Regex funcRex=new Regex("\"(\\S*?)\",\\s*?(\\S*?::\\S*?)\\s"); Regex funcRex = new Regex("\"(\\S*?)\",\\s*?(\\S*?::\\S*?)\\s");
MatchCollection funcsMatch=funcRex.Matches(texts); MatchCollection funcsMatch = funcRex.Matches(texts);
Log("log: functions count " + name + ":" + funcsMatch.Count.ToString()); Log("log: functions count " + name + ":" + funcsMatch.Count.ToString());
foreach (Match m in funcsMatch) foreach (Match m in funcsMatch)
{ {
if (m.Groups.Count > 2) if (m.Groups.Count > 2)
{ {
string k=ToTitle(name)+"."+m.Groups[1].Value; string k = ToTitle(name) + "." + m.Groups[1].Value;
string v=m.Groups[2].Value; string v = m.Groups[2].Value;
if (!dic.ContainsKey(k)) if (!dic.ContainsKey(k))
{ {
dic.Add(k, v); dic.Add(k, v);
...@@ -196,10 +196,10 @@ static string ToTitle(string str) ...@@ -196,10 +196,10 @@ static string ToTitle(string str)
//查找c++代码 //查找c++代码
static string FindCode(string texts, string name) static string FindCode(string texts, string name)
{ {
Regex reg=new Regex(@"int32\s+?"+name Regex reg = new Regex(@"int32\s+?" + name
+@"[\s\S]+?\{([\s\S]*?^)\}", + @"[\s\S]+?\{([\s\S]*?^)\}",
RegexOptions.Multiline); RegexOptions.Multiline);
Match mc=reg.Match(texts); Match mc = reg.Match(texts);
if (mc.Success) if (mc.Success)
{ {
if (mc.Groups.Count > 1) if (mc.Groups.Count > 1)
...@@ -218,7 +218,7 @@ static string FindCode(string texts, string name) ...@@ -218,7 +218,7 @@ static string FindCode(string texts, string name)
//查找返回类型 //查找返回类型
static string FindReturn(string texts) static string FindReturn(string texts)
{ {
string restr=""; string restr = "";
if (texts.IndexOf("lua_pushboolean") >= 0) if (texts.IndexOf("lua_pushboolean") >= 0)
{ {
return "bool "; return "bool ";
...@@ -292,14 +292,14 @@ static string getUserType(string str) ...@@ -292,14 +292,14 @@ static string getUserType(string str)
static void AddArgs(string texts, string regx, string arg, SortedList<int, string> dic) static void AddArgs(string texts, string regx, string arg, SortedList<int, string> dic)
{ {
//function //function
Regex reg=new Regex(regx); Regex reg = new Regex(regx);
MatchCollection mcs=reg.Matches(texts); MatchCollection mcs = reg.Matches(texts);
foreach (Match m in mcs) foreach (Match m in mcs)
{ {
if (m.Groups.Count > 1) if (m.Groups.Count > 1)
{ {
string v=arg; string v = arg;
int k=int.Parse(m.Groups[1].Value); int k = int.Parse(m.Groups[1].Value);
if (dic.ContainsKey(k)) if (dic.ContainsKey(k))
{ {
dic[k] = dic[k] + "|" + v; dic[k] = dic[k] + "|" + v;
...@@ -313,17 +313,17 @@ static void AddArgs(string texts, string regx, string arg, SortedList<int, strin ...@@ -313,17 +313,17 @@ static void AddArgs(string texts, string regx, string arg, SortedList<int, strin
} }
static string FindArgs(string texts) static string FindArgs(string texts)
{ {
SortedList<int,string> dic=new SortedList<int, string>(); SortedList<int, string> dic = new SortedList<int, string>();
//card effect ggroup //card effect ggroup
Regex reg=new Regex(@"\((\S+?)\)\s+?lua_touserdata\(L,\s+(\d+)\)"); Regex reg = new Regex(@"\((\S+?)\)\s+?lua_touserdata\(L,\s+(\d+)\)");
MatchCollection mcs=reg.Matches(texts); MatchCollection mcs = reg.Matches(texts);
foreach (Match m in mcs) foreach (Match m in mcs)
{ {
if (m.Groups.Count > 2) if (m.Groups.Count > 2)
{ {
string v=m.Groups[1].Value.ToLower(); string v = m.Groups[1].Value.ToLower();
v = getUserType(v); v = getUserType(v);
int k=int.Parse(m.Groups[2].Value); int k = int.Parse(m.Groups[2].Value);
if (dic.ContainsKey(k)) if (dic.ContainsKey(k))
{ {
dic[k] = dic[k] + "|" + v; dic[k] = dic[k] + "|" + v;
...@@ -345,7 +345,7 @@ static string FindArgs(string texts) ...@@ -345,7 +345,7 @@ static string FindArgs(string texts)
//bool //bool
AddArgs(texts, @"lua_toboolean\(L,\s+(\d+)\)", "boolean", dic); AddArgs(texts, @"lua_toboolean\(L,\s+(\d+)\)", "boolean", dic);
string args="("; string args = "(";
foreach (int i in dic.Keys) foreach (int i in dic.Keys)
{ {
args += dic[i] + ", "; args += dic[i] + ", ";
...@@ -382,9 +382,9 @@ public static void GetFunctions(string name, string texts, string file) ...@@ -382,9 +382,9 @@ public static void GetFunctions(string name, string texts, string file)
Log("error:no find file " + file); Log("error:no find file " + file);
return; return;
} }
string cpps=File.ReadAllText(file); string cpps = File.ReadAllText(file);
//lua name /cpp name //lua name /cpp name
Dictionary<string,string> fun=GetFunctionNames(texts,name); Dictionary<string, string> fun = GetFunctionNames(texts, name);
if (fun == null || fun.Count == 0) if (fun == null || fun.Count == 0)
{ {
Log("warning: no find functions of " + name); Log("warning: no find functions of " + name);
...@@ -396,18 +396,18 @@ public static void GetFunctions(string name, string texts, string file) ...@@ -396,18 +396,18 @@ public static void GetFunctions(string name, string texts, string file)
FileMode.Create, FileMode.Create,
FileAccess.Write)) FileAccess.Write))
{ {
StreamWriter sw=new StreamWriter(fs, Encoding.UTF8); StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine("========== " + name + " =========="); sw.WriteLine("========== " + name + " ==========");
File.AppendAllText(_funclisttxt, "========== " + name + " ==========" + Environment.NewLine); File.AppendAllText(_funclisttxt, "========== " + name + " ==========" + Environment.NewLine);
foreach (string k in fun.Keys) foreach (string k in fun.Keys)
{ {
string v=fun[k]; string v = fun[k];
string code=FindCode(cpps, v); string code = FindCode(cpps, v);
string txt="●"+FindReturn(code)+k+FindArgs(code) string txt = "●" + FindReturn(code) + k + FindArgs(code)
+Environment.NewLine + Environment.NewLine
+FindOldDesc(k) + FindOldDesc(k)
+Environment.NewLine + Environment.NewLine
+code; + code;
sw.WriteLine(txt); sw.WriteLine(txt);
File.AppendAllText(_funclisttxt, txt + Environment.NewLine); File.AppendAllText(_funclisttxt, txt + Environment.NewLine);
......
...@@ -36,7 +36,7 @@ public string GetMseRarity() ...@@ -36,7 +36,7 @@ public string GetMseRarity()
return "common"; return "common";
} }
string rarity=this.rarity.Trim().ToLower(); string rarity = this.rarity.Trim().ToLower();
if (rarity.Equals("common") || rarity.Equals("short print")) if (rarity.Equals("common") || rarity.Equals("short print"))
{ {
return "common"; return "common";
......
...@@ -35,12 +35,12 @@ public class MSEConfig ...@@ -35,12 +35,12 @@ public class MSEConfig
public const string TAG_MAXCOUNT = "maxcount"; public const string TAG_MAXCOUNT = "maxcount";
public const string TAG_RACE = "race"; public const string TAG_RACE = "race";
public const string TAG_TYPE = "type"; public const string TAG_TYPE = "type";
public const string TAG_WIDTH="width"; public const string TAG_WIDTH = "width";
public const string TAG_HEIGHT="height"; public const string TAG_HEIGHT = "height";
public const string TAG_REIMAGE="reimage"; public const string TAG_REIMAGE = "reimage";
public const string TAG_PEND_WIDTH="pwidth"; public const string TAG_PEND_WIDTH = "pwidth";
public const string TAG_PEND_HEIGHT="pheight"; public const string TAG_PEND_HEIGHT = "pheight";
public const string TAG_IMAGE = "imagepath"; public const string TAG_IMAGE = "imagepath";
public const string TAG_REPALCE = "replace"; public const string TAG_REPALCE = "replace";
...@@ -48,7 +48,7 @@ public class MSEConfig ...@@ -48,7 +48,7 @@ public class MSEConfig
public const string TAG_NO_TEN = "no10"; 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 TAG_REP = "%%";
public const string SEP_LINE = " "; public const string SEP_LINE = " ";
...@@ -146,7 +146,7 @@ public void SetConfig(string config, string path) ...@@ -146,7 +146,7 @@ public void SetConfig(string config, string path)
string val = ConfHelper.GetValue(line); string val = ConfHelper.GetValue(line);
string[] cs = val.Split(','); string[] cs = val.Split(',');
this.noStartCards = new long[cs.Length]; this.noStartCards = new long[cs.Length];
int i=0; int i = 0;
foreach (string str in cs) foreach (string str in cs)
{ {
long.TryParse(str, out long l); long.TryParse(str, out long l);
...@@ -190,7 +190,7 @@ public void Init(string path) ...@@ -190,7 +190,7 @@ public void Init(string path)
this.Iscn2tw = false; 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)) if (!File.Exists(tmp))
{ {
......
...@@ -305,8 +305,8 @@ public string GetType(CardType ctype) ...@@ -305,8 +305,8 @@ public string GetType(CardType ctype)
public string[] GetTypes(Card c) public string[] GetTypes(Card c)
{ {
//卡片类型,效果1,效果2,效果3 //卡片类型,效果1,效果2,效果3
int MAX_TYPE= 5; int MAX_TYPE = 5;
var types = new string[MAX_TYPE+1]; var types = new string[MAX_TYPE + 1];
types[0] = MseCardType.CARD_NORMAL; types[0] = MseCardType.CARD_NORMAL;
for (int i = 1; i < types.Length; i++) for (int i = 1; i < types.Length; i++)
{ {
...@@ -393,7 +393,7 @@ public string[] GetTypes(Card c) ...@@ -393,7 +393,7 @@ public string[] GetTypes(Card c)
list.Add(c, jpg); list.Add(c, jpg);
jpg = Path.GetFileName(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)) if (c.IsType(CardType.TYPE_SPELL) || c.IsType(CardType.TYPE_TRAP))
{ {
sw.WriteLine(this.getSpellTrap(c, jpg, c.IsType(CardType.TYPE_SPELL), cardpack, rarity)); sw.WriteLine(this.getSpellTrap(c, jpg, c.IsType(CardType.TYPE_SPELL), cardpack, rarity));
...@@ -412,7 +412,7 @@ public string[] GetTypes(Card c) ...@@ -412,7 +412,7 @@ public string[] GetTypes(Card c)
int getLinkNumber(long link) int getLinkNumber(long link)
{ {
string str = Convert.ToString(link, 2); string str = Convert.ToString(link, 2);
char[] cs = str.ToCharArray(); char[] cs = str.ToCharArray();
int i = 0; int i = 0;
foreach (char c in cs) foreach (char c in cs)
{ {
...@@ -911,7 +911,7 @@ public string GetImageCache(string img, Card card) ...@@ -911,7 +911,7 @@ public string GetImageCache(string img, Card card)
return img; return img;
} }
} }
string md5=MyUtils.GetMD5HashFromFile(img); string md5 = MyUtils.GetMD5HashFromFile(img);
if (MyUtils.Md5isEmpty(md5) || this.cfg.imagecache == null) if (MyUtils.Md5isEmpty(md5) || this.cfg.imagecache == null)
{ {
//md5为空 //md5为空
...@@ -921,7 +921,7 @@ public string GetImageCache(string img, Card card) ...@@ -921,7 +921,7 @@ public string GetImageCache(string img, Card card)
if (!File.Exists(file)) if (!File.Exists(file))
{ {
//生成缓存 //生成缓存
Bitmap bmp=MyBitmap.ReadImage(img); Bitmap bmp = MyBitmap.ReadImage(img);
//缩放 //缩放
if (isPendulum) if (isPendulum)
{ {
...@@ -943,15 +943,15 @@ public string GetImageCache(string img, Card card) ...@@ -943,15 +943,15 @@ public string GetImageCache(string img, Card card)
static EventHandler _exitHandler; static EventHandler _exitHandler;
private static void exportSetThread(object obj) private static void exportSetThread(object obj)
{ {
string[] args=(string[])obj; string[] args = (string[])obj;
if (args == null || args.Length < 3) if (args == null || args.Length < 3)
{ {
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr)); MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return; return;
} }
string mse_path=args[0]; string mse_path = args[0];
string setfile=args[1]; string setfile = args[1];
string path=args[2]; string path = args[2];
if (string.IsNullOrEmpty(mse_path) || string.IsNullOrEmpty(setfile)) if (string.IsNullOrEmpty(mse_path) || string.IsNullOrEmpty(setfile))
{ {
MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr)); MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
...@@ -959,7 +959,7 @@ private static void exportSetThread(object obj) ...@@ -959,7 +959,7 @@ private static void exportSetThread(object obj)
} }
else 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 = new System.Diagnostics.Process();
_mseProcess.StartInfo.FileName = mse_path; _mseProcess.StartInfo.FileName = mse_path;
_mseProcess.StartInfo.Arguments = cmd; _mseProcess.StartInfo.Arguments = cmd;
......
...@@ -30,7 +30,7 @@ public class CardInfo ...@@ -30,7 +30,7 @@ public class CardInfo
public int icon; public int icon;
public string description; public string description;
public string pendulum_description; public string pendulum_description;
public int[] pendulum_scales ; public int[] pendulum_scales;
public string[] subtypes; public string[] subtypes;
public string atk; public string atk;
public string def; public string def;
...@@ -57,7 +57,7 @@ public static void Test() ...@@ -57,7 +57,7 @@ public static void Test()
CardSet cardset = JsonConvert.DeserializeObject<CardSet>(json); CardSet cardset = JsonConvert.DeserializeObject<CardSet>(json);
if (cardset.cards != null) if (cardset.cards != null)
{ {
int index=0; int index = 0;
foreach (string key in cardset.cards.Keys) foreach (string key in cardset.cards.Keys)
{ {
Console.WriteLine(key); Console.WriteLine(key);
......
...@@ -133,7 +133,7 @@ public void ToImg(string img, string saveimg1) ...@@ -133,7 +133,7 @@ public void ToImg(string img, string saveimg1)
#region 检查更新 #region 检查更新
public static void CheckVersion(bool showNew) 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 (newver == CheckUpdate.DEFAULT)
{ //检查失败 { //检查失败
if (!showNew) if (!showNew)
...@@ -284,8 +284,8 @@ public void SaveMSEs(string file, Card[] cards, bool isUpdate) ...@@ -284,8 +284,8 @@ public void SaveMSEs(string file, Card[] cards, bool isUpdate)
return; return;
} }
string pack_db=MyPath.GetRealPath(MyConfig.ReadString("pack_db")); string pack_db = MyPath.GetRealPath(DEXConfig.ReadString("pack_db"));
bool rarity=MyConfig.ReadBoolean("mse_auto_rarity", false); bool rarity = DEXConfig.ReadBoolean("mse_auto_rarity", false);
#if DEBUG #if DEBUG
MessageBox.Show("db = " + pack_db + ",auto rarity=" + rarity); MessageBox.Show("db = " + pack_db + ",auto rarity=" + rarity);
#endif #endif
...@@ -325,7 +325,7 @@ public void SaveMSEs(string file, Card[] cards, bool isUpdate) ...@@ -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) public void SaveMSE(int num, string file, Card[] cards, string pack_db, bool rarity, bool isUpdate)
{ {
string setFile = file + ".txt"; 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)//仅更新文字 if (isUpdate)//仅更新文字
{ {
return; return;
...@@ -339,7 +339,7 @@ public void SaveMSE(int num, string file, Card[] cards, string pack_db, bool rar ...@@ -339,7 +339,7 @@ public void SaveMSE(int num, string file, Card[] cards, string pack_db, bool rar
zips.AddFile(setFile, "set", ""); zips.AddFile(setFile, "set", "");
foreach (Card c in images.Keys) foreach (Card c in images.Keys)
{ {
string img=images[c]; string img = images[c];
if (this.isCancel) if (this.isCancel)
{ {
break; 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) ...@@ -45,8 +45,8 @@ private void EffectCreatorForm_Load(object sender, EventArgs e)
{ {
return; return;
} }
char[] sepChars = new char[]{' ','\t',' '}; char[] sepChars = new char[] { ' ', '\t', ' ' };
FileStream fs = new FileStream(config,FileMode.Open); FileStream fs = new FileStream(config, FileMode.Open);
StreamReader sr = new StreamReader(fs); StreamReader sr = new StreamReader(fs);
string nowType = ""; string nowType = "";
for (string line = sr.ReadLine(); line != null; line = sr.ReadLine()) for (string line = sr.ReadLine(); line != null; line = sr.ReadLine())
...@@ -65,7 +65,7 @@ private void EffectCreatorForm_Load(object sender, EventArgs e) ...@@ -65,7 +65,7 @@ private void EffectCreatorForm_Load(object sender, EventArgs e)
{ {
continue; continue;
} }
string[] split = line.Split(sepChars,StringSplitOptions.RemoveEmptyEntries); string[] split = line.Split(sepChars, StringSplitOptions.RemoveEmptyEntries);
if (split.Length == 2) if (split.Length == 2)
{ {
itemDic[nowType].Add(new EffectCreatorItem(split[0], split[1])); itemDic[nowType].Add(new EffectCreatorItem(split[0], split[1]));
......
using System; 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; using System.Windows.Forms;
namespace DataEditorX namespace DataEditorX
......
...@@ -51,11 +51,11 @@ public enum LMSG : uint ...@@ -51,11 +51,11 @@ public enum LMSG : uint
ydkType = 0x22, ydkType = 0x22,
Setcode_error = 0x23, Setcode_error = 0x23,
SelectImage = 0x24, SelectImage = 0x24,
ImageType =0x25, ImageType = 0x25,
RunError = 0x26, RunError = 0x26,
checkUpdate = 0x27, checkUpdate = 0x27,
CopyCardsToDB = 0x28, CopyCardsToDB = 0x28,
CopyCardsToDBIsOK =0x29, CopyCardsToDBIsOK = 0x29,
selectMseset = 0x2a, selectMseset = 0x2a,
MseType = 0x2b, MseType = 0x2b,
SaveMse = 0x2c, SaveMse = 0x2c,
...@@ -83,10 +83,10 @@ public enum LMSG : uint ...@@ -83,10 +83,10 @@ public enum LMSG : uint
CheckText = 0x40, CheckText = 0x40,
CompareOK = 0x41, CompareOK = 0x41,
OpenFile = 0x42, OpenFile = 0x42,
ScriptFilter =0x43, ScriptFilter = 0x43,
NewFile = 0x44, NewFile = 0x44,
SaveFileOK = 0x45, SaveFileOK = 0x45,
IfSaveScript =0x46, IfSaveScript = 0x46,
ReadMSE = 0x47, ReadMSE = 0x47,
ReadMSEisOK = 0x48, ReadMSEisOK = 0x48,
......
...@@ -78,6 +78,8 @@ private void InitializeComponent() ...@@ -78,6 +78,8 @@ private void InitializeComponent()
this.dockPanel.Size = new System.Drawing.Size(992, 725); this.dockPanel.Size = new System.Drawing.Size(992, 725);
this.dockPanel.TabIndex = 0; this.dockPanel.TabIndex = 0;
this.dockPanel.Theme = this.theme; 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 // mainMenu
// //
...@@ -277,6 +279,7 @@ private void InitializeComponent() ...@@ -277,6 +279,7 @@ private void InitializeComponent()
// //
// MainForm // MainForm
// //
this.AllowDrop = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.SystemColors.Control; this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(992, 749); this.ClientSize = new System.Drawing.Size(992, 749);
......
...@@ -54,7 +54,7 @@ public void SetDataPath(string datapath) ...@@ -54,7 +54,7 @@ public void SetDataPath(string datapath)
this.tCards = null; this.tCards = null;
//数据目录 //数据目录
this.datapath = datapath; this.datapath = datapath;
if (MyConfig.ReadBoolean(MyConfig.TAG_ASYNC)) if (DEXConfig.ReadBoolean(DEXConfig.TAG_ASYNC))
{ {
//后台加载数据 //后台加载数据
this.bgWorker1.RunWorkerAsync(); this.bgWorker1.RunWorkerAsync();
...@@ -76,16 +76,16 @@ public void SetOpenFile(string file) ...@@ -76,16 +76,16 @@ public void SetOpenFile(string file)
void Init() void Init()
{ {
//文件路径 //文件路径
this.conflang = MyConfig.GetLanguageFile(this.datapath); this.conflang = DEXConfig.GetLanguageFile(this.datapath);
//游戏数据,MSE数据 //游戏数据,MSE数据
this.datacfg = new DataConfig(MyConfig.GetCardInfoFile(this.datapath)); this.datacfg = new DataConfig(DEXConfig.GetCardInfoFile(this.datapath));
//初始化YGOUtil的数据 //初始化YGOUtil的数据
YGOUtil.SetConfig(this.datacfg); YGOUtil.SetConfig(this.datacfg);
//代码提示 //代码提示
string funtxt = MyPath.Combine(this.datapath, MyConfig.FILE_FUNCTION); string funtxt = MyPath.Combine(this.datapath, DEXConfig.FILE_FUNCTION);
string conlua = MyPath.Combine(this.datapath, MyConfig.FILE_CONSTANT); string conlua = MyPath.Combine(this.datapath, DEXConfig.FILE_CONSTANT);
string confstring = MyPath.Combine(this.datapath, MyConfig.FILE_STRINGS); string confstring = MyPath.Combine(this.datapath, DEXConfig.FILE_STRINGS);
this.codecfg = new CodeConfig(); this.codecfg = new CodeConfig();
//添加函数 //添加函数
this.codecfg.AddFunction(funtxt); this.codecfg.AddFunction(funtxt);
...@@ -98,7 +98,7 @@ void Init() ...@@ -98,7 +98,7 @@ void Init()
this.codecfg.InitAutoMenus(); this.codecfg.InitAutoMenus();
this.history = new History(this); 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); LanguageHelper.LoadFormLabels(this.conflang);
} }
...@@ -158,8 +158,8 @@ protected override void DefWndProc(ref Message m) ...@@ -158,8 +158,8 @@ protected override void DefWndProc(ref Message m)
{ {
switch (m.Msg) switch (m.Msg)
{ {
case MyConfig.WM_OPEN://处理消息 case DEXConfig.WM_OPEN://处理消息
string file = MyPath.Combine(Application.StartupPath, MyConfig.FILE_TEMP); string file = MyPath.Combine(Application.StartupPath, DEXConfig.FILE_TEMP);
if (File.Exists(file)) if (File.Exists(file))
{ {
this.Activate(); this.Activate();
...@@ -180,7 +180,7 @@ protected override void DefWndProc(ref Message m) ...@@ -180,7 +180,7 @@ protected override void DefWndProc(ref Message m)
//打开脚本 //打开脚本
void OpenScript(string file) void OpenScript(string file)
{ {
if (MyConfig.ReadString(MyConfig.USE_EDITOR) == "Avalon") if (DEXConfig.ReadString(DEXConfig.USE_EDITOR) == "Avalon")
{ {
CodeEditForm_Avalon cf = new CodeEditForm_Avalon(); CodeEditForm_Avalon cf = new CodeEditForm_Avalon();
//设置界面语言 //设置界面语言
...@@ -577,10 +577,27 @@ private void bgWorker1_RunWorkerCompleted(object sender, System.ComponentModel.R ...@@ -577,10 +577,27 @@ private void bgWorker1_RunWorkerCompleted(object sender, System.ComponentModel.R
} }
#endregion #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) 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) Thread th = new Thread(this.CheckUpdate)
{ {
......
...@@ -47,17 +47,17 @@ public class Location ...@@ -47,17 +47,17 @@ public class Location
public int LocationInt; public int LocationInt;
enum LocationStrings enum LocationStrings
{ {
LOCATION_DECK =0x01, LOCATION_DECK = 0x01,
LOCATION_HAND =0x02, LOCATION_HAND = 0x02,
LOCATION_MZONE =0x04, LOCATION_MZONE = 0x04,
LOCATION_SZONE =0x08, LOCATION_SZONE = 0x08,
LOCATION_GRAVE =0x10, LOCATION_GRAVE = 0x10,
LOCATION_REMOVED =0x20, LOCATION_REMOVED = 0x20,
LOCATION_EXTRA =0x40, LOCATION_EXTRA = 0x40,
LOCATION_OVERLAY =0x80, LOCATION_OVERLAY = 0x80,
LOCATION_ONFIELD =0x0c, LOCATION_ONFIELD = 0x0c,
LOCATION_DECKBOT =0x10001, LOCATION_DECKBOT = 0x10001,
LOCATION_DECKSHF =0x20001 LOCATION_DECKSHF = 0x20001
} }
public override string ToString() public override string ToString()
......
...@@ -20,14 +20,14 @@ internal sealed class Program ...@@ -20,14 +20,14 @@ internal sealed class Program
private static void Main(string[] args) private static void Main(string[] args)
{ {
string arg = (args.Length > 0) ? args[0] : ""; 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(); SaveLanguage();
MessageBox.Show("Save Language OK."); MessageBox.Show("Save Language OK.");
Environment.Exit(1); Environment.Exit(1);
} }
if (MyConfig.OpenOnExistForm(arg))//在已经存在的窗口打开文件 if (DEXConfig.OpenOnExistForm(arg))//在已经存在的窗口打开文件
{ {
Environment.Exit(1); Environment.Exit(1);
} }
...@@ -39,15 +39,15 @@ private static void Main(string[] args) ...@@ -39,15 +39,15 @@ private static void Main(string[] args)
//设置将要打开的文件 //设置将要打开的文件
mainForm.SetOpenFile(arg); mainForm.SetOpenFile(arg);
//数据目录 //数据目录
mainForm.SetDataPath(MyPath.Combine(Application.StartupPath, MyConfig.TAG_DATA)); mainForm.SetDataPath(MyPath.Combine(Application.StartupPath, DEXConfig.TAG_DATA));
Application.Run(mainForm); Application.Run(mainForm);
} }
} }
static void SaveLanguage() static void SaveLanguage()
{ {
string datapath = MyPath.Combine(Application.StartupPath, MyConfig.TAG_DATA); string datapath = MyPath.Combine(Application.StartupPath, DEXConfig.TAG_DATA);
string conflang = MyConfig.GetLanguageFile(datapath); string conflang = DEXConfig.GetLanguageFile(datapath);
LanguageHelper.LoadFormLabels(conflang); LanguageHelper.LoadFormLabels(conflang);
LanguageHelper langhelper = new LanguageHelper(); LanguageHelper langhelper = new LanguageHelper();
MainForm form1 = new MainForm(); MainForm form1 = new MainForm();
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<add key="image_xyz" value="24,51,128,128"/> <add key="image_xyz" value="24,51,128,128"/>
<add key="image_pendulum" value="16,50,147,109"/> <add key="image_pendulum" value="16,50,147,109"/>
<add key="editor" value="Avalon"/> <add key="editor" value="Avalon"/>
<!-- CodeEdiotr Setting <!-- CodeEditor Setting
IME = true 使用輸入法,正常顯示文字,反應變慢 IME = true 使用輸入法,正常顯示文字,反應變慢
IME = false English IME = false English
--> -->
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<add key="wordwrap" value="true"/> <add key="wordwrap" value="true"/>
<add key="tabisspace" value="false"/> <add key="tabisspace" value="false"/>
<add key="fontname" value="Consolas"/> <add key="fontname" value="Consolas"/>
<add key="fontsize" value="18.5"/> <add key="fontsize" value="16"/>
<!-- MSE path--> <!-- MSE path-->
<add key="mse_path" value="./MagicSetEditor2/mse.exe"/> <add key="mse_path" value="./MagicSetEditor2/mse.exe"/>
<add key="mse_exprotpath" value="./exprot"/> <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