Commit 4484c872 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro into develop

parents 296b22a8 c3e25993
...@@ -218,6 +218,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -218,6 +218,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_LOAD_REPLAY: { case BUTTON_LOAD_REPLAY: {
int start_turn = 1;
if(open_file) { if(open_file) {
ReplayMode::cur_replay.OpenReplay(open_file_name); ReplayMode::cur_replay.OpenReplay(open_file_name);
open_file = false; open_file = false;
...@@ -229,6 +230,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -229,6 +230,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
myswprintf(replay_path, L"./replay/%ls", mainGame->lstReplayList->getListItem(selected)); myswprintf(replay_path, L"./replay/%ls", mainGame->lstReplayList->getListItem(selected));
if (!ReplayMode::cur_replay.OpenReplay(replay_path)) if (!ReplayMode::cur_replay.OpenReplay(replay_path))
break; break;
start_turn = std::wcstol(mainGame->ebRepStartTurn->getText(), nullptr, 10);
} }
mainGame->ClearCardInfo(); mainGame->ClearCardInfo();
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
...@@ -243,7 +245,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -243,7 +245,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->HideElement(mainGame->wReplay); mainGame->HideElement(mainGame->wReplay);
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
unsigned int start_turn = std::wcstol(mainGame->ebRepStartTurn->getText(), nullptr, 10);
if(start_turn == 1) if(start_turn == 1)
start_turn = 0; start_turn = 0;
ReplayMode::StartReplay(start_turn); ReplayMode::StartReplay(start_turn);
...@@ -516,27 +517,27 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -516,27 +517,27 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
wchar_t replay_path[256]{}; wchar_t replay_path[256]{};
myswprintf(replay_path, L"./replay/%ls", mainGame->lstReplayList->getListItem(sel)); myswprintf(replay_path, L"./replay/%ls", mainGame->lstReplayList->getListItem(sel));
if (!ReplayMode::cur_replay.OpenReplay(replay_path)) { if (!temp_replay.OpenReplay(replay_path)) {
mainGame->stReplayInfo->setText(L"Error"); mainGame->stReplayInfo->setText(L"Error");
break; break;
} }
wchar_t infobuf[256]{}; wchar_t infobuf[256]{};
std::wstring repinfo; std::wstring repinfo;
time_t curtime; time_t curtime;
if(ReplayMode::cur_replay.pheader.flag & REPLAY_UNIFORM) if(temp_replay.pheader.flag & REPLAY_UNIFORM)
curtime = ReplayMode::cur_replay.pheader.start_time; curtime = temp_replay.pheader.start_time;
else else
curtime = ReplayMode::cur_replay.pheader.seed; curtime = temp_replay.pheader.seed;
std::wcsftime(infobuf, sizeof infobuf / sizeof infobuf[0], L"%Y/%m/%d %H:%M:%S\n", std::localtime(&curtime)); std::wcsftime(infobuf, sizeof infobuf / sizeof infobuf[0], L"%Y/%m/%d %H:%M:%S\n", std::localtime(&curtime));
repinfo.append(infobuf); repinfo.append(infobuf);
if (ReplayMode::cur_replay.pheader.flag & REPLAY_SINGLE_MODE) { if (temp_replay.pheader.flag & REPLAY_SINGLE_MODE) {
wchar_t path[256]{}; wchar_t path[256]{};
BufferIO::DecodeUTF8(ReplayMode::cur_replay.script_name.c_str(), path); BufferIO::DecodeUTF8(temp_replay.script_name.c_str(), path);
repinfo.append(path); repinfo.append(path);
repinfo.append(L"\n"); repinfo.append(L"\n");
} }
const auto& player_names = ReplayMode::cur_replay.players; const auto& player_names = temp_replay.players;
if(ReplayMode::cur_replay.pheader.flag & REPLAY_TAG) if(temp_replay.pheader.flag & REPLAY_TAG)
myswprintf(infobuf, L"%ls\n%ls\n===VS===\n%ls\n%ls\n", player_names[0].c_str(), player_names[1].c_str(), player_names[2].c_str(), player_names[3].c_str()); myswprintf(infobuf, L"%ls\n%ls\n===VS===\n%ls\n%ls\n", player_names[0].c_str(), player_names[1].c_str(), player_names[2].c_str(), player_names[3].c_str());
else else
myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", player_names[0].c_str(), player_names[1].c_str()); myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", player_names[0].c_str(), player_names[1].c_str());
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define MENU_HANDLER_H #define MENU_HANDLER_H
#include <irrlicht.h> #include <irrlicht.h>
#include "replay.h"
namespace ygo { namespace ygo {
...@@ -10,7 +11,7 @@ public: ...@@ -10,7 +11,7 @@ public:
bool OnEvent(const irr::SEvent& event) override; bool OnEvent(const irr::SEvent& event) override;
irr::s32 prev_operation{ 0 }; irr::s32 prev_operation{ 0 };
int prev_sel{ -1 }; int prev_sel{ -1 };
Replay temp_replay;
}; };
} }
......
...@@ -227,8 +227,12 @@ void Replay::Reset() { ...@@ -227,8 +227,12 @@ void Replay::Reset() {
script_name.clear(); script_name.clear();
} }
void Replay::SkipInfo(){ void Replay::SkipInfo(){
if (data_position == 0)
data_position += info_offset; data_position += info_offset;
} }
bool Replay::IsReplaying() const {
return is_replaying;
}
bool Replay::ReadInfo() { bool Replay::ReadInfo() {
int player_count = (pheader.flag & REPLAY_TAG) ? 4 : 2; int player_count = (pheader.flag & REPLAY_TAG) ? 4 : 2;
for (int i = 0; i < player_count; ++i) { for (int i = 0; i < player_count; ++i) {
......
...@@ -81,6 +81,7 @@ public: ...@@ -81,6 +81,7 @@ public:
void Rewind(); void Rewind();
void Reset(); void Reset();
void SkipInfo(); void SkipInfo();
bool IsReplaying() const;
FILE* fp{ nullptr }; FILE* fp{ nullptr };
#ifdef _WIN32 #ifdef _WIN32
......
...@@ -25,7 +25,6 @@ private: ...@@ -25,7 +25,6 @@ private:
public: public:
static Replay cur_replay; static Replay cur_replay;
public:
static bool StartReplay(int skipturn); static bool StartReplay(int skipturn);
static void StopReplay(bool is_exiting = false); static void StopReplay(bool is_exiting = false);
static void SwapField(); static void SwapField();
......
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