Commit f940540c authored by Szefo09's avatar Szefo09

Merge branch 'pr/9' into mcUI

parents 756021d8 52f1a4c0
...@@ -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.isMatching ? 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 isMatching = false;
public bool isRequesting;
const string mycard_ip = "tiramisu.mycard.moe";
const string athletic_port = "8911";
const string entertain_port = "7911";
Thread requestThread = null;
MyCardHelper helper;
UIInput inputUsername;
UIInput inputPsw;
public override void initialize()
{
createWindow(Program.I().new_ui_mycard);
UIHelper.registEvent(gameObject, "exit_", onClickExit);
UIHelper.registEvent(gameObject, "joinAthletic", onJoinAthletic);
UIHelper.registEvent(gameObject, "joinEntertain", onJoinEntertain);
UIHelper.registEvent(gameObject, "database", onClickDatabase);
UIHelper.registEvent(gameObject, "community", onClickCommunity);
inputUsername = UIHelper.getByName<UIInput>(gameObject, "nameLine");
inputPsw = UIHelper.getByName<UIInput>(gameObject, "pswLine");
helper = new MyCardHelper();
loadUser();
SetActiveFalse();
}
void saveUser() {
Config.Set("mycard_username", inputUsername.value);
Config.Set("mycard_password", inputPsw.value);
}
void loadUser() {
inputUsername.value = Config.Get("mycard_username", "MyCard");
inputPsw.value = Config.Get("mycard_password", "");
}
public void terminateThread()
{
if (!isRequesting && requestThread = null)
{
return;
}
requestThread.Abort();
requestThread = null;
}
void onClickExit()
{
Program.I().shiftToServant(Program.I().menu);
if (TcpHelper.tcpClient != null)
{
if (isRequesting) {
terminateThread();
}
if (TcpHelper.tcpClient.Connected)
{
TcpHelper.tcpClient.Close();
}
}
}
void onClickDatabase() {
Application.OpenURL("https://ygobbs.com/");
}
void onClickCommunity() {
Application.OpenURL("https://mycard.moe/ygopro/arena");
}
void matchThread(string username, string password, string match_type) {
try {
Program.PrintToChat(InterString.Get("正在登录至MyCard。"));
string fail_reason = "";
bool res = helper.login(username, password, out fail_reason);
if (!res) {
Program.PrintToChat(InterString.Get("MyCard登录失败。原因: ") + fail_reason);
isRequesting = false;
return;
}
Program.PrintToChat(InterString.Get("正在请求匹配。匹配类型: ") + match_type);
string pswString = helper.requestMatch(match_type, out fail_reason);
if (pswString == null) {
Program.PrintToChat(InterString.Get("匹配请求失败。原因: ") + fail_reason);
isRequesting = false;
return;
}
Program.PrintToChat(InterString.Get("匹配成功。正在进入房间。"));
Program.I().mycard.isMatching = true;
(new Thread(() => { TcpHelper.join(mycard_ip, username, match_type == "athletic" ? athletic_port : entertain_port, pswString, "0x" + String.Format("{0:X}", Config.ClientVersion)); })).Start();
isRequesting = false;
} catch (Exception e) {
if (e != ThreadAbortException) {
Program.PrintToChat(InterString.Get("未知错误: ") + e.Message);
} else {
Program.PrintToChat("匹配已中断。");
}
isRequesting = false;
}
}
void startMatch(string match_type) {
const string username = inputUsername.value;
const string password = inputPsw.value;
if (username == "" || password == "")
{
RMSshow_onlyYes("", InterString.Get("用户名或密码为空。"), null);
return;
}
saveUser();
isRequesting = true;
requestThread = new Thread(() =>
{
matchThread(username, password, match_type);
});
}
void onJoinAthletic() {
startMatch("athletic");
}
void onJoinEntertain() {
startMatch("entertain");
}
}
...@@ -755,13 +755,21 @@ public class Ocgcore : ServantWithCardDescription ...@@ -755,13 +755,21 @@ public class Ocgcore : ServantWithCardDescription
} }
} }
public void onExit() public void setDefaultReturnServant() {
if (Program.I().mycard.isMatching) {
returnServant = Program.I().mycard;
} else {
returnServant = Program.I().selectServer;
}
}
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,7 +953,8 @@ public class Program : MonoBehaviour ...@@ -952,7 +953,8 @@ public class Program : MonoBehaviour
public DeckManager deckManager; public DeckManager deckManager;
public Ocgcore ocgcore; public Ocgcore ocgcore;
public SelectServer selectServer; public SelectServer selectServer;
public RoomList roomList; public MyCard mycard;
public RoomList roomList;
public Book book; public Book book;
public puzzleMode puzzleMode; public puzzleMode puzzleMode;
public AIRoom aiRoom; public AIRoom aiRoom;
...@@ -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();
...@@ -1106,7 +1115,7 @@ public class Program : MonoBehaviour ...@@ -1106,7 +1115,7 @@ public class Program : MonoBehaviour
string FPS = m_FPS.ToString(); string FPS = m_FPS.ToString();
try { FPS = FPS.Substring(0, 5); } catch{} try { FPS = FPS.Substring(0, 5); } catch{}
GUI.Label(new Rect(10, 5, 200, 200), "[Ver 1.034.9-A-test9] " + "FPS: " + FPS); GUI.Label(new Rect(10, 5, 200, 200), "[Ver 1.034.9-A-test10] " + "FPS: " + FPS);
} }
void Update() void Update()
......
...@@ -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)
......
...@@ -55,8 +55,6 @@ public class SelectServer : WindowServantSP ...@@ -55,8 +55,6 @@ public class SelectServer : WindowServantSP
serversList.items.Add("[AI]Doom Bots of Doom"); serversList.items.Add("[AI]Doom Bots of Doom");
//serversList.items.Add("[OCG&TCG]한국서버"); //serversList.items.Add("[OCG&TCG]한국서버");
//serversList.items.Add("[OCG&TCG]YGOhollow (JP)"); //serversList.items.Add("[OCG&TCG]YGOhollow (JP)");
serversList.items.Add("[MyCard]Athletic");
serversList.items.Add("[MyCard]Entertain");
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional) if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
{ {
serversList.items.Add("[自定义]"); serversList.items.Add("[自定义]");
...@@ -128,26 +126,6 @@ public class SelectServer : WindowServantSP ...@@ -128,26 +126,6 @@ public class SelectServer : WindowServantSP
UIHelper.getByName<UIInput>(gameObject, "port_").value = "573"; UIHelper.getByName<UIInput>(gameObject, "port_").value = "573";
Config.Set("serversPicker", "[AI]Doom Bots of Doom"); Config.Set("serversPicker", "[AI]Doom Bots of Doom");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[MyCard]Athletic":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "tiramisu.mycard.moe";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "8911";
Config.Set("serversPicker", "[MyCard]Athletic");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[MyCard]Entertain":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "tiramisu.mycard.moe";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7911";
Config.Set("serversPicker", "[MyCard]Entertain");
inputIP_.enabled = false; inputIP_.enabled = false;
inputPort_.enabled = false; inputPort_.enabled = false;
break; break;
...@@ -312,33 +290,6 @@ public class SelectServer : WindowServantSP ...@@ -312,33 +290,6 @@ public class SelectServer : WindowServantSP
UIHelper.getByName<UIInput>(gameObject, "version_").value = str; UIHelper.getByName<UIInput>(gameObject, "version_").value = str;
} }
bool isMyCard() {
string server = serversList.value;
return server == "[MyCard]Athletic" || server == "[MyCard]Entertain";
}
void startMyCard(string name, string password, string match_type = "entertain") {
MyCardHelper mycard = new MyCardHelper();
Program.PrintToChat(InterString.Get("正在登录至MyCard。"));
string fail_reason = "";
bool res = mycard.login(name, password, out fail_reason);
if (!res) {
Program.PrintToChat(InterString.Get("MyCard登录失败。原因: ") + fail_reason);
return;
}
Program.PrintToChat(InterString.Get("正在请求匹配。匹配类型: ") + match_type);
string pswString = mycard.requestMatch(match_type, out fail_reason);
if (pswString == null) {
Program.PrintToChat(InterString.Get("匹配请求失败。原因: ") + fail_reason);
return;
}
string ipString = UIHelper.getByName<UIInput>(gameObject, "ip_").value;
string portString = UIHelper.getByName<UIInput>(gameObject, "port_").value;
string versionString = UIHelper.getByName<UIInput>(gameObject, "version_").value;
Program.PrintToChat(InterString.Get("匹配成功。正在进入房间。"));
KF_onlineGame(name, ipString, portString, versionString, pswString);
}
void onClickJoin() void onClickJoin()
{ {
if (!isShowed) if (!isShowed)
...@@ -350,16 +301,12 @@ public class SelectServer : WindowServantSP ...@@ -350,16 +301,12 @@ public class SelectServer : WindowServantSP
string portString = UIHelper.getByName<UIInput>(gameObject, "port_").value; string portString = UIHelper.getByName<UIInput>(gameObject, "port_").value;
string pswString = UIHelper.getByName<UIInput>(gameObject, "psw_").value; string pswString = UIHelper.getByName<UIInput>(gameObject, "psw_").value;
string versionString = UIHelper.getByName<UIInput>(gameObject, "version_").value; string versionString = UIHelper.getByName<UIInput>(gameObject, "version_").value;
if (isMyCard()) { KF_onlineGame(Name, ipString, portString, versionString, pswString);
startMyCard(Name, pswString, portString == "8911" ? "athletic" : "entertain");
} else {
KF_onlineGame(Name, ipString, portString, versionString, pswString);
}
} }
public void onClickRoomList() public void onClickRoomList()
{ {
if (!isShowed || isMyCard()) if (!isShowed)
{ {
return; return;
} }
...@@ -388,25 +335,24 @@ public class SelectServer : WindowServantSP ...@@ -388,25 +335,24 @@ public class SelectServer : WindowServantSP
{ {
if (name != "") if (name != "")
{ {
if (!isMyCard()) { //string fantasty = "(" + versionString + ")" + ipString + ":" + portString + " " + pswString;
//string fantasty = "(" + versionString + ")" + ipString + ":" + portString + " " + pswString; string fantasty = "psw: " + pswString;
string fantasty = "psw: " + pswString; list.items.Remove(fantasty);
list.items.Remove(fantasty); list.items.Insert(0, fantasty);
list.items.Insert(0, fantasty); list.value = fantasty;
list.value = fantasty; if (list.items.Count > 5)
if (list.items.Count > 5) {
{ list.items.RemoveAt(list.items.Count - 1);
list.items.RemoveAt(list.items.Count - 1); }
} string all = "";
string all = ""; for (int i = 0; i < list.items.Count; i++)
for (int i = 0; i < list.items.Count; i++) {
{ all += list.items[i] + "\r\n";
all += list.items[i] + "\r\n";
}
File.WriteAllText("config/passwords.conf", all);
printFile(false);
} }
(new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); })).Start(); File.WriteAllText("config/passwords.conf", all);
printFile(false);
Program.I().mycard.isMatchingWithMyCard = false;
(new Thread(() => { TcpHelper.join(ipString, name, portString, pswString, versionString); })).Start();
} }
else else
{ {
......
...@@ -157,6 +157,7 @@ MonoBehaviour: ...@@ -157,6 +157,7 @@ MonoBehaviour:
new_ui_setting: {fileID: 0} new_ui_setting: {fileID: 0}
new_ui_book: {fileID: 0} new_ui_book: {fileID: 0}
new_ui_selectServer: {fileID: 0} new_ui_selectServer: {fileID: 0}
new_ui_mycard: {fileID: 0}
new_ui_gameInfo: {fileID: 0} new_ui_gameInfo: {fileID: 0}
new_ui_cardDescription: {fileID: 0} new_ui_cardDescription: {fileID: 0}
new_ui_search: {fileID: 0} new_ui_search: {fileID: 0}
......
...@@ -1417,7 +1417,7 @@ MonoBehaviour: ...@@ -1417,7 +1417,7 @@ MonoBehaviour:
keepCrispWhenShrunk: 1 keepCrispWhenShrunk: 1
mTrueTypeFont: {fileID: 12800000, guid: f775853fdfd14bb47934543e95c3bae3, type: 3} mTrueTypeFont: {fileID: 12800000, guid: f775853fdfd14bb47934543e95c3bae3, type: 3}
mFont: {fileID: 0} mFont: {fileID: 0}
mText: KoishiPro2 iOS 1.034.9-A-test9 mText: KoishiPro2 iOS 1.034.9-A-test10
mFontSize: 18 mFontSize: 18
mFontStyle: 0 mFontStyle: 0
mAlignment: 1 mAlignment: 1
......
...@@ -2546,7 +2546,7 @@ MonoBehaviour: ...@@ -2546,7 +2546,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
......
...@@ -123,7 +123,7 @@ PlayerSettings: ...@@ -123,7 +123,7 @@ PlayerSettings:
16:10: 1 16:10: 1
16:9: 1 16:9: 1
Others: 1 Others: 1
bundleVersion: 1.034.9-A-test9 bundleVersion: 1.034.9-A-test10
preloadedAssets: [] preloadedAssets: []
metroInputSource: 0 metroInputSource: 0
m_HolographicPauseOnTrackingLoss: 1 m_HolographicPauseOnTrackingLoss: 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