Commit 75569ced authored by mercury233's avatar mercury233

support command lines

parent 0db689f2
......@@ -105,7 +105,7 @@ public class Menu : WindowServantSP
}
}
void onClickExit()
public void onClickExit()
{
Program.I().quit();
Program.Running = false;
......@@ -194,8 +194,20 @@ public class Menu : WindowServantSP
string all = "";
try
{
all = File.ReadAllText("commamd.shell",Encoding.UTF8);
string[] mats = all.Split(" ");
all = File.ReadAllText("commamd.shell", Encoding.UTF8);
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)
{
switch (mats[0])
......
......@@ -758,7 +758,11 @@ public class Ocgcore : ServantWithCardDescription
public void returnTo()
{
TcpHelper.SaveRecord();
if (returnServant != null)
if (Program.exitOnReturn)
{
Program.I().menu.onClickExit();
}
else if (returnServant != null)
{
Program.I().shiftToServant(returnServant);
}
......
......@@ -412,11 +412,91 @@ public class Program : MonoBehaviour
initializeALLservants();
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;
static int lastChargeTime = 0;
......@@ -1040,6 +1120,8 @@ public class Program : MonoBehaviour
public static bool noAccess = false;
public static bool exitOnReturn = false;
void OnApplicationQuit()
{
TcpHelper.SaveRecord();
......
......@@ -26,7 +26,7 @@ public class AIRoom : WindowServantSP
UIHelper.registEvent(gameObject, "aideck_", onSave);
UIHelper.registEvent(gameObject, "rank_", onSave);
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("人机模式"));
superScrollView.install();
SetActiveFalse();
......@@ -43,6 +43,14 @@ public class AIRoom : WindowServantSP
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()
{
if (!isShowed)
......
......@@ -62,6 +62,14 @@ public class selectDeck : WindowServantSP
KF_editDeck(superScrollView.selectedString);
}
void returnToSelect()
{
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().selectDeck);
}
string preString = "";
public override void preFrameFunction()
......@@ -100,7 +108,7 @@ public class selectDeck : WindowServantSP
);
}
else {
Program.I().shiftToServant(Program.I().selectDeck);
returnToSelect();
}
};
}
......@@ -115,12 +123,12 @@ public class selectDeck : WindowServantSP
{
if (Program.I().deckManager.onSave())
{
Program.I().shiftToServant(Program.I().selectDeck);
returnToSelect();
}
}
if (result[0].value == "no")
{
Program.I().shiftToServant(Program.I().selectDeck);
returnToSelect();
}
}
if (hashCode == "onNew")
......@@ -508,7 +516,10 @@ public class selectDeck : WindowServantSP
void onClickExit()
{
Program.I().shiftToServant(Program.I().menu);
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu);
}
}
......@@ -70,7 +70,10 @@ public class puzzleMode : WindowServantSP
void onClickExit()
{
Program.I().shiftToServant(Program.I().menu);
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu);
}
PrecyOcg precy;
......
......@@ -519,7 +519,10 @@ public class selectReplay : WindowServantSP
void onClickExit()
{
Program.I().shiftToServant(Program.I().menu);
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu);
}
}
......@@ -109,7 +109,10 @@ public class SelectServer : WindowServantSP
void onClickExit()
{
Program.I().shiftToServant(Program.I().menu);
if (Program.exitOnReturn)
Program.I().menu.onClickExit();
else
Program.I().shiftToServant(Program.I().menu);
if (TcpHelper.tcpClient != null)
{
if (TcpHelper.tcpClient.Connected)
......
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