Commit 60be6d5c authored by JoyJ's avatar JoyJ

version 4.0.0.7 search improve

parent 6c5a754b
Pipeline #23370 passed with stages
in 35 seconds
......@@ -352,31 +352,6 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs
{
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
......@@ -398,13 +373,29 @@ private void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs
}
foreach (var d in tooltipDic)
{
if (d.Key.ToLower().StartsWith(find))
if (d.Key.ToUpper() == d.Key && find.ToUpper() == find && d.Key.StartsWith(find))
{
data.Add(new YGOProAutoCompletion(d.Key, d.Value));
}
else if (d.Key.ToLower().StartsWith(find.ToLower()))
{
data.Add(new YGOProAutoCompletion(d.Key, d.Value));
}
}
foreach (var d in tooltipDic)
{
if (d.Key.ToUpper() == d.Key && find.ToUpper() == find && d.Key.Contains(find))
{
data.Add(new YGOProAutoCompletion(d.Key, d.Value));
}
if (d.Key.ToLower().Contains(find.ToLower()))
{
data.Add(new YGOProAutoCompletion(d.Key, d.Value));
}
}
if (data.Count > 0)
{
completionWindowUse.SizeToContent = SizeToContent.Width;
completionWindowUse.Show();
string find2 = data[0].Text;
var ePos = editor.TextArea.Caret.CalculateCaretRectangle();
......
using System.IO;
using System;
using System.IO;
namespace DataEditorX.Config
{
......@@ -70,9 +71,9 @@ public string GetScript(string id)
{
return MyPath.Combine(this.luapath, "c" + id + ".lua");
}
public string GetModuleScript(string modulescript)
public string GetRandomName()
{
return MyPath.Combine(this.luapath, modulescript + ".lua");
return MyPath.Combine(this.luapath, "noname_" + new Random().Next(10000,100000) + ".lua");
}
public string[] GetCardfiles(long id)
......
using DataEditorX.Config;
using DataEditorX.Language;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
......@@ -287,7 +288,7 @@ public bool OpenScript(bool openinthis, string addrequire)
}
else if (addrequire.Length > 0)
{
lua = this.dataform.GetPath().GetModuleScript(addrequire);
lua = this.dataform.GetPath().GetRandomName();
}
else
{
......@@ -302,7 +303,13 @@ public bool OpenScript(bool openinthis, string addrequire)
FileMode.OpenOrCreate, FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
if (!DEXConfig.ReadBoolean(DEXConfig.TAG_ADD_REQUIRE))
string template = "";
try
{
template = File.ReadAllText(addrequire);
}
catch { }
if (!DEXConfig.ReadBoolean(DEXConfig.TAG_ADD_REQUIRE) || template == "")
{
// OCG script
sw.WriteLine("--" + c.name);
......@@ -312,21 +319,14 @@ public bool OpenScript(bool openinthis, string addrequire)
}
else
{
// DIY script
sw.WriteLine("--" + c.name);
sw.WriteLine("local this,id,ofs=GetID()");
if (addrequire.Length > 0)
{
sw.WriteLine("Duel.LoadScript(\"" + addrequire + ".lua\")");
}
sw.WriteLine("function this.initial_effect(c)");
sw.WriteLine("\t");
sw.WriteLine("end");
FileInfo fi = new FileInfo(lua);
template = template.Replace("{file_name}", Path.GetFileNameWithoutExtension(lua));
template = template.Replace("{ext_name}", fi.Extension);
template = template.Replace("{card_name}", c.name);
template = template.Replace("{date}", DateTime.Now.ToString("yyyy/MM/dd"));
template = template.Replace("{time}", DateTime.Now.ToString("HH:mm:ss"));
sw.Write(template);
}
/*else
{ //module script
sw.WriteLine("--Module script \"" + addrequire + "\"");
}*/
sw.Close();
fs.Close();
}
......
......@@ -394,12 +394,6 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
string readme = MyPath.Combine(path, name + ".txt");
//新卡ydk
string deckydk = ygopath.GetYdk(name);
//module scripts
string extra_script = "";
if (modulescript.Length > 0)
{
extra_script = ygopath.GetModuleScript(modulescript);
}
File.Delete(cdbfile);
DataBase.Create(cdbfile);
......@@ -422,11 +416,6 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
zips.AddFile(deckydk, "deck/" + name + ".ydk", "");
}
if (modulescript.Length > 0 && File.Exists(extra_script))
{
zips.AddFile(extra_script, extra_script.Replace(path, ""), "");
}
foreach (Card c in cards)
{
i++;
......@@ -434,7 +423,7 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
string[] files = ygopath.GetCardfiles(c.id);
foreach (string file in files)
{
if (!string.Equals(file, extra_script) && File.Exists(file))
if (File.Exists(file))
{
zips.AddFile(file, file.Replace(path, ""), "");
}
......
This diff is collapsed.
......@@ -35,12 +35,13 @@ public string Addrequire
{
return this.addrequire_str;
}
else
else if (CheckOpen())
{
string cdbName = Path.GetFileNameWithoutExtension(this.nowCdbFile);
if (cdbName.Length > 0 && File.Exists(this.GetPath().GetModuleScript(cdbName)))
FileInfo fi = new FileInfo(this.nowCdbFile);
string lua = $"{fi.DirectoryName}\\{Path.GetFileNameWithoutExtension(this.nowCdbFile)}.lua";
if (File.Exists(lua))
{
return cdbName;
return lua;
}
}
return "";
......@@ -305,7 +306,7 @@ void InitPath(string datapath)
}
}
#endregion
DataConfig dataConfig;
#region 界面控件
//初始化控件
public void InitControl(DataConfig datacfg)
......@@ -315,6 +316,8 @@ public void InitControl(DataConfig datacfg)
return;
}
dataConfig = datacfg;
List<long> setcodes = DataManager.GetKeys(datacfg.dicSetnames);
string[] setnames = DataManager.GetValues(datacfg.dicSetnames);
try
......@@ -326,10 +329,14 @@ public void InitControl(DataConfig datacfg)
this.InitCheckPanel(this.pl_cardtype, datacfg.dicCardTypes);
this.InitCheckPanel(this.pl_markers, datacfg.dicLinkMarkers);
this.InitCheckPanel(this.pl_category, datacfg.dicCardcategorys);
this.InitComboBox(this.cb_setname1, setcodes, setnames);
this.InitComboBox(this.cb_setname2, setcodes, setnames);
this.InitComboBox(this.cb_setname3, setcodes, setnames);
this.InitComboBox(this.cb_setname4, setcodes, setnames);
for(int i = 0; i < filtered.Length; i++)
{
filtered[i] = false;
}
this.InitSetCode(this.cb_setname1, datacfg.dicSetnames);
this.InitSetCode(this.cb_setname2, datacfg.dicSetnames);
this.InitSetCode(this.cb_setname3, datacfg.dicSetnames);
this.InitSetCode(this.cb_setname4, datacfg.dicSetnames);
}
catch (Exception ex)
{
......@@ -373,7 +380,46 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
fpanel.ResumeLayout(false);
fpanel.PerformLayout();
}
class SetCodeItem
{
public long Key;
public string Name;
public SetCodeItem(long key, string name)
{
Key = key;
Name = name;
}
public override string ToString()
{
return Name;
/*
if (Name == "自定义")
{
return "自定义";
}
return $"{Name}(0x{Key:x})";
*/
}
}
//初始化ComboBox
void InitSetCode(ComboBox cb, Dictionary<long, string> tempdic)
{
int index = int.Parse(cb.Name.Substring(cb.Name.Length - 1));
setcodeIsedit[index] = true;
cb.Items.Clear();
foreach (var kv in tempdic)
{
SetCodeItem sci = new SetCodeItem(kv.Key, kv.Value);
cb.Items.Add(sci);
}
setcodeIsedit[index] = false;
if (cb.Items.Count > 0)
{
cb.SelectedIndex = 0;
}
}
//初始化ComboBox
void InitComboBox(ComboBox cb, Dictionary<long, string> tempdic)
{
......@@ -729,6 +775,26 @@ public Card GetCard()
//列表选择
void Lv_cardlistSelectedIndexChanged(object sender, EventArgs e)
{
if (filtered[0])
{
filtered[0] = false;
InitSetCode(cb_setname1, dataConfig.dicSetnames);
}
if (filtered[1])
{
filtered[1] = false;
InitSetCode(cb_setname2, dataConfig.dicSetnames);
}
if (filtered[2])
{
filtered[2] = false;
InitSetCode(cb_setname3, dataConfig.dicSetnames);
}
if (filtered[3])
{
filtered[3] = false;
InitSetCode(cb_setname4, dataConfig.dicSetnames);
}
if (this.lv_cardlist.SelectedItems.Count > 0)
{
int sel = this.lv_cardlist.SelectedItems[0].Index;
......@@ -917,6 +983,18 @@ public void Reset()
{
this.oldCard = new Card(0);
this.SetCard(this.oldCard);
this.InitSetCode(this.cb_setname1, dataConfig.dicSetnames);
this.InitSetCode(this.cb_setname2, dataConfig.dicSetnames);
this.InitSetCode(this.cb_setname3, dataConfig.dicSetnames);
this.InitSetCode(this.cb_setname4, dataConfig.dicSetnames);
for (int i = 0; i < filtered.Length; i++)
{
filtered[i] = false;
}
this.tb_setcode1.Text = "0";
this.tb_setcode2.Text = "0";
this.tb_setcode3.Text = "0";
this.tb_setcode4.Text = "0";
}
#endregion
......@@ -1817,11 +1895,6 @@ void setCode_InputText(int index, ComboBox cb, TextBox tb)
{
if (index >= 0 && index < this.setcodeIsedit.Length)
{
if (this.setcodeIsedit[index])//如果正在编辑
{
return;
}
this.setcodeIsedit[index] = true;
int.TryParse(tb.Text, NumberStyles.HexNumber, null, out int temp);
//tb.Text = temp.ToString("x");
......@@ -1830,7 +1903,14 @@ void setCode_InputText(int index, ComboBox cb, TextBox tb)
temp = -1;
}
this.SetSelect(cb, temp);
foreach (SetCodeItem sci in cb.Items)
{
if (sci.Key == temp && temp > 0 && temp < 0xffff)
{
cb.SelectedItem = sci;
return;
}
}
this.setcodeIsedit[index] = false;
}
}
......@@ -1859,18 +1939,16 @@ private void tb_setcode4_TextChanged(object sender, EventArgs e)
//系列选择框 选择时
void setCode_Selected(int index, ComboBox cb, TextBox tb)
{
if (index >= 0 && index < this.setcodeIsedit.Length)
try
{
if (this.setcodeIsedit[index])//如果正在编辑
SetCodeItem sci = cb.SelectedItem as SetCodeItem;
if (sci != null)
{
return;
tb.Text = sci.Key.ToString("x");
}
this.setcodeIsedit[index] = true;
long tmp = this.GetSelect(cb);
tb.Text = tmp.ToString("x");
this.setcodeIsedit[index] = false;
}
catch { }
}
private void cb_setname1_SelectedIndexChanged(object sender, EventArgs e)
{
......@@ -1960,8 +2038,8 @@ private void menuitem_autocheckupdate_Click(object sender, EventArgs e)
//add require automatically
private void menuitem_addrequire_Click(object sender, EventArgs e)
{
this.Addrequire = Microsoft.VisualBasic.Interaction.InputBox("Module script?\n\nPress \"Cancel\" to remove module script.", "", this.Addrequire);
this.menuitem_addrequire.Checked = !this.menuitem_addrequire.Checked;
this.Addrequire = Microsoft.VisualBasic.Interaction.InputBox(LanguageHelper.GetMsg(LMSG.TemplateFileHint), LanguageHelper.GetMsg(LMSG.About), this.Addrequire);
this.menuitem_addrequire.Checked = Addrequire != "";
XMLReader.Save(DEXConfig.TAG_ADD_REQUIRE_STRING, this.Addrequire);
XMLReader.Save(DEXConfig.TAG_ADD_REQUIRE, this.menuitem_addrequire.Checked ? "true" : "false");
}
......@@ -2426,6 +2504,34 @@ private void menuMergeDatabase_Click(object sender, EventArgs e)
}
}
private void setCode_TextChanged(object sender, EventArgs e)
{
}
private void setName_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)
{
return;
}
ComboBox cb = (ComboBox)sender;
int index = int.Parse(cb.Name.Substring(cb.Name.Length - 1));
filtered[index - 1] = true;
Dictionary<long, string> tmpSetname = new Dictionary<long, string>();
foreach (var kv in dataConfig.dicSetnames)
{
if (kv.Value.Contains(cb.Text))
{
tmpSetname.Add(kv.Key, kv.Value);
}
}
InitSetCode(cb, tmpSetname);
}
bool[] filtered = new bool[4];
private void lv_cardlist_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
}
void Tb_linkKeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != '0' && e.KeyChar != '1' && e.KeyChar != 1 && e.KeyChar != 22 && e.KeyChar != 3 && e.KeyChar != 8)
......
......@@ -234,6 +234,9 @@
<None Include="data\constant.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="data\lua_template.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="data\strings.conf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
......@@ -100,6 +100,7 @@ public enum LMSG : uint
CdbTypeOnly = 0x50,
MergeHint = 0x51,
MergeComplete = 0x52,
TemplateFileHint = 0x53,
COUNT,
}
}
......@@ -9,12 +9,12 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DataEditorX")]
[assembly: AssemblyDescription("E-mail:nanahira@momobako.com")]
[assembly: AssemblyDescription("E-mail:316351048@qq.com")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Mycard")]
[assembly: AssemblyProduct("DataEditorX")]
[assembly: AssemblyCopyright("Copyright 2020-2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright 2020-2023")]
[assembly: AssemblyTrademark("Mycard")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
......@@ -27,4 +27,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("4.0.0.6")]
\ No newline at end of file
[assembly: AssemblyVersion("4.0.0.7")]
\ No newline at end of file
★更新历史
4.0.0.7
现在可以直接在字段位置搜索和过滤字段了(按回车搜索)。按重置键可以把字段重置到初始。
现在自动完成菜单也会提示包含当前输入的字符串的函数。
现在自动完成菜单只有在当前输入的字符串全部为大写时才匹配常量。
把”自动添加require“修改为”设置使用的模板文件“。现在可以自己撰写模板文件了。顺便修正了启用禁用不正常的bug。
※此为破坏性改动。此前打包时会把模板文件一起打包,现在不会这样做了。
修复了一些字段搜索的问题。
4.0.0.6
修正了一些函数提示的问题(by 尸体233)。
如果在字段框里输入汉字,DEX现在会在你点击别处或点击回车键时搜索一次对应的字段。没找到的话会把那个字段重置成0。
......
......@@ -80,7 +80,7 @@ DataEditForm.mainMenu.menuitem_mseconfig 设置MSE的配置文件
DataEditForm.mainMenu.menu_data 数据(&D)
DataEditForm.mainMenu.menuitem_operacardsfile 同步操作卡片图片和脚本
DataEditForm.mainMenu.menuitem_openfileinthis 用CodeEditor打开脚本
DataEditForm.mainMenu.menuitem_addrequire 创建脚本时自动添加require
DataEditForm.mainMenu.menuitem_addrequire 设置新脚本模板文件
DataEditForm.mainMenu.menuitem_findluafunc 从C++源码查找Lua函数
DataEditForm.mainMenu.menuitem_readydk 从卡组文件读取卡片(&Y)
DataEditForm.mainMenu.menuitem_readimages 从卡图文件夹读取卡片(&I)
......@@ -207,4 +207,5 @@ MainForm.mainMenu.menuitem_closeall 关闭所有
0x4f 无效的文件名。只支持类似[cXXXXXXXX.lua]的文件。
0x50 数据库文件(*.cdb)|*.cdb|所有文件(*.*)|*.*
0x51 如果遇到重复的卡,是否要进行覆盖?
0x52 合并完成!共读取了{0}张卡。
\ No newline at end of file
0x52 合并完成!共读取了{0}张卡。
0x53 请输入模板lua文件名,按取消则不使用模板文件。\n在创建新脚本文件时,DataEditorX会用该模板文件生成新脚本,并把该模板文件中的以下字符串自动替换:\n{file_name}=>文件名(不含扩展名)\n{ext_name}=>文件扩展名\n{card_name}=>卡名\n{date}=>yyyy/MM/dd格式的当前日期\n{time}HH:mm:ss格式的当前时间\n\n示例文件可以查看data文件夹下的lua_template.lua。
\ No newline at end of file
--{card_name}
--scripted by Knight of Hanoi
--{date} {time}
Duel.LoadScript("some_script.lua")
function {file_name}.initial_effect(c)
end
[DataEditorX]4.0.0.6[DataEditorX]
[URL]https://cdn01.moecube.com/DataEditorX/releases/DataEditorX-4.0.0.6.zip[URL]
[DataEditorX]4.0.0.7[DataEditorX]
[URL]https://cdn01.moecube.com/DataEditorX/releases/DataEditorX-4.0.0.7.zip[URL]
★运行环境(Environment)
本程序基于.Net framework 4.6开发
......
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