Commit 3812e3d9 authored by nanahira's avatar nanahira

unfinished

parent 077a8595
...@@ -17,6 +17,7 @@ public class Menu : WindowServantSP ...@@ -17,6 +17,7 @@ public class Menu : WindowServantSP
UIHelper.registEvent(gameObject, "setting_", onClickSetting); UIHelper.registEvent(gameObject, "setting_", onClickSetting);
UIHelper.registEvent(gameObject, "deck_", onClickSelectDeck); UIHelper.registEvent(gameObject, "deck_", onClickSelectDeck);
UIHelper.registEvent(gameObject, "online_", onClickOnline); UIHelper.registEvent(gameObject, "online_", onClickOnline);
UIHelper.registEvent(gameObject, "myCard_", onClickMyCard);
UIHelper.registEvent(gameObject, "replay_", onClickReplay); UIHelper.registEvent(gameObject, "replay_", onClickReplay);
UIHelper.registEvent(gameObject, "single_", onClickPizzle); UIHelper.registEvent(gameObject, "single_", onClickPizzle);
//UIHelper.registEvent(gameObject, "ai_", onClickAI); //UIHelper.registEvent(gameObject, "ai_", onClickAI);
...@@ -107,6 +108,11 @@ public class Menu : WindowServantSP ...@@ -107,6 +108,11 @@ public class Menu : WindowServantSP
Program.I().shiftToServant(Program.I().selectServer); Program.I().shiftToServant(Program.I().selectServer);
} }
void onClickMyCard()
{
Program.I().shiftToServant(Program.I().mycard);
}
void onClickAI() void onClickAI()
{ {
Program.I().shiftToServant(Program.I().aiRoom); Program.I().shiftToServant(Program.I().aiRoom);
...@@ -199,6 +205,10 @@ public class Menu : WindowServantSP ...@@ -199,6 +205,10 @@ public class Menu : WindowServantSP
{ {
return; return;
} }
if (Program.I().mycard == null)
{
return;
}
try try
{ {
if (File.Exists("commamd.shell") == false) if (File.Exists("commamd.shell") == false)
......
...@@ -191,7 +191,7 @@ public static class TcpHelper ...@@ -191,7 +191,7 @@ public static class TcpHelper
if (onDisConnected == true) if (onDisConnected == true)
{ {
onDisConnected = false; onDisConnected = false;
Program.I().ocgcore.returnServant = Program.I().selectServer; Program.I().ocgcore.setDefaultReturnServant();
if (TcpHelper.tcpClient != null) if (TcpHelper.tcpClient != null)
{ {
if (TcpHelper.tcpClient.Connected) if (TcpHelper.tcpClient.Connected)
...@@ -206,7 +206,7 @@ public static class TcpHelper ...@@ -206,7 +206,7 @@ public static class TcpHelper
{ {
if (Program.I().menu.isShowed == false) if (Program.I().menu.isShowed == false)
{ {
Program.I().shiftToServant(Program.I().selectServer); Program.I().shiftToServant(Program.I().mycard.isMatchingWithMyCard ? Program.I().mycard : Program.I().selectServer);
} }
if (!roomListChecking) if (!roomListChecking)
{ {
......
using UnityEngine;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
public class MyCard : WindowServantSP
{
public bool isMatchingWithMyCard = false;
UIPopupList list;
UIPopupList serversList;
UIInput inputIP;
UIInput inputPort;
UIInput inputPsw;
UIInput inputVersion;
UISprite inputIP_;
UISprite inputPort_;
public override void initialize()
{
createWindow(Program.I().new_ui_selectServer);
UIHelper.registEvent(gameObject, "exit_", onClickExit);
UIHelper.registEvent(gameObject, "face_", onClickFace);
UIHelper.registEvent(gameObject, "join_", onClickJoin);
UIHelper.registEvent(gameObject, "clearPsw_", onClearPsw);
serversList = UIHelper.getByName<UIPopupList>(gameObject, "server");
//serversList.fontSize = 30;
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
{
serversList.value = Config.Get("serversPicker", "[自定义]");
} else {
serversList.value = Config.Get("serversPicker", "[Custom]");
}
UIHelper.registEvent(gameObject, "server", pickServer);
UIHelper.getByName<UIInput>(gameObject, "name_").value = Config.Get("name", "YGOPro2 User");
list = UIHelper.getByName<UIPopupList>(gameObject, "history_");
list.enabled = true;
UIHelper.registEvent(gameObject, "history_", onSelected);
name = Config.Get("name", "YGOPro2 User");
inputIP = UIHelper.getByName<UIInput>(gameObject, "ip_");
inputPort = UIHelper.getByName<UIInput>(gameObject, "port_");
inputPsw = UIHelper.getByName<UIInput>(gameObject, "psw_");
inputIP_ = UIHelper.getByName<UISprite>(gameObject, "ip_");
inputPort_ = UIHelper.getByName<UISprite>(gameObject, "port_");
//inputVersion = UIHelper.getByName<UIInput>(gameObject, "version_");
set_version("0x" + String.Format("{0:X}", Config.ClientVersion));
//方便免修改 [selectServerWithRoomlist.prefab]
serversList.items.Add("[OCG]Koishi");
serversList.items.Add("[OCG]Mercury233");
serversList.items.Add("[TCG]Koishi");
serversList.items.Add("[轮抽服]2Pick");
//serversList.items.Add("[DIY]YGOPro 222DIY");
serversList.items.Add("[AI]Doom Bots of Doom");
//serversList.items.Add("[OCG&TCG]한국서버");
//serversList.items.Add("[OCG&TCG]YGOhollow (JP)");
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
{
serversList.items.Add("[自定义]");
} else {
serversList.items.Add("[Custom]");
}
SetActiveFalse();
}
private void pickServer()
{
string server = serversList.value;
switch (server)
{
case "[OCG]Koishi":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.moecube.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7210";
Config.Set("serversPicker", "[OCG]Koishi");
inputIP_.enabled = true;
inputPort_.enabled = false;
break;
}
case "[OCG]Mercury233":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "s1.ygo233.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "233";
Config.Set("serversPicker", "[OCG]Mercury233");
inputIP_.enabled = true;
inputPort_.enabled = false;
break;
}
case "[TCG]Koishi":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.moecube.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "1311";
Config.Set("serversPicker", "[TCG]Koishi");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[轮抽服]2Pick":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "2pick.mycard.moe";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "765";
Config.Set("serversPicker", "[轮抽服]2Pick");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
/*case "[DIY]YGOPro 222DIY":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.moecube.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "222";
Config.Set("serversPicker", "[DIY]YGOPro 222DIY");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
} */
case "[AI]Doom Bots of Doom":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.moecube.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "573";
Config.Set("serversPicker", "[AI]Doom Bots of Doom");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
/*case "[OCG&TCG]한국서버":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "cygopro.fun25.co.kr";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "17225";
Config.Set("serversPicker", "[OCG&TCG]한국서버 (KR)");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[OCG&TCG]YGOhollow (JP)":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "ygosvrjp.tk";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7911";
Config.Set("serversPicker", "[OCG&TCG]YGOhollow (JP)");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
} */
default:
{
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
{
Config.Set("serversPicker", "[自定义]");
} else {
Config.Set("serversPicker", "[Custom]");
}
inputIP_.enabled = true;
inputPort_.enabled = true;
break;
}
}
}
void onSelected()
{
if (list != null)
{
readString(list.value);
}
}
private void readString(string str)
{
/*
str = str.Substring(1, str.Length - 1);
string version = "", remain = "";
string[] splited;
splited = str.Split(")");
try
{
version = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(":");
string ip = "";
try
{
ip = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(" ");
string psw = "", port = "";
try
{
port = splited[0];
psw = splited[1];
}
catch (Exception)
{
}
if (EditIpAndPort)
{
inputIP.value = ip;
inputPort.value = port;
}
inputPsw.value = psw;
*/
//确保密码为空时,退出后密码依旧保持为空
str = str.Substring(5, str.Length - 5);
inputPsw.value = str;
//inputVersion.value = version;
}
void onClearPsw()
{
string PswString = File.ReadAllText("config/passwords.conf");
string[] lines = PswString.Replace("\r", "").Split("\n");
for (int i = 0; i < lines.Length; i++)
{
list.RemoveItem(lines[i]);//清空list
}
FileStream stream = new FileStream("config/passwords.conf", FileMode.Truncate, FileAccess.ReadWrite);//清空文件内容
stream.Close();
inputPsw.value = "";
Program.PrintToChat(InterString.Get("房间密码已清空"));
}
public override void show()
{
base.show();
Program.I().room.RMSshow_clear();
printFile(true);
Program.charge();
}
public override void preFrameFunction()
{
base.preFrameFunction();
Menu.checkCommend();
}
void printFile(bool first)
{
list.Clear();
if (File.Exists("config/passwords.conf") == false)
{
File.Create("config/passwords.conf").Close();
}
string txtString = File.ReadAllText("config/passwords.conf");
string[] lines = txtString.Replace("\r", "").Split("\n");
for (int i = 0; i < lines.Length; i++)
{
if (i == 0)
{
if (first)
{
readString(lines[i]);
}
}
list.AddItem(lines[i]);
}
}
void onClickExit()
{
Program.I().shiftToServant(Program.I().menu);
if (TcpHelper.tcpClient != null)
{
if (TcpHelper.tcpClient.Connected)
{
TcpHelper.tcpClient.Close();
}
}
}
public void set_version(string str)
{
UIHelper.getByName<UIInput>(gameObject, "version_").value = str;
}
void onClickJoin()
{
if (!isShowed)
{
return;
}
string Name = UIHelper.getByName<UIInput>(gameObject, "name_").value;
string ipString = UIHelper.getByName<UIInput>(gameObject, "ip_").value;
string portString = UIHelper.getByName<UIInput>(gameObject, "port_").value;
string pswString = UIHelper.getByName<UIInput>(gameObject, "psw_").value;
string versionString = UIHelper.getByName<UIInput>(gameObject, "version_").value;
KF_onlineGame(Name, ipString, portString, versionString, pswString);
}
public void onClickRoomList()
{
if (!isShowed)
{
return;
}
string Name = UIHelper.getByName<UIInput>(gameObject, "name_").value;
string ipString = UIHelper.getByName<UIInput>(gameObject, "ip_").value;
string portString = UIHelper.getByName<UIInput>(gameObject, "port_").value;
string pswString = "L";
string versionString = UIHelper.getByName<UIInput>(gameObject, "version_").value;
KF_onlineGame(Name, ipString, portString, versionString, pswString);
}
public void onHide(bool Bool)
{
gameObject.SetActive(!Bool);
}
public void KF_onlineGame(string Name, string ipString, string portString, string versionString, string pswString = "")
{
name = Name;
Config.Set("name", name);
if (ipString == "" || portString == "" || versionString == "")
{
RMSshow_onlyYes("", InterString.Get("非法输入!请检查输入的主机名。"), null);
}
else
{
if (name != "")
{
//string fantasty = "(" + versionString + ")" + ipString + ":" + portString + " " + pswString;
string fantasty = "psw: " + pswString;
list.items.Remove(fantasty);
list.items.Insert(0, fantasty);
list.value = fantasty;
if (list.items.Count > 5)
{
list.items.RemoveAt(list.items.Count - 1);
}
string all = "";
for (int i = 0; i < list.items.Count; i++)
{
all += list.items[i] + "\r\n";
}
File.WriteAllText("config/passwords.conf", all);
printFile(false);
(new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); })).Start();
}
else
{
RMSshow_onlyYes("", InterString.Get("昵称不能为空。"), null);
}
}
}
GameObject faceShow = null;
public string name = "";
void onClickFace()
{
name = UIHelper.getByName<UIInput>(gameObject, "name_").value;
RMSshow_face("showFace", name);
Config.Set("name", name);
}
}
...@@ -755,13 +755,21 @@ public class Ocgcore : ServantWithCardDescription ...@@ -755,13 +755,21 @@ public class Ocgcore : ServantWithCardDescription
} }
} }
public void setDefaultReturnServant() {
if (Program.I().mycard.isMatchingWithMyCard) {
returnServant = Program.I().mycard;
} else {
returnServant = Program.I().selectServer;
}
}
public void onExit() public void onExit()
{ {
if (TcpHelper.tcpClient != null) if (TcpHelper.tcpClient != null)
{ {
if (TcpHelper.tcpClient.Connected) if (TcpHelper.tcpClient.Connected)
{ {
Program.I().ocgcore.returnServant = Program.I().selectServer; setDefaultReturnServant();
TcpHelper.tcpClient.Client.Shutdown(0); TcpHelper.tcpClient.Client.Shutdown(0);
TcpHelper.tcpClient.Close(); TcpHelper.tcpClient.Close();
} }
...@@ -776,7 +784,7 @@ public class Ocgcore : ServantWithCardDescription ...@@ -776,7 +784,7 @@ public class Ocgcore : ServantWithCardDescription
{ {
/*if (TcpHelper.tcpClient.Connected) /*if (TcpHelper.tcpClient.Connected)
{ {
Program.I().ocgcore.returnServant = Program.I().selectServer; setDefaultReturnServant();
TcpHelper.tcpClient.Client.Shutdown(0); TcpHelper.tcpClient.Client.Shutdown(0);
TcpHelper.tcpClient.Close(); TcpHelper.tcpClient.Close();
} */ } */
......
...@@ -88,6 +88,7 @@ public class Program : MonoBehaviour ...@@ -88,6 +88,7 @@ public class Program : MonoBehaviour
public GameObject new_ui_setting; public GameObject new_ui_setting;
public GameObject new_ui_book; public GameObject new_ui_book;
public GameObject new_ui_selectServer; public GameObject new_ui_selectServer;
public GameObject new_ui_mycard;
public GameObject new_ui_RoomList; public GameObject new_ui_RoomList;
public GameObject new_ui_gameInfo; public GameObject new_ui_gameInfo;
public GameObject new_ui_cardDescription; public GameObject new_ui_cardDescription;
...@@ -952,6 +953,7 @@ public class Program : MonoBehaviour ...@@ -952,6 +953,7 @@ public class Program : MonoBehaviour
public DeckManager deckManager; public DeckManager deckManager;
public Ocgcore ocgcore; public Ocgcore ocgcore;
public SelectServer selectServer; public SelectServer selectServer;
public MyCard mycard;
public RoomList roomList; public RoomList roomList;
public Book book; public Book book;
public puzzleMode puzzleMode; public puzzleMode puzzleMode;
...@@ -974,6 +976,8 @@ public class Program : MonoBehaviour ...@@ -974,6 +976,8 @@ public class Program : MonoBehaviour
servants.Add(ocgcore); servants.Add(ocgcore);
selectServer = new SelectServer(); selectServer = new SelectServer();
servants.Add(selectServer); servants.Add(selectServer);
mycard = new MyCard();
servants.Add(mycard);
roomList = new RoomList(); roomList = new RoomList();
servants.Add(roomList); servants.Add(roomList);
book = new Book(); book = new Book();
...@@ -1020,6 +1024,10 @@ public class Program : MonoBehaviour ...@@ -1020,6 +1024,10 @@ public class Program : MonoBehaviour
{ {
selectServer.hide(); selectServer.hide();
} }
if (to != mycard && mycard.isShowed)
{
mycard.hide();
}
if (to != selectReplay && selectReplay.isShowed) if (to != selectReplay && selectReplay.isShowed)
{ {
selectReplay.hide(); selectReplay.hide();
...@@ -1045,6 +1053,7 @@ public class Program : MonoBehaviour ...@@ -1045,6 +1053,7 @@ public class Program : MonoBehaviour
if (to == deckManager && deckManager.isShowed == false) deckManager.show(); if (to == deckManager && deckManager.isShowed == false) deckManager.show();
if (to == ocgcore && ocgcore.isShowed == false) ocgcore.show(); if (to == ocgcore && ocgcore.isShowed == false) ocgcore.show();
if (to == selectServer && selectServer.isShowed == false) selectServer.show(); if (to == selectServer && selectServer.isShowed == false) selectServer.show();
if (to == mycard && mycard.isShowed == false) mycard.show();
if (to == selectReplay && selectReplay.isShowed == false) selectReplay.show(); if (to == selectReplay && selectReplay.isShowed == false) selectReplay.show();
if (to == puzzleMode && puzzleMode.isShowed == false) puzzleMode.show(); if (to == puzzleMode && puzzleMode.isShowed == false) puzzleMode.show();
if (to == aiRoom && aiRoom.isShowed == false) aiRoom.show(); if (to == aiRoom && aiRoom.isShowed == false) aiRoom.show();
......
...@@ -87,7 +87,7 @@ public class Room : WindowServantSP ...@@ -87,7 +87,7 @@ public class Room : WindowServantSP
Menu.deleteShell(); Menu.deleteShell();
} }
base.show(); base.show();
Program.I().ocgcore.returnServant = Program.I().selectServer; Program.I().ocgcore.setDefaultReturnServant();
Program.I().ocgcore.handler = handler; Program.I().ocgcore.handler = handler;
UIHelper.registEvent(toolBar, "input_", onChat); UIHelper.registEvent(toolBar, "input_", onChat);
Program.charge(); Program.charge();
...@@ -495,7 +495,7 @@ public class Room : WindowServantSP ...@@ -495,7 +495,7 @@ public class Room : WindowServantSP
public void StocMessage_DuelStart(BinaryReader r) public void StocMessage_DuelStart(BinaryReader r)
{ {
Program.I().ocgcore.returnServant = Program.I().selectServer; Program.I().ocgcore.setDefaultReturnServant();
needSide = false; needSide = false;
joinWithReconnect = true; joinWithReconnect = true;
if (Program.I().deckManager.isShowed) if (Program.I().deckManager.isShowed)
......
...@@ -351,6 +351,7 @@ public class SelectServer : WindowServantSP ...@@ -351,6 +351,7 @@ public class SelectServer : WindowServantSP
} }
File.WriteAllText("config/passwords.conf", all); File.WriteAllText("config/passwords.conf", all);
printFile(false); printFile(false);
Program.I().mycard.isMatchingWithMyCard = false;
(new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); })).Start(); (new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); })).Start();
} }
else else
......
...@@ -1937,7 +1937,7 @@ MonoBehaviour: ...@@ -1937,7 +1937,7 @@ MonoBehaviour:
keepCrispWhenShrunk: 1 keepCrispWhenShrunk: 1
mTrueTypeFont: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} mTrueTypeFont: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
mFont: {fileID: 0} mFont: {fileID: 0}
mText: MyCard Login mText: MyCard
mFontSize: 18 mFontSize: 18
mFontStyle: 0 mFontStyle: 0
mAlignment: 1 mAlignment: 1
......
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