Commit f1cc78ac authored by mercury233's avatar mercury233 Committed by Unicorn369

only ask saving deck when deck changed

parent 2256817d
...@@ -89,6 +89,8 @@ public class selectDeck : WindowServantSP ...@@ -89,6 +89,8 @@ public class selectDeck : WindowServantSP
((DeckManager)Program.I().deckManager).returnAction = ((DeckManager)Program.I().deckManager).returnAction =
() => () =>
{ {
if (((DeckManager)Program.I().deckManager).deckDirty)
{
RMSshow_yesOrNoOrCancle( RMSshow_yesOrNoOrCancle(
"deckManager_returnAction" "deckManager_returnAction"
, InterString.Get("要保存卡组的变更吗?") , InterString.Get("要保存卡组的变更吗?")
...@@ -96,6 +98,10 @@ public class selectDeck : WindowServantSP ...@@ -96,6 +98,10 @@ public class selectDeck : WindowServantSP
, new messageSystemValue { hint = "no", value = "no" } , new messageSystemValue { hint = "no", value = "no" }
, new messageSystemValue { hint = "cancle", value = "cancle" } , new messageSystemValue { hint = "cancle", value = "cancle" }
); );
}
else {
Program.I().shiftToServant(Program.I().selectDeck);
}
}; };
} }
} }
......
...@@ -291,6 +291,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -291,6 +291,7 @@ public class DeckManager : ServantWithCardDescription
} }
System.IO.File.WriteAllText("deck/" + deckInUse + ".ydk", value, System.Text.Encoding.UTF8); System.IO.File.WriteAllText("deck/" + deckInUse + ".ydk", value, System.Text.Encoding.UTF8);
} }
deckDirty = false;
RMSshow_none(InterString.Get("卡组[?]已经被保存。", deckInUse)); RMSshow_none(InterString.Get("卡组[?]已经被保存。", deckInUse));
return true; return true;
} }
...@@ -358,6 +359,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -358,6 +359,7 @@ public class DeckManager : ServantWithCardDescription
Debug.Log(e); Debug.Log(e);
} }
} }
deckDirty = true;
} }
bool detailShowed = false; bool detailShowed = false;
...@@ -1164,6 +1166,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1164,6 +1166,7 @@ public class DeckManager : ServantWithCardDescription
destroyCard(deck.IRemoved[i]); destroyCard(deck.IRemoved[i]);
} }
deck = new YGOSharp.Deck(); deck = new YGOSharp.Deck();
deckDirty = false;
((CardDescription)Program.I().cardDescription).setTitle(""); ((CardDescription)Program.I().cardDescription).setTitle("");
base.hide(); base.hide();
} }
...@@ -1292,6 +1295,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1292,6 +1295,7 @@ public class DeckManager : ServantWithCardDescription
MonoCardInDeckManager_.cardData.cloneTo(card.cardData); MonoCardInDeckManager_.cardData.cloneTo(card.cardData);
card.gameObject.layer = 16; card.gameObject.layer = 16;
deck.IMain.Add(card); deck.IMain.Add(card);
deckDirty = true;
ArrangeObjectDeck(true); ArrangeObjectDeck(true);
ShowObjectDeck(); ShowObjectDeck();
} }
...@@ -1316,6 +1320,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1316,6 +1320,7 @@ public class DeckManager : ServantWithCardDescription
card.cardData = cardPicLoader_.data; card.cardData = cardPicLoader_.data;
card.gameObject.layer = 16; card.gameObject.layer = 16;
deck.IMain.Add(card); deck.IMain.Add(card);
deckDirty = true;
cardInDragging = card; cardInDragging = card;
card.beginDrag(); card.beginDrag();
} }
...@@ -1334,6 +1339,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1334,6 +1339,7 @@ public class DeckManager : ServantWithCardDescription
} }
else else
{ {
deckDirty = true;
ArrangeObjectDeck(true); ArrangeObjectDeck(true);
ShowObjectDeck(); ShowObjectDeck();
} }
...@@ -1401,8 +1407,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -1401,8 +1407,9 @@ public class DeckManager : ServantWithCardDescription
deck.ISide.Add(MonoCardInDeckManager_); deck.ISide.Add(MonoCardInDeckManager_);
deck.IMain.Remove(MonoCardInDeckManager_); deck.IMain.Remove(MonoCardInDeckManager_);
deck.IExtra.Remove(MonoCardInDeckManager_); deck.IExtra.Remove(MonoCardInDeckManager_);
} }
ShowObjectDeck(); deckDirty = true;
ShowObjectDeck();
} }
} }
} }
...@@ -1438,16 +1445,19 @@ public class DeckManager : ServantWithCardDescription ...@@ -1438,16 +1445,19 @@ public class DeckManager : ServantWithCardDescription
{ {
deck.IMain.Add(card); deck.IMain.Add(card);
deck.Main.Add(card.cardData.Id); deck.Main.Add(card.cardData.Id);
} }
deckDirty = true;
} }
} }
public YGOSharp.Deck deck = new YGOSharp.Deck(); public YGOSharp.Deck deck = new YGOSharp.Deck();
public bool deckDirty = false;
public void loadDeckFromYDK(string path) public void loadDeckFromYDK(string path)
{ {
FromYDKtoCodedDeck(path, out deck); FromYDKtoCodedDeck(path, out deck);
FormCodedDeckToObjectDeck(); FormCodedDeckToObjectDeck();
deckDirty = false;
} }
public static void FromYDKtoCodedDeck(string path, out YGOSharp.Deck deck) public static void FromYDKtoCodedDeck(string path, out YGOSharp.Deck deck)
...@@ -1647,11 +1657,13 @@ public class DeckManager : ServantWithCardDescription ...@@ -1647,11 +1657,13 @@ public class DeckManager : ServantWithCardDescription
YGOSharp.Deck.sort((List<MonoCardInDeckManager>)deck.IMain); YGOSharp.Deck.sort((List<MonoCardInDeckManager>)deck.IMain);
YGOSharp.Deck.sort((List<MonoCardInDeckManager>)deck.IExtra); YGOSharp.Deck.sort((List<MonoCardInDeckManager>)deck.IExtra);
YGOSharp.Deck.sort((List<MonoCardInDeckManager>)deck.ISide); YGOSharp.Deck.sort((List<MonoCardInDeckManager>)deck.ISide);
deckDirty = true;
} }
void RandObjectDeck() void RandObjectDeck()
{ {
YGOSharp.Deck.rand((List<MonoCardInDeckManager>)deck.IMain); YGOSharp.Deck.rand((List<MonoCardInDeckManager>)deck.IMain);
deckDirty = true;
} }
......
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