Commit 1b0a5bfc authored by nanahira's avatar nanahira Committed by GitHub

Merge pull request #4 from Yumekaki/patch-2

automatically gets external script
parents 6d909b48 db508261
...@@ -276,18 +276,29 @@ public bool OpenScript(bool openinthis, string addrequire) ...@@ -276,18 +276,29 @@ public bool OpenScript(bool openinthis, string addrequire)
FileMode.OpenOrCreate,FileAccess.Write)) FileMode.OpenOrCreate,FileAccess.Write))
{ {
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false)); StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
if (c.id > 0) { //card script if (string.IsNullOrEmpty(addrequire))
sw.WriteLine("--" + c.name); {
sw.WriteLine("local m=" + id.ToString()); // OCG script
sw.WriteLine("local cm=_G[\"c\"..m]"); sw.WriteLine("--" + c.name);
if (addrequire.Length > 0) sw.WriteLine("function c" + id.ToString() + ".initial_effect(c)");
sw.WriteLine("xpcall(function() require(\"expansions/script/" + addrequire + "\") end,function() require(\"script/" + addrequire + "\") end)"); sw.WriteLine("\t");
sw.WriteLine("function cm.initial_effect(c)"); sw.WriteLine("end");
sw.WriteLine("\t"); }
sw.WriteLine("end"); else
} else { //module script {
sw.WriteLine("--Module script \"" + addrequire + "\""); // DIY script
} sw.WriteLine("--" + c.name);
sw.WriteLine("local m=" + id.ToString());
sw.WriteLine("local cm=_G[\"c\"..m]");
sw.WriteLine("xpcall(function() require(\"expansions/script/" + addrequire + "\") end,function() require(\"script/" + addrequire + "\") end)");
sw.WriteLine("function cm.initial_effect(c)");
sw.WriteLine("\t");
sw.WriteLine("end");
}
/*else
{ //module script
sw.WriteLine("--Module script \"" + addrequire + "\"");
}*/
sw.Close(); sw.Close();
fs.Close(); fs.Close();
} }
......
...@@ -23,7 +23,28 @@ namespace DataEditorX ...@@ -23,7 +23,28 @@ namespace DataEditorX
{ {
public partial class DataEditForm : DockContent, IDataForm public partial class DataEditForm : DockContent, IDataForm
{ {
public string addrequire; private string addrequire_str;
public string addrequire
{
get
{
if (!string.IsNullOrEmpty(addrequire_str))
return addrequire_str;
else
{
string cdbName = Path.GetFileNameWithoutExtension(nowCdbFile);
if (cdbName.Length > 0 && File.Exists(GetPath().GetModuleScript(cdbName)))
return cdbName;
}
return "";
}
set
{
addrequire_str = value;
}
}
#region 成员变量/构造 #region 成员变量/构造
TaskHelper tasker = null; TaskHelper tasker = null;
string taskname; string taskname;
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment