Commit 75569ced authored by mercury233's avatar mercury233

support command lines

parent 0db689f2
...@@ -105,7 +105,7 @@ public class Menu : WindowServantSP ...@@ -105,7 +105,7 @@ public class Menu : WindowServantSP
} }
} }
void onClickExit() public void onClickExit()
{ {
Program.I().quit(); Program.I().quit();
Program.Running = false; Program.Running = false;
...@@ -194,8 +194,20 @@ public class Menu : WindowServantSP ...@@ -194,8 +194,20 @@ public class Menu : WindowServantSP
string all = ""; string all = "";
try try
{ {
all = File.ReadAllText("commamd.shell",Encoding.UTF8); all = File.ReadAllText("commamd.shell", Encoding.UTF8);
string[] mats = all.Split(" "); char[] parmChars = all.ToCharArray();
bool inQuote = false;
for (int index = 0; index < parmChars.Length; index++)
{
if (parmChars[index] == '"')
{
inQuote = !inQuote;
parmChars[index] = '\n';
}
if (!inQuote && parmChars[index] == ' ')
parmChars[index] = '\n';
}
string[] mats = (new string(parmChars)).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length > 0) if (mats.Length > 0)
{ {
switch (mats[0]) switch (mats[0])
......
...@@ -758,7 +758,11 @@ public class Ocgcore : ServantWithCardDescription ...@@ -758,7 +758,11 @@ public class Ocgcore : ServantWithCardDescription
public void returnTo() public void returnTo()
{ {
TcpHelper.SaveRecord(); TcpHelper.SaveRecord();
if (returnServant != null) if (Program.exitOnReturn)
{
Program.I().menu.onClickExit();
}
else if (returnServant != null)
{ {
Program.I().shiftToServant(returnServant); Program.I().shiftToServant(returnServant);
} }
......
...@@ -412,11 +412,91 @@ public class Program : MonoBehaviour ...@@ -412,11 +412,91 @@ public class Program : MonoBehaviour
initializeALLservants(); initializeALLservants();
loadResources(); loadResources();
readParams();
}); });
} }
void readParams()
{
var args = Environment.GetCommandLineArgs();
string nick = null;
string host = null;
string port = null;
string password = null;
string deck = null;
string replay = null;
string puzzle = null;
bool join = false;
for (int i = 0; i < args.Length; i++)
{
if (args[i].ToLower() == "-n" && args.Length > i + 1)
{
nick = args[++i];
if (nick.Contains(" "))
nick = "\"" + nick + "\"";
}
if (args[i].ToLower() == "-h" && args.Length > i + 1)
{
host = args[++i];
}
if (args[i].ToLower() == "-p" && args.Length > i + 1)
{
port = args[++i];
}
if (args[i].ToLower() == "-w" && args.Length > i + 1)
{
password = args[++i];
if (password.Contains(" "))
password = "\"" + password + "\"";
}
if (args[i].ToLower() == "-d" && args.Length > i + 1)
{
deck = args[++i];
if (deck.Contains(" "))
deck = "\"" + deck + "\"";
}
if (args[i].ToLower() == "-r" && args.Length > i + 1)
{
replay = args[++i];
if (replay.Contains(" "))
replay = "\"" + replay + "\"";
}
if (args[i].ToLower() == "-s" && args.Length > i + 1)
{
puzzle = args[++i];
if (puzzle.Contains(" "))
puzzle = "\"" + puzzle + "\"";
}
if (args[i].ToLower() == "-j")
{
join = true;
Config.Set("deckInUse", deck);
}
}
string cmdFile = "commamd.shell";
if (join)
{
File.WriteAllText(cmdFile, "online " + nick + " " + host + " " + port + " 0x233 " + password, Encoding.UTF8);
Program.exitOnReturn = true;
}
else if (deck != null)
{
File.WriteAllText(cmdFile, "edit " + deck, Encoding.UTF8);
Program.exitOnReturn = true;
}
else if (replay != null)
{
File.WriteAllText(cmdFile, "replay " + replay, Encoding.UTF8);
Program.exitOnReturn = true;
}
else if (puzzle != null)
{
File.WriteAllText(cmdFile, "puzzle " + puzzle, Encoding.UTF8);
Program.exitOnReturn = true;
}
}
public GameObject mouseParticle; public GameObject mouseParticle;
static int lastChargeTime = 0; static int lastChargeTime = 0;
...@@ -1040,6 +1120,8 @@ public class Program : MonoBehaviour ...@@ -1040,6 +1120,8 @@ public class Program : MonoBehaviour
public static bool noAccess = false; public static bool noAccess = false;
public static bool exitOnReturn = false;
void OnApplicationQuit() void OnApplicationQuit()
{ {
TcpHelper.SaveRecord(); TcpHelper.SaveRecord();
......
...@@ -26,7 +26,7 @@ public class AIRoom : WindowServantSP ...@@ -26,7 +26,7 @@ public class AIRoom : WindowServantSP
UIHelper.registEvent(gameObject, "aideck_", onSave); UIHelper.registEvent(gameObject, "aideck_", onSave);
UIHelper.registEvent(gameObject, "rank_", onSave); UIHelper.registEvent(gameObject, "rank_", onSave);
UIHelper.registEvent(gameObject, "start_", onStart); UIHelper.registEvent(gameObject, "start_", onStart);
UIHelper.registEvent(gameObject, "exit_", ()=> { Program.I().shiftToServant(Program.I().menu); }); UIHelper.registEvent(gameObject, "exit_", onClickExit);
UIHelper.trySetLableText(gameObject,"percyHint",InterString.Get("人机模式")); UIHelper.trySetLableText(gameObject,"percyHint",InterString.Get("人机模式"));
superScrollView.install(); superScrollView.install();
SetActiveFalse(); SetActiveFalse();
...@@ -43,6 +43,14 @@ public class AIRoom : WindowServantSP ...@@ -43,6 +43,14 @@ public class AIRoom : WindowServantSP
Config.Set("list_airank", list_airank.value); Config.Set("list_airank", list_airank.value);
} }
void onClickExit()
{
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu);
}
void onStart() void onStart()
{ {
if (!isShowed) if (!isShowed)
......
...@@ -62,6 +62,14 @@ public class selectDeck : WindowServantSP ...@@ -62,6 +62,14 @@ public class selectDeck : WindowServantSP
KF_editDeck(superScrollView.selectedString); KF_editDeck(superScrollView.selectedString);
} }
void returnToSelect()
{
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().selectDeck);
}
string preString = ""; string preString = "";
public override void preFrameFunction() public override void preFrameFunction()
...@@ -100,7 +108,7 @@ public class selectDeck : WindowServantSP ...@@ -100,7 +108,7 @@ public class selectDeck : WindowServantSP
); );
} }
else { else {
Program.I().shiftToServant(Program.I().selectDeck); returnToSelect();
} }
}; };
} }
...@@ -115,12 +123,12 @@ public class selectDeck : WindowServantSP ...@@ -115,12 +123,12 @@ public class selectDeck : WindowServantSP
{ {
if (Program.I().deckManager.onSave()) if (Program.I().deckManager.onSave())
{ {
Program.I().shiftToServant(Program.I().selectDeck); returnToSelect();
} }
} }
if (result[0].value == "no") if (result[0].value == "no")
{ {
Program.I().shiftToServant(Program.I().selectDeck); returnToSelect();
} }
} }
if (hashCode == "onNew") if (hashCode == "onNew")
...@@ -508,6 +516,9 @@ public class selectDeck : WindowServantSP ...@@ -508,6 +516,9 @@ public class selectDeck : WindowServantSP
void onClickExit() void onClickExit()
{ {
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu); Program.I().shiftToServant(Program.I().menu);
} }
......
...@@ -70,6 +70,9 @@ public class puzzleMode : WindowServantSP ...@@ -70,6 +70,9 @@ public class puzzleMode : WindowServantSP
void onClickExit() void onClickExit()
{ {
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu); Program.I().shiftToServant(Program.I().menu);
} }
......
...@@ -519,6 +519,9 @@ public class selectReplay : WindowServantSP ...@@ -519,6 +519,9 @@ public class selectReplay : WindowServantSP
void onClickExit() void onClickExit()
{ {
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu); Program.I().shiftToServant(Program.I().menu);
} }
......
...@@ -109,6 +109,9 @@ public class SelectServer : WindowServantSP ...@@ -109,6 +109,9 @@ public class SelectServer : WindowServantSP
void onClickExit() void onClickExit()
{ {
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu); Program.I().shiftToServant(Program.I().menu);
if (TcpHelper.tcpClient != null) if (TcpHelper.tcpClient != null)
{ {
......
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