Commit a5d9d45d authored by nanahira's avatar nanahira

Merge branch 'master' of git.mycard.moe:mycard/YGOProUnity_V2

parents fb8e29ab f35f6b22
Pipeline #6019 passed with stages
in 54 minutes and 35 seconds
...@@ -117,10 +117,10 @@ public class Menu : WindowServantSP ...@@ -117,10 +117,10 @@ public class Menu : WindowServantSP
Program.I().shiftToServant(Program.I().selectServer); Program.I().shiftToServant(Program.I().selectServer);
} }
private void onClickAI() // private void onClickAI()
{ // {
Program.I().shiftToServant(Program.I().aiRoom); // Program.I().shiftToServant(Program.I().aiRoom);
} // }
private void onClickPizzle() private void onClickPizzle()
{ {
......
...@@ -830,6 +830,29 @@ public static class UIHelper ...@@ -830,6 +830,29 @@ public static class UIHelper
screenposition.z + l)); screenposition.z + l));
} }
public const string sort = "sortByTimeDeck";
public static IOrderedEnumerable<FileInfo> SortDeck(this IOrderedEnumerable<FileInfo> source)
{
return Config.Get(sort, "1") == "1"
? source.ThenByDescending(f => f.LastWriteTime)
: source.ThenBy(f => f.Name);
}
public static IEnumerable<string> GetDecks(string search = "")
{
var deckInUse = Config.Get("deckInUse", "miaowu");
var deckInUsePath = Path.GetFullPath($"deck/{deckInUse}.ydk");
return new DirectoryInfo("deck").EnumerateFiles("*.ydk", SearchOption.AllDirectories)
.Where(f => search == "" || f.Name.Contains(search))
.OrderByDescending(f => f.FullName == deckInUsePath)
.ThenBy(f => f.DirectoryName)
.SortDeck()
.Select(f =>
f.DirectoryName == Path.GetFullPath("deck")
? Path.GetFileNameWithoutExtension(f.Name)
: $"{Path.GetFileName(f.DirectoryName)}/{Path.GetFileNameWithoutExtension(f.Name)}");
}
public static int CompareTime(object x, object y) public static int CompareTime(object x, object y)
{ {
......
...@@ -794,7 +794,7 @@ public class Ocgcore : ServantWithCardDescription ...@@ -794,7 +794,7 @@ public class Ocgcore : ServantWithCardDescription
public void returnTo() public void returnTo()
{ {
TcpHelper.SaveRecord(); TcpHelper.SaveRecord();
if (Program.exitOnReturn) if (Program.exitOnReturn && returnServant != Program.I().deckManager)
Program.I().menu.onClickExit(); Program.I().menu.onClickExit();
else if (returnServant != null) Program.I().shiftToServant(returnServant); else if (returnServant != null) Program.I().shiftToServant(returnServant);
} }
......
...@@ -715,7 +715,7 @@ public class Program : MonoBehaviour ...@@ -715,7 +715,7 @@ public class Program : MonoBehaviour
public SelectServer selectServer; public SelectServer selectServer;
public Book book; public Book book;
public puzzleMode puzzleMode; public puzzleMode puzzleMode;
public AIRoom aiRoom; // public AIRoom aiRoom;
private void initializeALLservants() private void initializeALLservants()
{ {
...@@ -740,8 +740,8 @@ public class Program : MonoBehaviour ...@@ -740,8 +740,8 @@ public class Program : MonoBehaviour
servants.Add(selectReplay); servants.Add(selectReplay);
puzzleMode = new puzzleMode(); puzzleMode = new puzzleMode();
servants.Add(puzzleMode); servants.Add(puzzleMode);
aiRoom = new AIRoom(); // aiRoom = new AIRoom();
servants.Add(aiRoom); // servants.Add(aiRoom);
} }
public void shiftToServant(Servant to) public void shiftToServant(Servant to)
...@@ -756,7 +756,7 @@ public class Program : MonoBehaviour ...@@ -756,7 +756,7 @@ public class Program : MonoBehaviour
if (to != selectServer && selectServer.isShowed) selectServer.hide(); if (to != selectServer && selectServer.isShowed) selectServer.hide();
if (to != selectReplay && selectReplay.isShowed) selectReplay.hide(); if (to != selectReplay && selectReplay.isShowed) selectReplay.hide();
if (to != puzzleMode && puzzleMode.isShowed) puzzleMode.hide(); if (to != puzzleMode && puzzleMode.isShowed) puzzleMode.hide();
if (to != aiRoom && aiRoom.isShowed) aiRoom.hide(); // if (to != aiRoom && aiRoom.isShowed) aiRoom.hide();
if (to == backGroundPic && backGroundPic.isShowed == false) backGroundPic.show(); if (to == backGroundPic && backGroundPic.isShowed == false) backGroundPic.show();
if (to == menu && menu.isShowed == false) menu.show(); if (to == menu && menu.isShowed == false) menu.show();
...@@ -768,7 +768,7 @@ public class Program : MonoBehaviour ...@@ -768,7 +768,7 @@ public class Program : MonoBehaviour
if (to == selectServer && selectServer.isShowed == false) selectServer.show(); if (to == selectServer && selectServer.isShowed == false) selectServer.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();
} }
#endregion #endregion
......
This diff is collapsed.
...@@ -9,7 +9,6 @@ using Object = UnityEngine.Object; ...@@ -9,7 +9,6 @@ using Object = UnityEngine.Object;
public class Room : WindowServantSP public class Room : WindowServantSP
{ {
private readonly string sort = "sortByTimeDeck";
private UIselectableList superScrollView; private UIselectableList superScrollView;
public override void initialize() public override void initialize()
...@@ -32,23 +31,8 @@ public class Room : WindowServantSP ...@@ -32,23 +31,8 @@ public class Room : WindowServantSP
private void printFile() private void printFile()
{ {
var deckInUse = Config.Get("deckInUse", "wizard");
superScrollView.clear(); superScrollView.clear();
var fileInfos = new DirectoryInfo("deck").GetFiles(); foreach (var deck in UIHelper.GetDecks()) superScrollView.add(deck);
if (Config.Get(sort, "1") == "1")
Array.Sort(fileInfos, UIHelper.CompareTime);
else
Array.Sort(fileInfos, UIHelper.CompareName);
for (var i = 0; i < fileInfos.Length; i++)
if (fileInfos[i].Name.Length > 4)
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".ydk")
if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) == deckInUse)
superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4));
for (var i = 0; i < fileInfos.Length; i++)
if (fileInfos[i].Name.Length > 4)
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".ydk")
if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) != deckInUse)
superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4));
} }
public override void show() public override void show()
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using UnityEngine; using UnityEngine;
using YGOSharp; using YGOSharp;
...@@ -11,7 +12,6 @@ public class selectDeck : WindowServantSP ...@@ -11,7 +12,6 @@ public class selectDeck : WindowServantSP
{ {
private readonly cardPicLoader[] quickCards = new cardPicLoader[200]; private readonly cardPicLoader[] quickCards = new cardPicLoader[200];
private readonly string sort = "sortByTimeDeck";
private UIDeckPanel deckPanel; private UIDeckPanel deckPanel;
...@@ -121,7 +121,9 @@ public class selectDeck : WindowServantSP ...@@ -121,7 +121,9 @@ public class selectDeck : WindowServantSP
if (hashCode == "onNew") if (hashCode == "onNew")
try try
{ {
File.Create("deck/" + result[0].value + ".ydk").Close(); var path = $"deck/{result[0].value}.ydk";
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
File.Create(path).Close();
RMSshow_none(InterString.Get("「[?]」创建完毕。", result[0].value)); RMSshow_none(InterString.Get("「[?]」创建完毕。", result[0].value));
superScrollView.selectedString = result[0].value; superScrollView.selectedString = result[0].value;
printFile(); printFile();
...@@ -147,7 +149,9 @@ public class selectDeck : WindowServantSP ...@@ -147,7 +149,9 @@ public class selectDeck : WindowServantSP
if (hashCode == "onCopy") if (hashCode == "onCopy")
try try
{ {
File.Copy("deck/" + superScrollView.selectedString + ".ydk", "deck/" + result[0].value + ".ydk"); var path = $"deck/{result[0].value}.ydk";
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
File.Copy("deck/" + superScrollView.selectedString + ".ydk", path);
RMSshow_none(InterString.Get("「[?]」复制完毕。", superScrollView.selectedString)); RMSshow_none(InterString.Get("「[?]」复制完毕。", superScrollView.selectedString));
superScrollView.selectedString = result[0].value; superScrollView.selectedString = result[0].value;
printFile(); printFile();
...@@ -160,7 +164,9 @@ public class selectDeck : WindowServantSP ...@@ -160,7 +164,9 @@ public class selectDeck : WindowServantSP
if (hashCode == "onRename") if (hashCode == "onRename")
try try
{ {
File.Move("deck/" + superScrollView.selectedString + ".ydk", "deck/" + result[0].value + ".ydk"); var path = $"deck/{result[0].value}.ydk";
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
File.Move("deck/" + superScrollView.selectedString + ".ydk", path);
RMSshow_none(InterString.Get("「[?]」重命名完毕。", superScrollView.selectedString)); RMSshow_none(InterString.Get("「[?]」重命名完毕。", superScrollView.selectedString));
superScrollView.selectedString = result[0].value; superScrollView.selectedString = result[0].value;
printFile(); printFile();
...@@ -233,7 +239,7 @@ public class selectDeck : WindowServantSP ...@@ -233,7 +239,7 @@ public class selectDeck : WindowServantSP
private void setSortLable() private void setSortLable()
{ {
if (Config.Get(sort, "1") == "1") if (Config.Get(UIHelper.sort, "1") == "1")
UIHelper.trySetLableText(gameObject, "sort_", InterString.Get("时间排序")); UIHelper.trySetLableText(gameObject, "sort_", InterString.Get("时间排序"));
else else
UIHelper.trySetLableText(gameObject, "sort_", InterString.Get("名称排序")); UIHelper.trySetLableText(gameObject, "sort_", InterString.Get("名称排序"));
...@@ -241,10 +247,10 @@ public class selectDeck : WindowServantSP ...@@ -241,10 +247,10 @@ public class selectDeck : WindowServantSP
private void onSort() private void onSort()
{ {
if (Config.Get(sort, "1") == "1") if (Config.Get(UIHelper.sort, "1") == "1")
Config.Set(sort, "0"); Config.Set(UIHelper.sort, "0");
else else
Config.Set(sort, "1"); Config.Set(UIHelper.sort, "1");
setSortLable(); setSortLable();
printFile(); printFile();
} }
...@@ -377,29 +383,9 @@ public class selectDeck : WindowServantSP ...@@ -377,29 +383,9 @@ public class selectDeck : WindowServantSP
private void printFile() private void printFile()
{ {
var deckInUse = Config.Get("deckInUse", "miaowu");
superScrollView.clear(); superScrollView.clear();
var fileInfos = new DirectoryInfo("deck").GetFiles(); foreach (var deck in UIHelper.GetDecks(searchInput.value))
if (Config.Get(sort, "1") == "1") superScrollView.add(deck);
Array.Sort(fileInfos, UIHelper.CompareTime);
else
Array.Sort(fileInfos, UIHelper.CompareName);
for (var i = 0; i < fileInfos.Length; i++)
if (fileInfos[i].Name.Length > 4)
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".ydk")
if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) == deckInUse)
if (searchInput.value == "" ||
Regex.Replace(fileInfos[i].Name, searchInput.value, "miaowu", RegexOptions.IgnoreCase) !=
fileInfos[i].Name)
superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4));
for (var i = 0; i < fileInfos.Length; i++)
if (fileInfos[i].Name.Length > 4)
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".ydk")
if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) != deckInUse)
if (searchInput.value == "" ||
Regex.Replace(fileInfos[i].Name, searchInput.value, "miaowu", RegexOptions.IgnoreCase) !=
fileInfos[i].Name)
superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4));
if (superScrollView.Selected() == false) superScrollView.selectTop(); if (superScrollView.Selected() == false) superScrollView.selectTop();
} }
......
...@@ -117,14 +117,6 @@ public class DeckManager : ServantWithCardDescription ...@@ -117,14 +117,6 @@ public class DeckManager : ServantWithCardDescription
} }
camrem(); camrem();
if (Input.mousePosition.x < Screen.width - 280)
if (Input.mousePosition.x > 250)
{
cameraAngle += Program.wheelValue * 1.2f;
if (cameraAngle < 0f) cameraAngle = 0f;
if (cameraAngle > 90f) cameraAngle = 90f;
}
cameraDistance = 29 - 3.1415926f / 180f * (cameraAngle - 60f) * 13f; cameraDistance = 29 - 3.1415926f / 180f * (cameraAngle - 60f) * 13f;
Program.cameraPosition = new Vector3(0, cameraDistance * Mathf.Sin(3.1415926f / 180f * cameraAngle), Program.cameraPosition = new Vector3(0, cameraDistance * Mathf.Sin(3.1415926f / 180f * cameraAngle),
-cameraDistance * Mathf.Cos(3.1415926f / 180f * cameraAngle)); -cameraDistance * Mathf.Cos(3.1415926f / 180f * cameraAngle));
...@@ -223,17 +215,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -223,17 +215,9 @@ public class DeckManager : ServantWithCardDescription
{ {
if (cardInDragging != null) if (cardInDragging != null)
{ {
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) if (cardInDragging.getIfAlive()) deckDirty = true;
{ ArrangeObjectDeck(true);
// ShowObjectDeck();
}
else
{
if (cardInDragging.getIfAlive())
deckDirty = true;
ArrangeObjectDeck(true);
ShowObjectDeck();
}
cardInDragging.endDrag(); cardInDragging.endDrag();
cardInDragging = null; cardInDragging = null;
......
...@@ -62,28 +62,28 @@ public class PrecyOcg ...@@ -62,28 +62,28 @@ public class PrecyOcg
} }
} }
public void startAI(string playerDek, string aiDeck, string aiScript, bool playerGo, bool unrand, int life, // public void startAI(string playerDek, string aiDeck, string aiScript, bool playerGo, bool unrand, int life,
bool god, int rule) // bool god, int rule)
{ // {
if (Program.I().ocgcore.isShowed == false) // if (Program.I().ocgcore.isShowed == false)
{ // {
Program.I().room.mode = 0; // Program.I().room.mode = 0;
Program.I().ocgcore.MasterRule = rule; // Program.I().ocgcore.MasterRule = rule;
godMode = god; // godMode = god;
prepareOcgcore(); // prepareOcgcore();
Program.I().ocgcore.lpLimit = life; // Program.I().ocgcore.lpLimit = life;
Program.I().ocgcore.isFirst = playerGo; // Program.I().ocgcore.isFirst = playerGo;
Program.I().ocgcore.returnServant = Program.I().aiRoom; // Program.I().ocgcore.returnServant = Program.I().aiRoom;
if (!ygopro.startAI(playerDek, aiDeck, aiScript, playerGo, unrand, life, god, rule)) // if (!ygopro.startAI(playerDek, aiDeck, aiScript, playerGo, unrand, life, god, rule))
{ // {
Program.I().cardDescription.RMSshow_none(InterString.Get("游戏内部出错,请重试。")); // Program.I().cardDescription.RMSshow_none(InterString.Get("游戏内部出错,请重试。"));
return; // return;
} // }
//
//Config.ClientVersion = 0x233c; // //Config.ClientVersion = 0x233c;
Program.I().shiftToServant(Program.I().ocgcore); // Program.I().shiftToServant(Program.I().ocgcore);
} // }
} // }
private void prepareOcgcore() private void prepareOcgcore()
{ {
......
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