Commit 865004d8 authored by mercury233's avatar mercury233

only ask saving deck when deck changed

parent 5bfb16ff
...@@ -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);
}
}; };
} }
} }
......
...@@ -286,6 +286,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -286,6 +286,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;
} }
...@@ -352,6 +353,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -352,6 +353,7 @@ public class DeckManager : ServantWithCardDescription
Debug.Log(e); Debug.Log(e);
} }
} }
deckDirty = true;
} }
bool detailShowed = false; bool detailShowed = false;
...@@ -1135,6 +1137,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1135,6 +1137,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();
} }
...@@ -1263,6 +1266,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1263,6 +1266,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();
} }
...@@ -1287,6 +1291,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1287,6 +1291,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();
} }
...@@ -1305,6 +1310,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1305,6 +1310,7 @@ public class DeckManager : ServantWithCardDescription
} }
else else
{ {
deckDirty = true;
ArrangeObjectDeck(true); ArrangeObjectDeck(true);
ShowObjectDeck(); ShowObjectDeck();
} }
...@@ -1372,8 +1378,9 @@ public class DeckManager : ServantWithCardDescription ...@@ -1372,8 +1378,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();
} }
} }
} }
...@@ -1404,16 +1411,19 @@ public class DeckManager : ServantWithCardDescription ...@@ -1404,16 +1411,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)
...@@ -1606,11 +1616,13 @@ public class DeckManager : ServantWithCardDescription ...@@ -1606,11 +1616,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