Commit 192cb6b7 authored by salix5's avatar salix5 Committed by GitHub

Replay: add SaveDeck (#2986)

parent a07898e5
...@@ -311,7 +311,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -311,7 +311,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
for (size_t i = 0; i < replay.decks.size(); ++i) { for (size_t i = 0; i < replay.decks.size(); ++i) {
myswprintf(filename, L"./deck/%ls-%d %ls.ydk", replay_filename, i + 1, namebuf[i]); myswprintf(filename, L"./deck/%ls-%d %ls.ydk", replay_filename, i + 1, namebuf[i]);
DeckManager::SaveDeckArray(replay.decks[i], filename); replay.SaveDeck(i, filename);
} }
mainGame->stACMessage->setText(dataManager.GetSysString(1335)); mainGame->stACMessage->setText(dataManager.GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
......
...@@ -221,6 +221,14 @@ void Replay::SkipInfo(){ ...@@ -221,6 +221,14 @@ void Replay::SkipInfo(){
bool Replay::IsReplaying() const { bool Replay::IsReplaying() const {
return is_replaying; return is_replaying;
} }
bool Replay::SaveDeck(size_t index, const wchar_t* filename) {
if(index >= decks.size())
return false;
DeckArray deck = decks[index];
std::reverse(deck.main.begin(), deck.main.end());
std::reverse(deck.extra.begin(), deck.extra.end());
return DeckManager::SaveDeckArray(deck, filename);
}
bool Replay::ReadInfo() { bool Replay::ReadInfo() {
int player_count = (pheader.base.flag & REPLAY_TAG) ? 4 : 2; int player_count = (pheader.base.flag & REPLAY_TAG) ? 4 : 2;
for (int i = 0; i < player_count; ++i) { for (int i = 0; i < player_count; ++i) {
......
...@@ -96,6 +96,7 @@ public: ...@@ -96,6 +96,7 @@ public:
void Reset(); void Reset();
void SkipInfo(); void SkipInfo();
bool IsReplaying() const; bool IsReplaying() const;
bool SaveDeck(size_t index, const wchar_t* filename);
FILE* fp{ nullptr }; FILE* fp{ nullptr };
ExtendedReplayHeader pheader; ExtendedReplayHeader pheader;
......
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