Commit 4c71c8a4 authored by hex's avatar hex

- Optimized DeckManager

parent 020eee2a
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
...@@ -189,7 +190,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -189,7 +190,7 @@ public class DeckManager : ServantWithCardDescription
Program.camera_main_2d.ScreenToWorldPoint( Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width + 600, Screen.height / 2, 600) new Vector3(Screen.width + 600, Screen.height / 2, 600)
), ),
1.2f 0.6f
); );
refreshDetail(); refreshDetail();
} }
...@@ -205,7 +206,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -205,7 +206,7 @@ public class DeckManager : ServantWithCardDescription
Program.camera_main_2d.ScreenToWorldPoint( Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(Screen.width - MAIN_PANEL_MARGIN_RIGHT, Screen.height / 2, 0) new Vector3(Screen.width - MAIN_PANEL_MARGIN_RIGHT, Screen.height / 2, 0)
), ),
1.2f 0.6f
); );
refreshDetail(); refreshDetail();
} }
...@@ -298,51 +299,54 @@ public class DeckManager : ServantWithCardDescription ...@@ -298,51 +299,54 @@ public class DeckManager : ServantWithCardDescription
if (deck.IMain.Count <= 60 && deck.IExtra.Count <= 15 && deck.ISide.Count <= 15) if (deck.IMain.Count <= 60 && deck.IExtra.Count <= 15 && deck.ISide.Count <= 15)
{ {
string deckInUse = Config.Get("deckInUse", "miaowu"); string deckInUse = Config.Get("deckInUse", "miaowu");
StringBuilder sb = new StringBuilder(2048); // 预估最大容量,避免多次扩容
if (canSave) if (canSave)
{ {
ArrangeObjectDeck(); ArrangeObjectDeck();
FromObjectDeckToCodedDeck(true); FromObjectDeckToCodedDeck(true);
string value = "#created by ygopro2\r\n#main\r\n"; sb.AppendLine("#created by ygopro2");
sb.AppendLine("#main");
for (int i = 0; i < deck.Main.Count; i++) for (int i = 0; i < deck.Main.Count; i++)
{ {
value += deck.Main[i].ToString() + "\r\n"; sb.AppendLine(deck.Main[i].ToString());
} }
value += "#extra\r\n"; sb.AppendLine("#extra");
for (int i = 0; i < deck.Extra.Count; i++) for (int i = 0; i < deck.Extra.Count; i++)
{ {
value += deck.Extra[i].ToString() + "\r\n"; sb.AppendLine(deck.Extra[i].ToString());
} }
value += "!side\r\n"; sb.AppendLine("!side");
for (int i = 0; i < deck.Side.Count; i++) for (int i = 0; i < deck.Side.Count; i++)
{ {
value += deck.Side[i].ToString() + "\r\n"; sb.AppendLine(deck.Side[i].ToString());
} }
System.IO.File.WriteAllText( System.IO.File.WriteAllText(
"deck/" + deckInUse + ".ydk", "deck/" + deckInUse + ".ydk",
value, sb.ToString(),
System.Text.Encoding.UTF8 System.Text.Encoding.UTF8
); );
} }
else else
{ {
string value = "#created by ygopro2\r\n#main\r\n"; sb.AppendLine("#created by ygopro2");
sb.AppendLine("#main");
for (int i = 0; i < deck.Deck_O.Main.Count; i++) for (int i = 0; i < deck.Deck_O.Main.Count; i++)
{ {
value += deck.Deck_O.Main[i].ToString() + "\r\n"; sb.AppendLine(deck.Deck_O.Main[i].ToString());
} }
value += "#extra\r\n"; sb.AppendLine("#extra");
for (int i = 0; i < deck.Deck_O.Extra.Count; i++) for (int i = 0; i < deck.Deck_O.Extra.Count; i++)
{ {
value += deck.Deck_O.Extra[i].ToString() + "\r\n"; sb.AppendLine(deck.Deck_O.Extra[i].ToString());
} }
value += "!side\r\n"; sb.AppendLine("!side");
for (int i = 0; i < deck.Deck_O.Side.Count; i++) for (int i = 0; i < deck.Deck_O.Side.Count; i++)
{ {
value += deck.Deck_O.Side[i].ToString() + "\r\n"; sb.AppendLine(deck.Deck_O.Side[i].ToString());
} }
System.IO.File.WriteAllText( System.IO.File.WriteAllText(
"deck/" + deckInUse + ".ydk", "deck/" + deckInUse + ".ydk",
value, sb.ToString(),
System.Text.Encoding.UTF8 System.Text.Encoding.UTF8
); );
} }
...@@ -1292,7 +1296,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1292,7 +1296,7 @@ public class DeckManager : ServantWithCardDescription
return UIPopupList_pack.value; return UIPopupList_pack.value;
} }
// [新增] 封装的添加卡片副本的逻辑,用于复用 // 封装的添加卡片副本的逻辑,用于复用
private void AddCopyToDeck(MonoCardInDeckManager sourceCard) private void AddCopyToDeck(MonoCardInDeckManager sourceCard)
{ {
// 安全检查:如果不在编辑模式,或卡片已满编,则不执行任何操作 // 安全检查:如果不在编辑模式,或卡片已满编,则不执行任何操作
...@@ -1311,6 +1315,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1311,6 +1315,7 @@ public class DeckManager : ServantWithCardDescription
deckDirty = true; deckDirty = true;
ArrangeObjectDeck(true); // 重新整理数据 ArrangeObjectDeck(true); // 重新整理数据
ShowObjectDeck(); // 重新排列场上的卡片 ShowObjectDeck(); // 重新排列场上的卡片
UpdateDeckCounts(); // 事件驱动更新UI
} }
#endregion #endregion
...@@ -1512,29 +1517,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1512,29 +1517,7 @@ public class DeckManager : ServantWithCardDescription
cameraDistance * Mathf.Sin(3.1415926f / 180f * cameraAngle), cameraDistance * Mathf.Sin(3.1415926f / 180f * cameraAngle),
-cameraDistance * Mathf.Cos(3.1415926f / 180f * cameraAngle) -cameraDistance * Mathf.Cos(3.1415926f / 180f * cameraAngle)
); );
if (Program.TimePassed() - lastRefreshTime > 80)
{
lastRefreshTime = Program.TimePassed();
FromObjectDeckToCodedDeck();
main_unmber.set_number(deck.Main.Count, 3);
side_number.set_number(deck.Side.Count, 4);
extra_unmber.set_number(deck.Extra.Count, 0);
int m = 0,
s = 0,
t = 0;
foreach (var item in deck.IMain)
{
if ((item.cardData.Type & (int)CardType.Monster) > 0)
m++;
if ((item.cardData.Type & (int)CardType.Spell) > 0)
s++;
if ((item.cardData.Type & (int)CardType.Trap) > 0)
t++;
}
m_unmber.set_number(m, 1);
s_number.set_number(s, 2);
t_unmber.set_number(t, 5);
}
if (Program.InputEnterDown) if (Program.InputEnterDown)
{ {
if (condition == Condition.editDeck) if (condition == Condition.editDeck)
...@@ -1548,6 +1531,30 @@ public class DeckManager : ServantWithCardDescription ...@@ -1548,6 +1531,30 @@ public class DeckManager : ServantWithCardDescription
} }
} }
// 独立的卡组数量更新方法,在卡片增删时调用
public void UpdateDeckCounts()
{
FromObjectDeckToCodedDeck();
main_unmber.set_number(deck.Main.Count, 3);
side_number.set_number(deck.Side.Count, 4);
extra_unmber.set_number(deck.Extra.Count, 0);
int m = 0,
s = 0,
t = 0;
foreach (var item in deck.IMain)
{
if ((item.cardData.Type & (int)CardType.Monster) > 0)
m++;
if ((item.cardData.Type & (int)CardType.Spell) > 0)
s++;
if ((item.cardData.Type & (int)CardType.Trap) > 0)
t++;
}
m_unmber.set_number(m, 1);
s_number.set_number(s, 2);
t_unmber.set_number(t, 5);
}
private void camrem() private void camrem()
{ {
float l = Program.I().cardDescription.width + ((float)Screen.width) * 0.03f; float l = Program.I().cardDescription.width + ((float)Screen.width) * 0.03f;
...@@ -1593,7 +1600,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1593,7 +1600,7 @@ public class DeckManager : ServantWithCardDescription
cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>(); cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>();
if (cardInDeck != null && !cardInDeck.dying) if (cardInDeck != null && !cardInDeck.dying)
{ {
// [修改] 初始化长按/拖拽状态 // 初始化长按/拖拽状态
cardForLongPress = cardInDeck; cardForLongPress = cardInDeck;
pressStartTime = Time.time; pressStartTime = Time.time;
isContinuouslyAdding = false; // 每次按下都重置持续添加状态 isContinuouslyAdding = false; // 每次按下都重置持续添加状态
...@@ -1614,6 +1621,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1614,6 +1621,7 @@ public class DeckManager : ServantWithCardDescription
deck.IMain.Add(card); deck.IMain.Add(card);
cardInDragging = card; cardInDragging = card;
card.beginDrag(); card.beginDrag();
UpdateDeckCounts(); // 事件驱动更新UI
} }
} }
} }
...@@ -1639,6 +1647,8 @@ public class DeckManager : ServantWithCardDescription ...@@ -1639,6 +1647,8 @@ public class DeckManager : ServantWithCardDescription
// 第四步:更新卡片在场景中的位置与角度(含Tween) // 第四步:更新卡片在场景中的位置与角度(含Tween)
ShowObjectDeck(); ShowObjectDeck();
UpdateDeckCounts(); // 事件驱动更新UI
// 第五步:清除引用 // 第五步:清除引用
cardInDragging = null; cardInDragging = null;
} }
...@@ -1648,63 +1658,61 @@ public class DeckManager : ServantWithCardDescription ...@@ -1648,63 +1658,61 @@ public class DeckManager : ServantWithCardDescription
public override void ES_mouseUpRight() public override void ES_mouseUpRight()
{ {
if (Program.pointedGameObject != null) if (Program.pointedGameObject == null)
return;
bool deckChanged = false;
if (condition == Condition.editDeck)
{ {
if (condition == Condition.editDeck) MonoCardInDeckManager cardInDeck =
Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (cardInDeck != null)
{ {
MonoCardInDeckManager cardInDeck = cardInDeck.killIt(); // 标记为待删除
Program.pointedGameObject.GetComponent<MonoCardInDeckManager>(); // 从数据结构中移除
if (cardInDeck != null) deck.IMain.Remove(cardInDeck);
{ deck.IExtra.Remove(cardInDeck);
cardInDeck.killIt(); deck.ISide.Remove(cardInDeck);
ArrangeObjectDeck(true); deckChanged = true;
ShowObjectDeck();
}
cardPicLoader cardInSearchResult =
Program.pointedGameObject.GetComponent<cardPicLoader>();
if (cardInSearchResult != null)
{
CreateMonoCard(cardInSearchResult.data);
ShowObjectDeck();
}
} }
else cardPicLoader cardInSearchResult =
Program.pointedGameObject.GetComponent<cardPicLoader>();
if (cardInSearchResult != null)
{ {
MonoCardInDeckManager cardInDeck = CreateMonoCard(cardInSearchResult.data);
Program.pointedGameObject.GetComponent<MonoCardInDeckManager>(); deckChanged = true;
if (cardInDeck != null) }
}
else
{
MonoCardInDeckManager cardInDeck =
Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (cardInDeck != null)
{
if (deck.ISide.Contains(cardInDeck))
{ {
bool isSide = false; deck.ISide.Remove(cardInDeck);
for (int i = 0; i < deck.ISide.Count; i++) if (cardInDeck.cardData.IsExtraCard())
{ deck.IExtra.Add(cardInDeck);
if (cardInDeck == deck.ISide[i])
{
isSide = true;
}
}
if (isSide)
{
if (cardInDeck.cardData.IsExtraCard())
{
deck.IExtra.Add(cardInDeck);
deck.ISide.Remove(cardInDeck);
}
else
{
deck.IMain.Add(cardInDeck);
deck.ISide.Remove(cardInDeck);
}
}
else else
{ deck.IMain.Add(cardInDeck);
deck.ISide.Add(cardInDeck); }
deck.IMain.Remove(cardInDeck); else
deck.IExtra.Remove(cardInDeck); {
} deck.IMain.Remove(cardInDeck);
ShowObjectDeck(); deck.IExtra.Remove(cardInDeck);
deck.ISide.Add(cardInDeck);
} }
deckChanged = true;
} }
} }
if (deckChanged)
{
ArrangeObjectDeck(true);
ShowObjectDeck();
UpdateDeckCounts(); // 事件驱动更新UI
}
} }
private void CreateMonoCard(YGOSharp.Card data) private void CreateMonoCard(YGOSharp.Card data)
...@@ -1726,6 +1734,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1726,6 +1734,7 @@ public class DeckManager : ServantWithCardDescription
deck.Main.Add(card.cardData.Id); deck.Main.Add(card.cardData.Id);
} }
deckDirty = true; deckDirty = true;
UpdateDeckCounts(); // [优化] 事件驱动更新UI
} }
} }
......
...@@ -32,16 +32,16 @@ public class selectReplay : WindowServantSP ...@@ -32,16 +32,16 @@ public class selectReplay : WindowServantSP
void onValue() void onValue()
{ {
RMSshow_yesOrNo( RMSshow_yesOrNo(
"onValue", "onValue",
InterString.Get("您确定要删除所有未命名的录像?"), InterString.Get("您确定要删除所有未命名的录像?"),
new messageSystemValue { hint = "yes", value = "yes" }, new messageSystemValue { hint = "yes", value = "yes" },
new messageSystemValue { hint = "no", value = "no" }); new messageSystemValue { hint = "no", value = "no" }
);
} }
private void setSortLable() private void setSortLable()
{ {
if (Config.Get(sort,"1") == "1") if (Config.Get(sort, "1") == "1")
{ {
UIHelper.trySetLableText(gameObject, "sort_", InterString.Get("时间排序")); UIHelper.trySetLableText(gameObject, "sort_", InterString.Get("时间排序"));
} }
...@@ -66,7 +66,7 @@ public class selectReplay : WindowServantSP ...@@ -66,7 +66,7 @@ public class selectReplay : WindowServantSP
PrecyOcg precy; PrecyOcg precy;
private void onGod() private void onGod()
{ {
if (!superScrollView.Selected()) if (!superScrollView.Selected())
{ {
...@@ -76,12 +76,12 @@ public class selectReplay : WindowServantSP ...@@ -76,12 +76,12 @@ public class selectReplay : WindowServantSP
{ {
return; return;
} }
KF_replay(superScrollView.selectedString,true); KF_replay(superScrollView.selectedString, true);
} }
private void onSort() private void onSort()
{ {
if (Config.Get(sort,"1") == "1") if (Config.Get(sort, "1") == "1")
{ {
Config.Set(sort, "0"); Config.Set(sort, "0");
} }
...@@ -105,7 +105,11 @@ public class selectReplay : WindowServantSP ...@@ -105,7 +105,11 @@ public class selectReplay : WindowServantSP
if (name.Length > 4 && name.Substring(name.Length - 4, 4) == ".yrp") if (name.Length > 4 && name.Substring(name.Length - 4, 4) == ".yrp")
{ {
opYRP = true; opYRP = true;
RMSshow_input("onRename", InterString.Get("请输入重命名后的录像名"), name.Substring(0, name.Length - 4)); RMSshow_input(
"onRename",
InterString.Get("请输入重命名后的录像名"),
name.Substring(0, name.Length - 4)
);
} }
else else
{ {
...@@ -121,11 +125,11 @@ public class selectReplay : WindowServantSP ...@@ -121,11 +125,11 @@ public class selectReplay : WindowServantSP
return; return;
} }
RMSshow_yesOrNo( RMSshow_yesOrNo(
"onDelete", "onDelete",
InterString.Get("删除[?],@n请确认。", InterString.Get("删除[?],@n请确认。", superScrollView.selectedString),
superScrollView.selectedString), new messageSystemValue { hint = "yes", value = "yes" },
new messageSystemValue { hint = "yes", value = "yes" }, new messageSystemValue { hint = "no", value = "no" }
new messageSystemValue { hint = "no", value = "no" }); );
} }
byte[] getYRPbuffer(string path) byte[] getYRPbuffer(string path)
...@@ -146,9 +150,8 @@ public class selectReplay : WindowServantSP ...@@ -146,9 +150,8 @@ public class selectReplay : WindowServantSP
break; break;
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Log(e); Debug.Log(e);
} }
...@@ -168,20 +171,26 @@ public class selectReplay : WindowServantSP ...@@ -168,20 +171,26 @@ public class selectReplay : WindowServantSP
try try
{ {
BinaryReader reader = new BinaryReader(new MemoryStream(buffer)); BinaryReader reader = new BinaryReader(new MemoryStream(buffer));
returnValue.ID= reader.ReadInt32(); returnValue.ID = reader.ReadInt32();
returnValue.Version= reader.ReadInt32(); returnValue.Version = reader.ReadInt32();
returnValue.Flag= reader.ReadInt32(); returnValue.Flag = reader.ReadInt32();
returnValue.Seed= reader.ReadUInt32(); returnValue.Seed = reader.ReadUInt32();
returnValue.DataSize = reader.ReadInt32(); returnValue.DataSize = reader.ReadInt32();
returnValue.Hash = reader.ReadInt32(); returnValue.Hash = reader.ReadInt32();
returnValue.Props= reader.ReadBytes(8); returnValue.Props = reader.ReadBytes(8);
byte[] raw = reader.ReadToEnd(); byte[] raw = reader.ReadToEnd();
if ((returnValue.Flag & 0x1) > 0) if ((returnValue.Flag & 0x1) > 0)
{ {
SevenZip.Compression.LZMA.Decoder lzma = new SevenZip.Compression.LZMA.Decoder(); SevenZip.Compression.LZMA.Decoder lzma = new SevenZip.Compression.LZMA.Decoder();
lzma.SetDecoderProperties(returnValue.Props); lzma.SetDecoderProperties(returnValue.Props);
MemoryStream decompressed = new MemoryStream(); MemoryStream decompressed = new MemoryStream();
lzma.Code(new MemoryStream(raw), decompressed, raw.LongLength, returnValue.DataSize, null); lzma.Code(
new MemoryStream(raw),
decompressed,
raw.LongLength,
returnValue.DataSize,
null
);
raw = decompressed.ToArray(); raw = decompressed.ToArray();
} }
reader = new BinaryReader(new MemoryStream(raw)); reader = new BinaryReader(new MemoryStream(raw));
...@@ -252,7 +261,7 @@ public class selectReplay : WindowServantSP ...@@ -252,7 +261,7 @@ public class selectReplay : WindowServantSP
return returnValue; return returnValue;
} }
private void onYdk() private void onYdk()
{ {
if (!superScrollView.Selected()) if (!superScrollView.Selected())
{ {
...@@ -261,7 +270,7 @@ public class selectReplay : WindowServantSP ...@@ -261,7 +270,7 @@ public class selectReplay : WindowServantSP
try try
{ {
Percy.YRP yrp; Percy.YRP yrp;
if (File.Exists("replay/" + superScrollView.selectedString)) if (File.Exists("replay/" + superScrollView.selectedString))
{ {
yrp = getYRP(File.ReadAllBytes("replay/" + superScrollView.selectedString)); yrp = getYRP(File.ReadAllBytes("replay/" + superScrollView.selectedString));
} }
...@@ -269,7 +278,7 @@ public class selectReplay : WindowServantSP ...@@ -269,7 +278,7 @@ public class selectReplay : WindowServantSP
{ {
yrp = getYRP(getYRPbuffer("replay/" + superScrollView.selectedString + ".yrp3d")); yrp = getYRP(getYRPbuffer("replay/" + superScrollView.selectedString + ".yrp3d"));
} }
for (int i = 0; i < yrp.playerData.Count; i++) for (int i = 0; i < yrp.playerData.Count; i++)
{ {
string value = "#created by ygopro2\r\n#main\r\n"; string value = "#created by ygopro2\r\n#main\r\n";
for (int i2 = 0; i2 < yrp.playerData[i].main.Count; i2++) for (int i2 = 0; i2 < yrp.playerData[i].main.Count; i2++)
...@@ -281,7 +290,8 @@ public class selectReplay : WindowServantSP ...@@ -281,7 +290,8 @@ public class selectReplay : WindowServantSP
{ {
value += yrp.playerData[i].extra[i2].ToString() + "\r\n"; value += yrp.playerData[i].extra[i2].ToString() + "\r\n";
} }
string name = "deck/" + superScrollView.selectedString + "_" + (i + 1).ToString() + ".ydk"; string name =
"deck/" + superScrollView.selectedString + "_" + (i + 1).ToString() + ".ydk";
File.WriteAllText(name, value); File.WriteAllText(name, value);
RMSshow_none(InterString.Get("卡组入库:[?]", name)); RMSshow_none(InterString.Get("卡组入库:[?]", name));
} }
...@@ -304,10 +314,18 @@ public class selectReplay : WindowServantSP ...@@ -304,10 +314,18 @@ public class selectReplay : WindowServantSP
} }
try try
{ {
if (File.Exists("replay/" + superScrollView.selectedString + ".yrp3d")) if (File.Exists("replay/" + superScrollView.selectedString + ".yrp3d"))
{ {
File.WriteAllBytes("replay/" + superScrollView.selectedString + ".yrp", getYRPbuffer("replay/" + superScrollView.selectedString + ".yrp3d")); File.WriteAllBytes(
RMSshow_none(InterString.Get("录像入库:[?]", "replay/" + superScrollView.selectedString + ".yrp")); "replay/" + superScrollView.selectedString + ".yrp",
getYRPbuffer("replay/" + superScrollView.selectedString + ".yrp3d")
);
RMSshow_none(
InterString.Get(
"录像入库:[?]",
"replay/" + superScrollView.selectedString + ".yrp"
)
);
printFile(); printFile();
} }
else else
...@@ -330,12 +348,17 @@ public class selectReplay : WindowServantSP ...@@ -330,12 +348,17 @@ public class selectReplay : WindowServantSP
{ {
if (opYRP) if (opYRP)
{ {
System.IO.File.Move("replay/" + superScrollView.selectedString, "replay/" + result[0].value + ".yrp"); System.IO.File.Move(
"replay/" + superScrollView.selectedString,
}else "replay/" + result[0].value + ".yrp"
);
}
else
{ {
System.IO.File.Move("replay/" + superScrollView.selectedString + ".yrp3d", "replay/" + result[0].value + ".yrp3d"); System.IO.File.Move(
"replay/" + superScrollView.selectedString + ".yrp3d",
"replay/" + result[0].value + ".yrp3d"
);
} }
printFile(); printFile();
RMSshow_none(InterString.Get("重命名成功。")); RMSshow_none(InterString.Get("重命名成功。"));
...@@ -353,20 +376,24 @@ public class selectReplay : WindowServantSP ...@@ -353,20 +376,24 @@ public class selectReplay : WindowServantSP
{ {
if (File.Exists("replay/" + superScrollView.selectedString + ".yrp3d")) if (File.Exists("replay/" + superScrollView.selectedString + ".yrp3d"))
{ {
System.IO.File.Delete("replay/" + superScrollView.selectedString + ".yrp3d"); System.IO.File.Delete(
RMSshow_none(InterString.Get("[?]已经被删除。", superScrollView.selectedString)); "replay/" + superScrollView.selectedString + ".yrp3d"
);
RMSshow_none(
InterString.Get("[?]已经被删除。", superScrollView.selectedString)
);
printFile(); printFile();
} }
if (File.Exists("replay/" + superScrollView.selectedString)) if (File.Exists("replay/" + superScrollView.selectedString))
{ {
System.IO.File.Delete("replay/" + superScrollView.selectedString); System.IO.File.Delete("replay/" + superScrollView.selectedString);
RMSshow_none(InterString.Get("[?]已经被删除。", superScrollView.selectedString)); RMSshow_none(
InterString.Get("[?]已经被删除。", superScrollView.selectedString)
);
printFile(); printFile();
} }
} }
catch (Exception) catch (Exception) { }
{
}
} }
} }
if (hashCode == "onValue") if (hashCode == "onValue")
...@@ -388,9 +415,7 @@ public class selectReplay : WindowServantSP ...@@ -388,9 +415,7 @@ public class selectReplay : WindowServantSP
{ {
File.Delete("replay/" + fileInfos[i].Name); File.Delete("replay/" + fileInfos[i].Name);
} }
catch (Exception) catch (Exception) { }
{
}
} }
} }
} }
...@@ -402,10 +427,11 @@ public class selectReplay : WindowServantSP ...@@ -402,10 +427,11 @@ public class selectReplay : WindowServantSP
} }
} }
string selectedTrace = ""; string selectedTrace = "";
void onSelected() void onSelected()
{ {
if (selectedTrace == superScrollView.selectedString) if (selectedTrace == superScrollView.selectedString)
{ {
KF_replay(selectedTrace); KF_replay(selectedTrace);
} }
...@@ -426,11 +452,17 @@ public class selectReplay : WindowServantSP ...@@ -426,11 +452,17 @@ public class selectReplay : WindowServantSP
{ {
if (god) if (god)
{ {
RMSshow_none(InterString.Get("您正在观看旧版的录像(上帝视角),不保证稳定性。")); RMSshow_none(
InterString.Get("您正在观看旧版的录像(上帝视角),不保证稳定性。")
);
if (precy != null) if (precy != null)
precy.dispose(); precy.dispose();
precy = new PrecyOcg(); precy = new PrecyOcg();
var collections = TcpHelper.getPackages(precy.ygopro.getYRP3dBuffer(getYRP(getYRPbuffer("replay/" + name + ".yrp3d")))); var collections = TcpHelper.getPackages(
precy.ygopro.getYRP3dBuffer(
getYRP(getYRPbuffer("replay/" + name + ".yrp3d"))
)
);
pushCollection(collections); pushCollection(collections);
} }
else else
...@@ -441,21 +473,25 @@ public class selectReplay : WindowServantSP ...@@ -441,21 +473,25 @@ public class selectReplay : WindowServantSP
} }
else else
{ {
if (name.Length>4&&name.Substring(name.Length - 4, 4) == ".yrp") if (name.Length > 4 && name.Substring(name.Length - 4, 4) == ".yrp")
{ {
if (File.Exists("replay/" + name)) if (File.Exists("replay/" + name))
{ {
RMSshow_none(InterString.Get("您正在观看旧版的录像(上帝视角),不保证稳定性。")); RMSshow_none(
InterString.Get("您正在观看旧版的录像(上帝视角),不保证稳定性。")
);
if (precy != null) if (precy != null)
precy.dispose(); precy.dispose();
precy = new PrecyOcg(); precy = new PrecyOcg();
var collections = TcpHelper.getPackages(precy.ygopro.getYRP3dBuffer(getYRP(File.ReadAllBytes("replay/" + name)))); var collections = TcpHelper.getPackages(
precy.ygopro.getYRP3dBuffer(getYRP(File.ReadAllBytes("replay/" + name)))
);
pushCollection(collections); pushCollection(collections);
} }
} }
} }
} }
catch (Exception) catch (Exception)
{ {
RMSshow_none(InterString.Get("录像没有录制完整。")); RMSshow_none(InterString.Get("录像没有录制完整。"));
} }
...@@ -502,11 +538,19 @@ public class selectReplay : WindowServantSP ...@@ -502,11 +538,19 @@ public class selectReplay : WindowServantSP
{ {
if (fileInfos[i].Name.Length > 6) if (fileInfos[i].Name.Length > 6)
{ {
if (fileInfos[i].Name.Length > 6 && fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 6, 6) == ".yrp3d") if (
fileInfos[i].Name.Length > 6
&& fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 6, 6) == ".yrp3d"
)
{ {
superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 6)); superScrollView.add(
fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 6)
);
} }
if (fileInfos[i].Name.Length > 4 && fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".yrp") if (
fileInfos[i].Name.Length > 4
&& fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".yrp"
)
{ {
superScrollView.add(fileInfos[i].Name); superScrollView.add(fileInfos[i].Name);
} }
...@@ -518,5 +562,4 @@ public class selectReplay : WindowServantSP ...@@ -518,5 +562,4 @@ public class selectReplay : WindowServantSP
{ {
Program.I().shiftToServant(Program.I().menu); Program.I().shiftToServant(Program.I().menu);
} }
} }
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