Commit da4fdff2 authored by SherryChaos's avatar SherryChaos

see UpdateContent.txt

parent 08fa2264
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
MDPro3 v1.3.8更新: MDPro3 v1.3.8更新:
1.非中文的卡片渲染的属性球添加了注音文字; 1.非中文的卡片渲染的属性球添加了注音文字;
2.决斗中点击魔陷区会缩回对应玩家的手卡以展示魔陷区(屏幕比例16:9以上的缩回); 2.决斗中点击魔陷区会缩回对应玩家的手卡以展示魔陷区(屏幕比例16:9以上的缩回);
3.为移动端的卡组编辑界面的卡片详情页添加了左右滑动的功能; 3.移动端的卡组编辑界面的卡片详情页添加了左右滑动的功能;
4.修复移动端的卡组编辑界面的卡片详情页缺少Genesys点数图标的错误; 4.为决斗中生成卡片的功能添加了支持与特效(Duel.CreateToken,但卡片不是Token);
5.优化决斗中卡片发动与无效的动画,使其更接近MasterDuel的表现;
6.卡组添加分组功能;
7.修复移动端的卡组编辑界面的卡片详情页缺少Genesys点数图标的错误;
8.修复残局的录像无法播放的错误;
MDPro3 v1.3.7更新: MDPro3 v1.3.7更新:
1.卡组编辑界面的[测试]按钮恢复功能,并以第一位WindBot为对手,不洗牌进行决斗; 1.卡组编辑界面的[测试]按钮恢复功能,并以第一位WindBot为对手,不洗牌进行决斗;
......
...@@ -319,7 +319,6 @@ namespace Percy ...@@ -319,7 +319,6 @@ namespace Percy
public static extern int get_message(IntPtr pduel, IntPtr buf); public static extern int get_message(IntPtr pduel, IntPtr buf);
[DllImport("ocgcore", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] [DllImport("ocgcore", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
//public static extern void get_log_message(IntPtr pduel, IntPtr buf);
public static extern void get_log_message(IntPtr pduel, byte[] buf); public static extern void get_log_message(IntPtr pduel, byte[] buf);
[DllImport("ocgcore", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] [DllImport("ocgcore", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
......
...@@ -38,17 +38,17 @@ namespace MDPro3.Duel ...@@ -38,17 +38,17 @@ namespace MDPro3.Duel
{ {
showing = true; showing = true;
AudioManager.PlaySE("SE_LOG_OPEN"); AudioManager.PlaySE("SE_LOG_OPEN");
baseRect.DOAnchorPosX(-20f, 0.2f); baseRect.DOAnchorPosX(-20f, 0.2f).SetUpdate(true);
baseRect.localScale = Vector3.one * Config.GetUIScale(1.15f); baseRect.localScale = Vector3.one * Config.GetUIScale(1.15f);
} }
public void Hide(bool silent = false) public void Hide(bool mute = false)
{ {
showing = false; showing = false;
draged = false; draged = false;
baseRect.DOAnchorPosX(400f * Config.GetUIScale(1.15f) + SafeAreaAdapter.GetSafeAreaRightOffset(), 0.2f); baseRect.DOAnchorPosX(400f * Config.GetUIScale(1.15f) + SafeAreaAdapter.GetSafeAreaRightOffset(), 0.2f).SetUpdate(true);
if (!silent) if (!mute)
AudioManager.PlaySE("SE_LOG_CLOSE"); AudioManager.PlaySE("SE_LOG_CLOSE");
} }
...@@ -72,7 +72,7 @@ namespace MDPro3.Duel ...@@ -72,7 +72,7 @@ namespace MDPro3.Duel
if (!showing && fullHeight > scrollRect.viewport.rect.height) if (!showing && fullHeight > scrollRect.viewport.rect.height)
item.SetActive(false); item.SetActive(false);
if (!draged) if (!draged)
scrollRect.DOVerticalNormalizedPos(0f, 0.1f); scrollRect.DOVerticalNormalizedPos(0f, 0.1f).SetUpdate(true);
} }
public void ClearLog() public void ClearLog()
......
This diff is collapsed.
...@@ -1070,7 +1070,6 @@ namespace MDPro3.Duel ...@@ -1070,7 +1070,6 @@ namespace MDPro3.Duel
cardsInChain.Add(card); cardsInChain.Add(card);
codesInChain.Add(code); codesInChain.Add(code);
controllerInChain.Add(gps.controller); controllerInChain.Add(gps.controller);
card.AnimationActivate();
ES_hint = InterString.Get("「[?]」被发动时", card.GetData().Name); ES_hint = InterString.Get("「[?]」被发动时", card.GetData().Name);
if (gps.InMyControl()) if (gps.InMyControl())
{ {
...@@ -1084,7 +1083,7 @@ namespace MDPro3.Duel ...@@ -1084,7 +1083,7 @@ namespace MDPro3.Duel
} }
if(Core.GetAutoInfo()) if(Core.GetAutoInfo())
Core.GetUI<OcgCoreUI>().CardDescription.Show(card, null); Core.GetUI<OcgCoreUI>().CardDescription.Show(card, null);
await UniTask.WaitForSeconds(1f); await card.AnimationActivate().WaitAsync();
} }
protected override async UniTask GameMessage_Chained(BinaryReader reader) protected override async UniTask GameMessage_Chained(BinaryReader reader)
......
...@@ -25,6 +25,8 @@ namespace MDPro3.Duel.YGOSharp ...@@ -25,6 +25,8 @@ namespace MDPro3.Duel.YGOSharp
public string userId; public string userId;
public string deckId; public string deckId;
public string type = string.Empty;
public Deck() public Deck()
{ {
Main = new List<int>(); Main = new List<int>();
...@@ -40,7 +42,11 @@ namespace MDPro3.Duel.YGOSharp ...@@ -40,7 +42,11 @@ namespace MDPro3.Duel.YGOSharp
} }
public Deck(string path) : this(File.ReadAllText(path), string.Empty, string.Empty) public Deck(string path) : this(File.ReadAllText(path), string.Empty, string.Empty)
{} {
type = Path.GetFileName(Path.GetDirectoryName(path));
if(type == "Deck" && type == Path.GetDirectoryName(path))
type = string.Empty;
}
public Deck(string ydk, string deckID = "", string userID = "") public Deck(string ydk, string deckID = "", string userID = "")
{ {
...@@ -271,17 +277,21 @@ namespace MDPro3.Duel.YGOSharp ...@@ -271,17 +277,21 @@ namespace MDPro3.Duel.YGOSharp
/// <param name="saveTime"></param> /// <param name="saveTime"></param>
/// <param name="upload"></param> /// <param name="upload"></param>
/// <returns></returns> /// <returns></returns>
public bool Save(string deckName, DateTime saveTime, bool upload = true) public bool Save(string deckName, DateTime saveTime, bool upload = true, bool showHint = true)
{ {
var ydk = GetYDK(); var ydk = GetYDK();
try try
{ {
var path = Program.PATH_DECK + deckName + Program.EXPANSION_YDK; deckName = Path.GetFileNameWithoutExtension(deckName);
var path = Program.PATH_DECK + (type == string.Empty ? string.Empty : $"{type}/") + deckName + Program.EXPANSION_YDK;
var dir = Path.GetDirectoryName(path);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
File.WriteAllText(path, ydk, Encoding.UTF8); File.WriteAllText(path, ydk, Encoding.UTF8);
File.SetLastWriteTimeUtc(path, saveTime); File.SetLastWriteTimeUtc(path, saveTime);
if (MyCard.account != null && upload) if (MyCard.account != null && upload)
_ = OnlineDeck.SyncDeck(deckId, deckName, this, saveTime, true); _ = OnlineDeck.SyncDeck(deckId, deckName, this, saveTime, showHint);
} }
catch catch
{ {
......
...@@ -191,14 +191,20 @@ namespace MDPro3 ...@@ -191,14 +191,20 @@ namespace MDPro3
return scale > maxUIScale ? maxUIScale : scale; return scale > maxUIScale ? maxUIScale : scale;
} }
public static string GetConfigDeckName() public static string GetConfigDeckName(bool containType = true)
{ {
return Get("DeckInUse", EMPTY_STRING); var config = Get("DeckInUse", EMPTY_STRING);
if(!containType && config.Contains("/"))
config = Path.GetFileName(config);
return config;
} }
public static void SetConfigDeck(string deckName) public static void SetConfigDeck(string deckName, bool needCheck = false)
{ {
Set("DeckInUse", deckName); if(needCheck)
Set("DeckInUse", $"{Program.instance.deckSelector.DeckType}/{deckName}");
else
Set("DeckInUse", deckName);
} }
} }
} }
...@@ -93,7 +93,8 @@ namespace MDPro3 ...@@ -93,7 +93,8 @@ namespace MDPro3
renderer.material = mat; renderer.material = mat;
} }
public async UniTask LoadDummyCard(ElementObjectManager manager, int code, uint player, bool active = false) public async UniTask LoadDummyCard(ElementObjectManager manager, int code, uint player, bool active = false,
Renderer attachRenderer = null, Renderer attachRenderer2 = null)
{ {
if (active) if (active)
manager.gameObject.SetActive(false); manager.gameObject.SetActive(false);
...@@ -102,6 +103,10 @@ namespace MDPro3 ...@@ -102,6 +103,10 @@ namespace MDPro3
var renderer = manager.GetElement<Renderer>("DummyCardModel_front"); var renderer = manager.GetElement<Renderer>("DummyCardModel_front");
renderer.material = MaterialLoader.GetCardMaterial(code, true); renderer.material = MaterialLoader.GetCardMaterial(code, true);
renderer.material.mainTexture = await CardImageLoader.LoadCardAsync(code, false, manager.destroyCancellationToken); renderer.material.mainTexture = await CardImageLoader.LoadCardAsync(code, false, manager.destroyCancellationToken);
if(attachRenderer != null)
attachRenderer.material.mainTexture = renderer.material.mainTexture;
if (attachRenderer2 != null)
attachRenderer2.material.mainTexture = renderer.material.mainTexture;
if (active) if (active)
manager.gameObject.SetActive(true); manager.gameObject.SetActive(true);
} }
......
...@@ -437,7 +437,9 @@ namespace MDPro3 ...@@ -437,7 +437,9 @@ namespace MDPro3
public static void ShowBlackBack(float alpha, float time, Action action = null) public static void ShowBlackBack(float alpha, float time, Action action = null)
{ {
Program.instance.ui_.blackBack.raycastTarget = true; Program.instance.ui_.blackBack.raycastTarget = true;
Program.instance.ui_.blackBack.DOFade(alpha, time).OnComplete(() => Program.instance.ui_.blackBack.DOFade(alpha, time)
.SetUpdate(true)
.OnComplete(() =>
{ {
action?.Invoke(); action?.Invoke();
}); });
...@@ -445,7 +447,9 @@ namespace MDPro3 ...@@ -445,7 +447,9 @@ namespace MDPro3
public static void HideBlackBack(float time) public static void HideBlackBack(float time)
{ {
Program.instance.ui_.blackBack.DOFade(0f, time).OnComplete(() => Program.instance.ui_.blackBack.DOFade(0f, time)
.SetUpdate(true)
.OnComplete(() =>
{ {
Program.instance.ui_.blackBack.raycastTarget = false; Program.instance.ui_.blackBack.raycastTarget = false;
}); });
......
...@@ -79,11 +79,7 @@ namespace MDPro3.Net ...@@ -79,11 +79,7 @@ namespace MDPro3.Net
{ {
using var request = UnityWebRequest.Get(authUrl); using var request = UnityWebRequest.Get(authUrl);
request.SetRequestHeader(authHeader, "Bearer " + token); request.SetRequestHeader(authHeader, "Bearer " + token);
await request.SendWebRequest();
var send = request.SendWebRequest();
await TaskUtility.WaitUntil(() => send.isDone);
if(!Application.isPlaying)
return null;
if (request.result == UnityWebRequest.Result.Success) if (request.result == UnityWebRequest.Result.Success)
{ {
......
using MDPro3.Duel.YGOSharp; using MDPro3.Duel.YGOSharp;
using MDPro3.Utility; using MDPro3.Utility;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
...@@ -129,7 +131,10 @@ namespace MDPro3.Net ...@@ -129,7 +131,10 @@ namespace MDPro3.Net
if (request.result == UnityWebRequest.Result.Success) if (request.result == UnityWebRequest.Result.Success)
{ {
//Debug.Log(request.downloadHandler.text); //var formatted = Tools.FormatJsonString(request.downloadHandler.text);
//File.WriteAllText("Decks.txt", formatted);
//Debug.Log(formatted);
decks = JsonUtility.FromJson<ResponseMultiSimpleData>(request.downloadHandler.text).data; decks = JsonUtility.FromJson<ResponseMultiSimpleData>(request.downloadHandler.text).data;
return decks; return decks;
} }
...@@ -206,18 +211,20 @@ namespace MDPro3.Net ...@@ -206,18 +211,20 @@ namespace MDPro3.Net
{ {
var oldName = deckNames[i]; var oldName = deckNames[i];
var newName = deckNames[i]; var newName = deckNames[i];
if (DeckNameExist(oldName)) if (DeckNameExist(oldName, decks[i].type))
{ {
newName += " - " + InterString.Get("复制"); newName += " - " + InterString.Get("复制");
while (File.Exists(Program.PATH_DECK + newName + Program.EXPANSION_YDK)) while (File.Exists(Program.PATH_DECK + (decks[i].type == string.Empty ? string.Empty : $"{decks[i].type}/")
+ newName + Program.EXPANSION_YDK))
newName += " - " + InterString.Get("复制"); newName += " - " + InterString.Get("复制");
File.Delete(Program.PATH_DECK + oldName + Program.EXPANSION_YDK); File.Delete(Program.PATH_DECK + (decks[i].type == string.Empty ? string.Empty : $"{decks[i].type}/") + oldName + Program.EXPANSION_YDK);
} }
body.decks[i] = new PostDeck body.decks[i] = new PostDeck
{ {
deckId = ids[i], deckId = ids[i],
deckName = newName, deckName = newName,
deckType = decks[i].type,
deckCoverCard1 = decks[i].Pickup.Count > 0 ? decks[i].Pickup[0] : 0, deckCoverCard1 = decks[i].Pickup.Count > 0 ? decks[i].Pickup[0] : 0,
deckCoverCard2 = decks[i].Pickup.Count > 1 ? decks[i].Pickup[1] : 0, deckCoverCard2 = decks[i].Pickup.Count > 1 ? decks[i].Pickup[1] : 0,
deckCoverCard3 = decks[i].Pickup.Count > 2 ? decks[i].Pickup[2] : 0, deckCoverCard3 = decks[i].Pickup.Count > 2 ? decks[i].Pickup[2] : 0,
...@@ -433,14 +440,11 @@ namespace MDPro3.Net ...@@ -433,14 +440,11 @@ namespace MDPro3.Net
return true; return true;
} }
private static bool DeckNameExist(string deckName) private static bool DeckNameExist(string deckName, string deckType)
{ {
if (decks == null) if (decks == null)
return false; return false;
foreach (var deck in decks) return decks.Any(deck => !deck.isDelete && deck.deckName == deckName && deck.deckType == deckType);
if (deck.deckName == deckName && !deck.isDelete)
return true;
return false;
} }
#endregion #endregion
...@@ -569,6 +573,7 @@ namespace MDPro3.Net ...@@ -569,6 +573,7 @@ namespace MDPro3.Net
{ {
public string deckId; public string deckId;
public string deckName; public string deckName;
public string deckType;
public int deckCoverCard1; public int deckCoverCard1;
public int deckCoverCard2; public int deckCoverCard2;
public int deckCoverCard3; public int deckCoverCard3;
...@@ -591,6 +596,7 @@ namespace MDPro3.Net ...@@ -591,6 +596,7 @@ namespace MDPro3.Net
{ {
this.deckId = deckId; this.deckId = deckId;
this.deckName = deckName; this.deckName = deckName;
deckType = deck.type;
if (deck.Pickup.Count > 0) if (deck.Pickup.Count > 0)
deckCoverCard1 = deck.Pickup[0]; deckCoverCard1 = deck.Pickup[0];
if (deck.Pickup.Count > 1) if (deck.Pickup.Count > 1)
......
...@@ -634,7 +634,7 @@ namespace MDPro3 ...@@ -634,7 +634,7 @@ namespace MDPro3
} }
catch catch
{ {
Debug.LogError("Addressables Not Found: " + $"DeckCase{code.ToString()[3..]}{suffix}"); Debug.LogError("Addressables Not Found: " + $"DeckCase {code}_{suffix}");
return await LoadAddressableSprite(ADDRESS_DEFAULT_DECK_CASE); return await LoadAddressableSprite(ADDRESS_DEFAULT_DECK_CASE);
} }
} }
......
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.UI;
using MDPro3.Duel.YGOSharp;
using MDPro3.UI; using MDPro3.UI;
using MDPro3.Net;
using TMPro;
using UnityEngine.EventSystems;
using MDPro3.UI.ServantUI; using MDPro3.UI.ServantUI;
namespace MDPro3.Servant namespace MDPro3.Servant
...@@ -52,11 +39,14 @@ namespace MDPro3.Servant ...@@ -52,11 +39,14 @@ namespace MDPro3.Servant
public override int Depth => 4; public override int Depth => 4;
protected override bool ShowLine => true; protected override bool ShowLine => true;
public string DeckType => GetUI<DeckSelectorUI>().deckType;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SwitchCondition(Condition.ForEdit); SwitchCondition(Condition.ForEdit);
} }
public override void OnExit() public override void OnExit()
{ {
if (Program.exitOnReturn) if (Program.exitOnReturn)
...@@ -64,6 +54,7 @@ namespace MDPro3.Servant ...@@ -64,6 +54,7 @@ namespace MDPro3.Servant
else else
Program.instance.ShiftToServant(returnServant); Program.instance.ShiftToServant(returnServant);
} }
public override void PerFrameFunction() public override void PerFrameFunction()
{ {
if (!showing) return; if (!showing) return;
...@@ -79,13 +70,21 @@ namespace MDPro3.Servant ...@@ -79,13 +70,21 @@ namespace MDPro3.Servant
if (GetUI<DeckSelectorUI>().ButtonOnline.gameObject.activeSelf) if (GetUI<DeckSelectorUI>().ButtonOnline.gameObject.activeSelf)
GetUI<DeckSelectorUI>().OnOnlineDeckView(); GetUI<DeckSelectorUI>().OnOnlineDeckView();
else else
GetUI<DeckSelectorUI>().OnDeleteConfirm(); GetUI<DeckSelectorUI>().OnConfirm();
} }
if (UserInput.WasGamepadButtonNorthPressed) if (UserInput.WasGamepadButtonNorthPressed)
{ {
AudioManager.PlaySE("SE_MENU_SELECT_01"); AudioManager.PlaySE("SE_MENU_SELECT_01");
GetUI<DeckSelectorUI>().ActivateInputField(); GetUI<DeckSelectorUI>().ActivateInputField();
} }
if (UserInput.WasLeftShoulderPressed)
{
if (GetUI<DeckSelectorUI>().ButtonType.gameObject.activeSelf)
{
AudioManager.PlaySE("SE_MENU_SELECT_01");
GetUI<DeckSelectorUI>().OnType();
}
}
if (UserInput.WasRightShoulderPressed) if (UserInput.WasRightShoulderPressed)
{ {
if (GetUI<DeckSelectorUI>().ButtonOnline.gameObject.activeSelf) if (GetUI<DeckSelectorUI>().ButtonOnline.gameObject.activeSelf)
...@@ -101,11 +100,12 @@ namespace MDPro3.Servant ...@@ -101,11 +100,12 @@ namespace MDPro3.Servant
else else
{ {
AudioManager.PlaySE("SE_MENU_CANCEL"); AudioManager.PlaySE("SE_MENU_CANCEL");
GetUI<DeckSelectorUI>().OnDeleteCancel(); GetUI<DeckSelectorUI>().OnCancel();
} }
} }
} }
} }
public override void Select(bool forced = false) public override void Select(bool forced = false)
{ {
if (!forced && !UserInput.NeedDefaultSelect()) if (!forced && !UserInput.NeedDefaultSelect())
...@@ -113,6 +113,7 @@ namespace MDPro3.Servant ...@@ -113,6 +113,7 @@ namespace MDPro3.Servant
lastSelectedDeckItem.GetSelectable().Select(); lastSelectedDeckItem.GetSelectable().Select();
} }
public override bool NeedResponseInput() public override bool NeedResponseInput()
{ {
if(servantUI == null if(servantUI == null
......
...@@ -24,7 +24,7 @@ namespace MDPro3.Servant ...@@ -24,7 +24,7 @@ namespace MDPro3.Servant
public class OcgCore : Servant public class OcgCore : Servant
{ {
private DuelBGManager DuelBGManager => messageDispatcher.duel.duelBGManager; public DuelBGManager DuelBGManager => messageDispatcher.duel.duelBGManager;
public List<GameObject> allGameObjects => messageDispatcher.duel.duelBGManager.allGameObjects; public List<GameObject> allGameObjects => messageDispatcher.duel.duelBGManager.allGameObjects;
public List<PlaceSelector> places => messageDispatcher.duel.duelBGManager.places; public List<PlaceSelector> places => messageDispatcher.duel.duelBGManager.places;
public static List<GameCard> materialCards = new(); public static List<GameCard> materialCards = new();
...@@ -740,13 +740,13 @@ namespace MDPro3.Servant ...@@ -740,13 +740,13 @@ namespace MDPro3.Servant
public void StocMessage_Error(string error) public void StocMessage_Error(string error)
{ {
StartCoroutine(ShowErrorMessageAsync(error)); _ = ShowErrorMessageAsync(error);
} }
private IEnumerator ShowErrorMessageAsync(string error) private async UniTask ShowErrorMessageAsync(string error)
{ {
while (servantUI == null) await UniTask.WaitWhile(() => servantUI == null);
yield return null; UniTask.ReturnToMainThread();
GetUI<OcgCoreUI>().DuelErrorLog.Show(error); GetUI<OcgCoreUI>().DuelErrorLog.Show(error);
} }
...@@ -939,7 +939,7 @@ namespace MDPro3.Servant ...@@ -939,7 +939,7 @@ namespace MDPro3.Servant
currentMessage = (GameMessage)currentPackage.Function; currentMessage = (GameMessage)currentPackage.Function;
//if (currentMessage != GameMessage.UpdateData) //if (currentMessage != GameMessage.UpdateData)
//Debug.Log($"GameMessage: {currentMessage}"); // Debug.Log($"GameMessage: {currentMessage}");
try try
{ {
...@@ -1374,6 +1374,49 @@ namespace MDPro3.Servant ...@@ -1374,6 +1374,49 @@ namespace MDPro3.Servant
return 0; return 0;
} }
public int GetUpdateDataIdByGameCard(GameCard card)
{
for (int i = 0; i < packages.Count; i++)
{
if ((GameMessage)packages[i].Function == GameMessage.UpdateData)
{
var reader = packages[i].Data.reader;
reader.BaseStream.Seek(0, 0);
var player = LocalPlayer(reader.ReadChar());
var location = reader.ReadChar();
if (player != card.p.controller)
continue;
if((location & card.p.location) == 0)
continue;
while (true)
{
var len = reader.ReadInt32();
if (len == 4) continue;
var pos = reader.BaseStream.Position;
var flag = reader.ReadInt32();
var code = 0;
if((flag & (int)Query.Code) != 0)
code = reader.ReadInt32();
if ((flag & (int)Query.Position) != 0)
{
var gps = reader.ReadGPS();
var cardToRefresh = Program.instance.ocgcore.GCS_Get(gps);
if (cardToRefresh != null && cardToRefresh == card)
return code;
else
{
reader.BaseStream.Position = pos + len - 4;
continue;
}
}
}
}
}
return 0;
}
#endregion #endregion
#region Practicalize #region Practicalize
...@@ -1889,13 +1932,6 @@ namespace MDPro3.Servant ...@@ -1889,13 +1932,6 @@ namespace MDPro3.Servant
DuelBGManager.UpdateExDeckTop(controller); DuelBGManager.UpdateExDeckTop(controller);
} }
public void RefreshBgState()
{
if (DuelBGManager == null)
return;
DuelBGManager.RefreshBgState();
}
public void SetBgTimeScale(float timeScale) public void SetBgTimeScale(float timeScale)
{ {
if (DuelBGManager == null) if (DuelBGManager == null)
...@@ -1985,79 +2021,6 @@ namespace MDPro3.Servant ...@@ -1985,79 +2021,6 @@ namespace MDPro3.Servant
deck.GetElement("CardShuffleTop").SetActive(active); deck.GetElement("CardShuffleTop").SetActive(active);
} }
bool CheckChain()
{
bool config = true;
if (condition == Condition.Duel && Config.Get("DuelChain", "1") == "0")
config = false;
else if (condition == Condition.Watch && Config.Get("WatchChain", "1") == "0")
config = false;
else if (condition == Condition.Replay && Config.Get("ReplayChain", "1") == "0")
config = false;
return config;
}
void ChangeChainNumber(SpriteRenderer digit, SpriteRenderer one, SpriteRenderer ten, int number)
{
if (number < 10)
{
one.gameObject.SetActive(false);
ten.gameObject.SetActive(false);
digit.sprite = TextureManager.container.GetChainNumSprite(number);
}
else
{
digit.gameObject.SetActive(false);
one.sprite = TextureManager.container.GetChainNumSprite(number % 10);
ten.sprite = TextureManager.container.GetChainNumSprite((number / 10) % 10);
}
}
private void PlayCommonSpecialWin(int[] codes)
{
var count = codes.Length;
var go = ABLoader.LoadFromFolder<ElementObjectManager>("MasterDuel/Timeline/SpecialWin/SpecialWinCommonCard0" + count, false, true);
allGameObjects.Add(go);
var mner = go.GetComponent<ElementObjectManager>();
foreach (var child in mner.transform.GetComponentsInChildren<Transform>(true))
if (child.name == "White")
{
//var newWhite = Instantiate(child.gameObject);
//newWhite.transform.SetParent(child.transform, false);
//newWhite.transform.localScale = Vector3.one;
//newWhite.GetComponent<SpriteRenderer>().color = Color.clear;
child.gameObject.SetActive(false);
}
_ = Program.instance.texture_.LoadDummyCard(mner.GetElement<ElementObjectManager>("DummyCard01"), codes[0], 0, true);
mner.GetElement<ElementObjectManager>("DummyCard01").GetElement<Renderer>("DummyCardModel_front").material.renderQueue = 4000;
if (count > 1)
_ = Program.instance.texture_.LoadDummyCard(mner.GetElement<ElementObjectManager>("DummyCard02"), codes[1], 0, true);
if (count > 2)
_ = Program.instance.texture_.LoadDummyCard(mner.GetElement<ElementObjectManager>("DummyCard03"), codes[2], 0, true);
if (count > 3)
_ = Program.instance.texture_.LoadDummyCard(mner.GetElement<ElementObjectManager>("DummyCard04"), codes[3], 0, true);
if (count > 4)
_ = Program.instance.texture_.LoadDummyCard(mner.GetElement<ElementObjectManager>("DummyCard05"), codes[4], 0, true);
mner.GetComponent<PlayableDirector>().Play();
var mono = mner.gameObject.AddComponent<DoWhenPlayableDirectorStop>();
mono.action = () =>
{
Destroy(go);
};
}
private ElementObjectManager PlaySpecialWin(string path)
{
var go = ABLoader.LoadFromFolder<ElementObjectManager>("MasterDuel/Timeline/SpecialWin/" + path, false, true);
allGameObjects.Add(go);
ElementObjectManager manager = go.GetComponent<ElementObjectManager>();
var mono = go.AddComponent<DoWhenPlayableDirectorStop>();
mono.action = () => { Destroy(go); };
return manager;
}
#endregion #endregion
#region Voice #region Voice
......
using System;
using MDPro3.UI;
using MDPro3.Duel.YGOSharp; using MDPro3.Duel.YGOSharp;
using MDPro3.Net;
using MDPro3.UI;
using MDPro3.UI.ServantUI;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using UnityEngine; using System.Linq;
using UnityEngine.UI;
using TMPro; using TMPro;
using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using MDPro3.Net; using UnityEngine.UI;
using MDPro3.UI.ServantUI; using YgomGame.TextIDs;
using static MDPro3.Duel.YGOSharp.PacksManager; using static MDPro3.Duel.YGOSharp.PacksManager;
namespace MDPro3.Servant namespace MDPro3.Servant
...@@ -267,7 +269,7 @@ namespace MDPro3.Servant ...@@ -267,7 +269,7 @@ namespace MDPro3.Servant
yield break; yield break;
} }
var deckFiles = Directory.GetFiles(Program.PATH_DECK, "*.ydk"); var deckFiles = Directory.GetFiles(Program.PATH_DECK, "*.ydk", SearchOption.AllDirectories);
var decks = new List<Deck>(); var decks = new List<Deck>();
foreach (var deckPath in deckFiles) foreach (var deckPath in deckFiles)
decks.Add(new Deck(deckPath)); decks.Add(new Deck(deckPath));
...@@ -280,11 +282,10 @@ namespace MDPro3.Servant ...@@ -280,11 +282,10 @@ namespace MDPro3.Servant
for (int i = 0; i < decks.Count; i++) for (int i = 0; i < decks.Count; i++)
{ {
var deckName = Path.GetFileNameWithoutExtension(deckFiles[i]); var deckName = Path.GetFileNameWithoutExtension(deckFiles[i]);
if (decks[i].userId != MyCard.account.user.id.ToString()) var type = Path.GetFileName(Path.GetDirectoryName(deckFiles[i]));
{ if (type == "Deck" && type == Path.GetDirectoryName(deckFiles[i]))
decksNeedUpload.Add(deckName, decks[i]); type = string.Empty;
continue; decks[i].type = type;
}
bool deckIdFound = false; bool deckIdFound = false;
foreach (var od in OnlineDeck.decks) foreach (var od in OnlineDeck.decks)
...@@ -292,15 +293,13 @@ namespace MDPro3.Servant ...@@ -292,15 +293,13 @@ namespace MDPro3.Servant
if (od.deckId == decks[i].deckId) if (od.deckId == decks[i].deckId)
{ {
deckIdFound = true; deckIdFound = true;
localFoundIds.Add(od.deckId);
if (od.isDelete) if (od.isDelete)
{ {
Debug.LogFormat("Deck Delete: [{0}]", deckName);
File.Delete(deckFiles[i]); File.Delete(deckFiles[i]);
} }
else else
{ {
localFoundIds.Add(od.deckId);
var fileInfo = new FileInfo(deckFiles[i]); var fileInfo = new FileInfo(deckFiles[i]);
var serverTime = od.GetUpdateUtcTime(); var serverTime = od.GetUpdateUtcTime();
var diff = serverTime - fileInfo.LastWriteTimeUtc; var diff = serverTime - fileInfo.LastWriteTimeUtc;
...@@ -314,10 +313,13 @@ namespace MDPro3.Servant ...@@ -314,10 +313,13 @@ namespace MDPro3.Servant
else else
decksNeedUpdateFromServer.Add(deckName, decks[i]); decksNeedUpdateFromServer.Add(deckName, decks[i]);
} }
if(deckName != od.deckName && !decksNeedUpdateFromServer.Keys.Contains(deckName))
decksNeedUpdateFromServer.Add(deckName, decks[i]);
} }
break; break;
} }
} }
if (!deckIdFound) if (!deckIdFound)
decksNeedUpload.Add(deckName, decks[i]); decksNeedUpload.Add(deckName, decks[i]);
} }
...@@ -337,29 +339,35 @@ namespace MDPro3.Servant ...@@ -337,29 +339,35 @@ namespace MDPro3.Servant
Debug.LogFormat("卡组[{0}]需要更新。", deck.Key); Debug.LogFormat("卡组[{0}]需要更新。", deck.Key);
var od = OnlineDeck.GetByID(deck.Value.deckId); var od = OnlineDeck.GetByID(deck.Value.deckId);
var oldPath = Program.PATH_DECK + deck.Key + Program.EXPANSION_YDK; var oldPath = Program.PATH_DECK + (deck.Value.type == string.Empty ? string.Empty : $"{deck.Value.type}/") + deck.Key + Program.EXPANSION_YDK;
if (oldPath != od.deckName) if (deck.Key != od.deckName || deck.Value.type != od.deckType)
File.Delete(oldPath); File.Delete(oldPath);
var newPath = Program.PATH_DECK + od.deckName + Program.EXPANSION_YDK; var newPath = Program.PATH_DECK + (od.deckType == string.Empty ? string.Empty : $"{od.deckType}/") + od.deckName + Program.EXPANSION_YDK;
File.WriteAllText(newPath, od.deckYdk); File.WriteAllText(newPath, od.deckYdk);
File.SetLastWriteTimeUtc(newPath, od.GetUpdateUtcTime()); File.SetLastWriteTimeUtc(newPath, od.GetUpdateUtcTime());
} }
//下载本地ID不存在的服务器卡组 //下载本地ID不存在的服务器卡组
//OnlineDeck.UploadDecks() 会刷新OnlineDeck.decks,因此本功能需要在[上传没有Id的本地卡组]之前执行 //OnlineDeck.UploadDecks() 会刷新OnlineDeck.decks,因此本功能需要在[上传没有Id的本地卡组]之前执行
List<OnlineDeck.OnlineDeckData> odtd = new List<OnlineDeck.OnlineDeckData>(); var odtd = OnlineDeck.decks
foreach (var od in OnlineDeck.decks) .Where(od => !od.isDelete && !localFoundIds.Contains(od.deckId))
if (!od.isDelete) .ToList();
if (!localFoundIds.Contains(od.deckId))
odtd.Add(od);
foreach (var deck in odtd) foreach (var deck in odtd)
{ {
Debug.LogFormat("卡组[{0}]需要下载。{1}", deck.deckName, deck.isDelete); var path = Program.PATH_DECK + (deck.deckType == string.Empty ? string.Empty : $"{deck.deckType}/") + deck.deckName + Program.EXPANSION_YDK;
if (File.Exists(path))
{
Debug.Log($"删除服务器同名卡组 [{deck.deckType}/{deck.deckName}] [{deck.deckId}]。");
_ = OnlineDeck.DeleteDecks(new List<string> { deck.deckId });
continue;
}
Debug.Log($"卡组[{deck.deckName}] [{deck.deckId}]需要下载。");
var d = new Deck(deck.deckYdk, string.Empty, string.Empty); var d = new Deck(deck.deckYdk, deck.deckId, MyCard.account.user.username)
d.userId = MyCard.account.user.id.ToString(); {
d.deckId = deck.deckId; type = deck.deckType
d.Save(deck.deckName, deck.GetUpdateUtcTime()); };
d.Save(Path.GetFileName(deck.deckName), deck.GetUpdateUtcTime(), false);
} }
//上传没有Id的本地卡组 //上传没有Id的本地卡组
......
...@@ -176,7 +176,9 @@ namespace MDPro3.Servant ...@@ -176,7 +176,9 @@ namespace MDPro3.Servant
if (fromDuel) if (fromDuel)
{ {
servantUI.ShowEvent(); servantUI.ShowEvent();
DOTween.To(v => { }, 0, 0, Program.instance.ocgcore.TransitionTime).OnComplete(() => DOTween.To(v => { }, 0, 0, Program.instance.ocgcore.TransitionTime)
.SetUpdate(true)
.OnComplete(() =>
{ {
servantUI.gameObject.SetActive(true); servantUI.gameObject.SetActive(true);
inTransition = false; inTransition = false;
...@@ -237,7 +239,9 @@ namespace MDPro3.Servant ...@@ -237,7 +239,9 @@ namespace MDPro3.Servant
if (toDuel) if (toDuel)
{ {
DOTween.To(v => { }, 0, 0, TransitionTime).OnComplete(() => DOTween.To(v => { }, 0, 0, TransitionTime)
.SetUpdate(true)
.OnComplete(() =>
{ {
servantUI.ShutDown(); servantUI.ShutDown();
inTransition = false; inTransition = false;
...@@ -246,7 +250,9 @@ namespace MDPro3.Servant ...@@ -246,7 +250,9 @@ namespace MDPro3.Servant
else else
{ {
servantUI.Hide(nextDepth > Depth); servantUI.Hide(nextDepth > Depth);
DOTween.To(v => { }, 0, 0, TransitionTime).OnComplete(() => DOTween.To(v => { }, 0, 0, TransitionTime)
.SetUpdate(true)
.OnComplete(() =>
{ {
inTransition = false; inTransition = false;
AfterHidingEvent(); AfterHidingEvent();
......
using MDPro3.Utility; using MDPro3.Utility;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -351,5 +352,22 @@ namespace MDPro3 ...@@ -351,5 +352,22 @@ namespace MDPro3
#endregion #endregion
#region Json
public static string FormatJsonString(string jsonString)
{
try
{
var obj = JsonConvert.DeserializeObject(jsonString);
return JsonConvert.SerializeObject(obj, Formatting.Indented);
}
catch
{
return jsonString;
}
}
#endregion
} }
} }
...@@ -17,6 +17,7 @@ namespace MDPro3.UI.Popup ...@@ -17,6 +17,7 @@ namespace MDPro3.UI.Popup
base.InitializeSelections(); base.InitializeSelections();
input.GetComponent<TmpInputValidation>().type = validationType; input.GetComponent<TmpInputValidation>().type = validationType;
input.text = args[1]; input.text = args[1];
input.ActivateInputField();
} }
protected override void OnCancel() protected override void OnCancel()
......
...@@ -49,7 +49,7 @@ namespace MDPro3.UI.Popup ...@@ -49,7 +49,7 @@ namespace MDPro3.UI.Popup
var tasks = new List<string[]>(); var tasks = new List<string[]>();
for (int i = 2; i < args.Count; i++) for (int i = 2; i < args.Count; i++)
{ {
var task = new string[] { args[i] }; var task = args[i].Split(":");
tasks.Add(task); tasks.Add(task);
} }
superScrollView.Print(tasks); superScrollView.Print(tasks);
...@@ -61,7 +61,15 @@ namespace MDPro3.UI.Popup ...@@ -61,7 +61,15 @@ namespace MDPro3.UI.Popup
private void ItemOnListRefresh(string[] task, GameObject item) private void ItemOnListRefresh(string[] task, GameObject item)
{ {
var handler = item.GetComponent<SelectionToggle_PopupSelectionItem>(); var handler = item.GetComponent<SelectionToggle_PopupSelectionItem>();
handler.selection = task[0]; if(task.Length == 2)
{
handler.color = task[0];
handler.selection = task[1];
}
else
{
handler.selection = task[0];
}
handler.clickAction = OnClick; handler.clickAction = OnClick;
handler.manager = this; handler.manager = this;
handler.Refresh(); handler.Refresh();
......
...@@ -69,7 +69,7 @@ namespace MDPro3.UI ...@@ -69,7 +69,7 @@ namespace MDPro3.UI
private const string LABEL_TXT_BUTTONTEXT = "ButtonText"; private const string LABEL_TXT_BUTTONTEXT = "ButtonText";
private TextMeshProUGUI m_ButtonText; private TextMeshProUGUI m_ButtonText;
private TextMeshProUGUI ButtonText => protected TextMeshProUGUI ButtonText =>
m_ButtonText = m_ButtonText != null ? m_ButtonText m_ButtonText = m_ButtonText != null ? m_ButtonText
: Manager.GetElement<TextMeshProUGUI>(LABEL_TXT_BUTTONTEXT); : Manager.GetElement<TextMeshProUGUI>(LABEL_TXT_BUTTONTEXT);
...@@ -446,6 +446,19 @@ namespace MDPro3.UI ...@@ -446,6 +446,19 @@ namespace MDPro3.UI
return string.Empty; return string.Empty;
} }
public virtual void SetButtonTextColor(Color color)
{
if (ButtonText != null)
ButtonText.color = color;
}
public virtual Color GetButtonTextColor()
{
if (ButtonText != null)
return ButtonText.color;
return Color.white;
}
public virtual Sprite GetIconSprite() public virtual Sprite GetIconSprite()
{ {
if(Icon != null) if(Icon != null)
...@@ -459,6 +472,12 @@ namespace MDPro3.UI ...@@ -459,6 +472,12 @@ namespace MDPro3.UI
Icon.sprite = sprite; Icon.sprite = sprite;
} }
public virtual void ShowIcon(bool show)
{
if(Icon != null)
Icon.gameObject.SetActive(show);
}
public virtual void SetHoverOnEvent(UnityAction call) public virtual void SetHoverOnEvent(UnityAction call)
{ {
hoverEvent.onHoverOn.AddListener(call); hoverEvent.onHoverOn.AddListener(call);
......
...@@ -102,7 +102,10 @@ namespace MDPro3.UI ...@@ -102,7 +102,10 @@ namespace MDPro3.UI
await UniTask.WaitWhile(() => Program.instance.deckSelector.inTransition); await UniTask.WaitWhile(() => Program.instance.deckSelector.inTransition);
for (int i = 0; i < transform.GetSiblingIndex(); i++) for (int i = 0; i < transform.GetSiblingIndex(); i++)
await UniTask.Yield(); await UniTask.Yield(cancellationToken: destroyCancellationToken);
if (gameObject == null)
return;
var sprite = await Program.items.LoadDeckCaseIconAsync(deckCase, "_L_SD"); var sprite = await Program.items.LoadDeckCaseIconAsync(deckCase, "_L_SD");
if (sprite != null) if (sprite != null)
...@@ -187,7 +190,7 @@ namespace MDPro3.UI ...@@ -187,7 +190,7 @@ namespace MDPro3.UI
else else
{ {
AudioManager.PlaySE(SoundLabelClick); AudioManager.PlaySE(SoundLabelClick);
Config.SetConfigDeck(deckName); Config.SetConfigDeck(deckName, true);
if (DeckSelector.condition == DeckSelector.Condition.ForEdit) if (DeckSelector.condition == DeckSelector.Condition.ForEdit)
{ {
Program.instance.deckEditor.SwitchCondition(DeckEditor.Condition.EditDeck); Program.instance.deckEditor.SwitchCondition(DeckEditor.Condition.EditDeck);
......
...@@ -2,18 +2,36 @@ using MDPro3.UI; ...@@ -2,18 +2,36 @@ using MDPro3.UI;
using System; using System;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
using YgomSystem.UI;
namespace MDPro3.UI.Popup namespace MDPro3.UI.Popup
{ {
public class SelectionToggle_PopupSelectionItem : SelectionToggle_ScrollRectItem public class SelectionToggle_PopupSelectionItem : SelectionToggle_ScrollRectItem
{ {
public string selection; public string selection;
public string color = string.Empty;
public Action clickAction; public Action clickAction;
public PopupSelection manager; public PopupSelection manager;
private void SetTextColor()
{
var targetColor = Color.white;
if(color == "r")
targetColor = Color.red;
else if(color == "g")
targetColor = Color.green;
else if(color == "b")
targetColor = Color.cyan;
var ccg = ButtonText.GetComponent<ColorContainerGraphic>();
ccg.baseColor = targetColor;
SetButtonTextColor(targetColor);
}
public override void Refresh() public override void Refresh()
{ {
SetButtonText(selection); SetButtonText(selection);
SetTextColor();
RemoveAllListeners(); RemoveAllListeners();
SetClickEvent(new UnityAction(clickAction)); SetClickEvent(new UnityAction(clickAction));
} }
......
...@@ -28,6 +28,7 @@ namespace MDPro3.UI ...@@ -28,6 +28,7 @@ namespace MDPro3.UI
public void Show(string log) public void Show(string log)
{ {
log = $"[OcgCore Message]: {log}";
lastMessage = text.text; lastMessage = text.text;
text.text = lastMessage + Program.STRING_LINE_BREAK + log; text.text = lastMessage + Program.STRING_LINE_BREAK + log;
......
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