Commit f8ad44e6 authored by nanahira's avatar nanahira

Merge branch 'param-deck-category' of /home/nanahira/ygo/versions/ygopro-yuzu

parents 55ed1e12 324a1b5c
......@@ -93,6 +93,7 @@ extern bool exit_on_return;
extern bool auto_watch_mode;
extern bool open_file;
extern wchar_t open_file_name[256];
extern wchar_t open_file_name_with_category[256];
extern bool bot_mode;
#endif
......@@ -12,6 +12,7 @@ bool exit_on_return = false;
bool auto_watch_mode = false;
bool open_file = false;
wchar_t open_file_name[256] = L"";
wchar_t open_file_name_with_category[256] = L"";
bool bot_mode = false;
void ClickButton(irr::gui::IGUIElement* btn) {
......@@ -76,6 +77,7 @@ int main(int argc, char* argv[]) {
#endif //_WIN32
bool keep_on_return = false;
bool deckCategorySpecified = false;
for(int i = 1; i < wargc; ++i) {
if(wargv[i][0] == L'-' && wargv[i][1] == L'e' && wargv[i][2] != L'\0') {
ygo::dataManager.LoadDB(&wargv[i][2]);
......@@ -112,9 +114,16 @@ int main(int argc, char* argv[]) {
keep_on_return = true;
} else if(!wcscmp(wargv[i], L"--auto-watch")) { // Auto watch mode
auto_watch_mode = true;
} else if(!wcscmp(wargv[i], L"--deck-category")) {
++i;
if(i < wargc) {
deckCategorySpecified = true;
wcscpy(ygo::mainGame->gameConf.lastcategory, wargv[i]);
}
} else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i;
ygo::mainGame->gameConf.lastcategory[0] = 0;
if(!deckCategorySpecified)
ygo::mainGame->gameConf.lastcategory[0] = 0;
if(i + 1 < wargc) { // select deck
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
continue;
......@@ -123,6 +132,11 @@ int main(int argc, char* argv[]) {
if(i < wargc) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
if(deckCategorySpecified) {
swprintf(open_file_name_with_category, 256, L"%ls/%ls", ygo::mainGame->gameConf.lastcategory, open_file_name);
} else {
wcscpy(open_file_name_with_category, open_file_name);
}
}
ClickButton(ygo::mainGame->btnDeckEdit);
break;
......
......@@ -313,7 +313,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int extra = replay.ReadInt32();
for(int j = 0; j < extra; ++j)
tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32()));
myswprintf(filename, L"./deck/%ls %ls.ydk", ex_filename, namebuf[i]);
FileSystem::SafeFileName(namebuf[i]);
myswprintf(filename, L"deck/%ls-%d %ls.ydk", ex_filename, i + 1, namebuf[i]);
deckManager.SaveDeck(tmp_deck, filename);
}
mainGame->stACMessage->setText(dataManager.GetSysString(1335));
......@@ -402,7 +403,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
case BUTTON_DECK_EDIT: {
mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
if(open_file && deckManager.LoadDeck(open_file_name)) {
if(open_file && deckManager.LoadDeck(open_file_name_with_category)) {
#ifdef WIN32
wchar_t *dash = wcsrchr(open_file_name, L'\\');
#else
......
......@@ -19,6 +19,11 @@
class FileSystem {
public:
static void SafeFileName(wchar_t* wfile) {
while((wfile = wcspbrk(wfile, L"<>:\"/\\|?*")) != NULL)
*wfile++ = '_';
}
static bool IsFileExists(const wchar_t* wfile) {
DWORD attr = GetFileAttributesW(wfile);
return attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY);
......@@ -112,6 +117,11 @@ public:
class FileSystem {
public:
static void SafeFileName(wchar_t* wfile) {
while((wfile = wcspbrk(wfile, L"/")) != NULL)
*wfile++ = '_';
}
static bool IsFileExists(const char* file) {
struct stat fileStat;
return (stat(file, &fileStat) == 0) && !S_ISDIR(fileStat.st_mode);
......
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