diff --git a/gframe/client_field.cpp b/gframe/client_field.cpp index 7a8ea493e..dbd40728a 100644 --- a/gframe/client_field.cpp +++ b/gframe/client_field.cpp @@ -18,6 +18,7 @@ ClientField::ClientField() { hovered_card = 0; clicked_card = 0; highlighting_card = 0; + menu_card = 0; hovered_controler = 0; hovered_location = 0; hovered_sequence = 0; @@ -89,6 +90,7 @@ void ClientField::Clear() { hovered_card = 0; clicked_card = 0; highlighting_card = 0; + menu_card = 0; hovered_controler = 0; hovered_location = 0; hovered_sequence = 0; diff --git a/gframe/client_field.h b/gframe/client_field.h index 3969c837b..834856a6e 100644 --- a/gframe/client_field.h +++ b/gframe/client_field.h @@ -43,6 +43,7 @@ class ClientField: public irr::IEventReceiver { std::vector conti_cards; std::vector> activatable_descs; std::vector select_options; + std::vector select_options_index; std::vector chains; int extra_p_count[2]; @@ -138,6 +139,7 @@ class ClientField: public irr::IEventReceiver { ClientCard* clicked_card; ClientCard* command_card; ClientCard* highlighting_card; + ClientCard* menu_card; int list_command; virtual bool OnEvent(const irr::SEvent& event); diff --git a/gframe/data_manager.cpp b/gframe/data_manager.cpp index fcf1f63fe..bc66d48f1 100644 --- a/gframe/data_manager.cpp +++ b/gframe/data_manager.cpp @@ -5,13 +5,13 @@ namespace ygo { const wchar_t* DataManager::unknown_string = L"???"; -wchar_t DataManager::strBuffer[4096]; byte DataManager::scriptBuffer[0x20000]; IFileSystem* DataManager::FileSystem; DataManager dataManager; bool DataManager::LoadDB(const wchar_t* wfile) { char file[256]; + wchar_t strBuffer[4096]; BufferIO::EncodeUTF8(wfile, file); #ifdef _WIN32 IReadFile* reader = FileSystem->createAndOpenFile(wfile); @@ -118,6 +118,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) { return; char strbuf[256]; int value; + wchar_t strBuffer[4096]; sscanf(linebuf, "!%s", strbuf); if(!strcmp(strbuf, "system")) { sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf); @@ -138,6 +139,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) { } } bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) { + wchar_t strBuffer[4096]; BufferIO::DecodeUTF8(sqlite3_errmsg(pDB->handle), strBuffer); if(pStmt) sqlite3_finalize(pStmt); diff --git a/gframe/data_manager.h b/gframe/data_manager.h index ccaa58735..62da9461f 100644 --- a/gframe/data_manager.h +++ b/gframe/data_manager.h @@ -51,7 +51,6 @@ class DataManager { wchar_t scBuffer[128]; wchar_t lmBuffer[32]; - static wchar_t strBuffer[4096]; static byte scriptBuffer[0x20000]; static const wchar_t* unknown_string; static int CardReader(int, void*); diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index 2b86d9197..48fe90190 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -88,9 +88,7 @@ void DeckBuilder::Initialize() { is_starting_dragging = false; prev_deck = mainGame->cbDBDecks->getSelected(); prev_category = mainGame->cbDBCategory->getSelected(); - readonly = prev_category < 2; - mainGame->btnSaveDeck->setEnabled(!readonly); - mainGame->btnDeleteDeck->setEnabled(!readonly); + RefreshReadonly(prev_category); prev_operation = 0; prev_sel = -1; is_modified = false; diff --git a/gframe/event_handler.cpp b/gframe/event_handler.cpp index 56b720382..807a76259 100644 --- a/gframe/event_handler.cpp +++ b/gframe/event_handler.cpp @@ -313,11 +313,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) { int step = mainGame->scrOption->isVisible() ? mainGame->scrOption->getPos() : 0; selected_option = id - BUTTON_OPTION_0 + step; SetResponseSelectedOption(); + ShowCancelOrFinishButton(0); break; } case BUTTON_OPTION_OK: { soundManager.PlaySoundEffect(SOUND_BUTTON); SetResponseSelectedOption(); + ShowCancelOrFinishButton(0); break; } case BUTTON_ANNUMBER_1: @@ -372,22 +374,25 @@ bool ClientField::OnEvent(const irr::SEvent& event) { mainGame->wCmdMenu->setVisible(false); ShowCancelOrFinishButton(0); if(!list_command) { - int index = -1; + if(!menu_card) + break; select_options.clear(); + select_options_index.clear(); for (size_t i = 0; i < activatable_cards.size(); ++i) { - if (activatable_cards[i] == clicked_card) { + if (activatable_cards[i] == menu_card) { if(activatable_descs[i].second == EDESC_OPERATION) continue; - if(activatable_descs[i].second == EDESC_RESET) { + else if(activatable_descs[i].second == EDESC_RESET) { if(id == BUTTON_CMD_ACTIVATE) continue; } else { if(id == BUTTON_CMD_RESET) continue; } select_options.push_back(activatable_descs[i].first); - if (index == -1) index = i; + select_options_index.push_back(i); } } if (select_options.size() == 1) { + int index = select_options_index[0]; if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { DuelClient::SetResponseI((index << 16) + 5); } else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { @@ -397,8 +402,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { } DuelClient::SendResponse(); } else { - command_card = clicked_card; + command_card = menu_card; ShowSelectOption(); + select_ready = false; + ShowCancelOrFinishButton(1); } } else { selectable_cards.clear(); @@ -451,10 +458,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { } case BUTTON_CMD_SUMMON: { mainGame->wCmdMenu->setVisible(false); - if(!clicked_card) + if(!menu_card) break; for(size_t i = 0; i < summonable_cards.size(); ++i) { - if(summonable_cards[i] == clicked_card) { + if(summonable_cards[i] == menu_card) { ClearCommandFlag(); DuelClient::SetResponseI(i << 16); DuelClient::SendResponse(); @@ -466,10 +473,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { case BUTTON_CMD_SPSUMMON: { mainGame->wCmdMenu->setVisible(false); if(!list_command) { - if(!clicked_card) + if(!menu_card) break; for(size_t i = 0; i < spsummonable_cards.size(); ++i) { - if(spsummonable_cards[i] == clicked_card) { + if(spsummonable_cards[i] == menu_card) { ClearCommandFlag(); DuelClient::SetResponseI((i << 16) + 1); DuelClient::SendResponse(); @@ -508,10 +515,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { } case BUTTON_CMD_MSET: { mainGame->wCmdMenu->setVisible(false); - if(!clicked_card) + if(!menu_card) break; for(size_t i = 0; i < msetable_cards.size(); ++i) { - if(msetable_cards[i] == clicked_card) { + if(msetable_cards[i] == menu_card) { current_mset_param = (i << 16) + 3; if(mainGame->gameConf.ask_mset) { wchar_t wbuf[256]; @@ -529,10 +536,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { } case BUTTON_CMD_SSET: { mainGame->wCmdMenu->setVisible(false); - if(!clicked_card) + if(!menu_card) break; for(size_t i = 0; i < ssetable_cards.size(); ++i) { - if(ssetable_cards[i] == clicked_card) { + if(ssetable_cards[i] == menu_card) { DuelClient::SetResponseI((i << 16) + 4); DuelClient::SendResponse(); break; @@ -542,10 +549,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { } case BUTTON_CMD_REPOS: { mainGame->wCmdMenu->setVisible(false); - if(!clicked_card) + if(!menu_card) break; for(size_t i = 0; i < reposable_cards.size(); ++i) { - if(reposable_cards[i] == clicked_card) { + if(reposable_cards[i] == menu_card) { DuelClient::SetResponseI((i << 16) + 2); DuelClient::SendResponse(); break; @@ -555,10 +562,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { } case BUTTON_CMD_ATTACK: { mainGame->wCmdMenu->setVisible(false); - if(!clicked_card) + if(!menu_card) break; for(size_t i = 0; i < attackable_cards.size(); ++i) { - if(attackable_cards[i] == clicked_card) { + if(attackable_cards[i] == menu_card) { DuelClient::SetResponseI((i << 16) + 1); DuelClient::SendResponse(); break; @@ -664,9 +671,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) { break; } if(list_command == COMMAND_ACTIVATE || list_command == COMMAND_OPERATION) { - int index = -1; command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10]; select_options.clear(); + select_options_index.clear(); for (size_t i = 0; i < activatable_cards.size(); ++i) { if (activatable_cards[i] == command_card) { if(activatable_descs[i].second == EDESC_OPERATION) { @@ -675,10 +682,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) { if(list_command == COMMAND_OPERATION) continue; } select_options.push_back(activatable_descs[i].first); - if (index == -1) index = i; + select_options_index.push_back(i); } } if (select_options.size() == 1) { + int index = select_options_index[0]; if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { DuelClient::SetResponseI((index << 16) + 5); } else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { @@ -1572,7 +1580,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { SetShowMark(hovered_card, false); } if(mcard) { - if(mcard != clicked_card) + if(mcard != menu_card) mainGame->wCmdMenu->setVisible(false); if(hovered_location == LOCATION_HAND) { mcard->is_hovered = true; @@ -2349,6 +2357,7 @@ void ClientField::ShowMenu(int flag, int x, int y) { mainGame->wCmdMenu->setVisible(false); return; } + menu_card = clicked_card; int height = 1; int offset = mainGame->gameConf.resize_popup_menu ? ((mainGame->yScale >= 0.666) ? 21 * mainGame->yScale : 14) : 21; if(flag & COMMAND_ACTIVATE) { @@ -2518,8 +2527,7 @@ void ClientField::SetResponseSelectedOption() const { if(mainGame->dInfo.curMsg == MSG_SELECT_OPTION) { DuelClient::SetResponseI(selected_option); } else { - int index = 0; - while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++; + int index = select_options_index[selected_option]; if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { DuelClient::SetResponseI((index << 16) + 5); } else if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { diff --git a/gframe/game.cpp b/gframe/game.cpp index 88f2aefcd..7d28eb86d 100644 --- a/gframe/game.cpp +++ b/gframe/game.cpp @@ -278,8 +278,8 @@ bool Game::Initialize() { chkHostPrepReady[i]->setEnabled(false); } btnHostPrepOB = env->addButton(rect(10, 180, 110, 205), wHostPrepare, BUTTON_HP_OBSERVER, dataManager.GetSysString(1252)); - myswprintf(dataManager.strBuffer, L"%ls%d", dataManager.GetSysString(1253), 0); - stHostPrepOB = env->addStaticText(dataManager.strBuffer, rect(10, 285, 270, 305), false, false, wHostPrepare); + myswprintf(strbuf, L"%ls%d", dataManager.GetSysString(1253), 0); + stHostPrepOB = env->addStaticText(strbuf, rect(10, 285, 270, 305), false, false, wHostPrepare); stHostPrepRule = env->addStaticText(L"", rect(280, 30, 460, 230), false, true, wHostPrepare); env->addStaticText(dataManager.GetSysString(1254), rect(10, 210, 110, 230), false, false, wHostPrepare); cbCategorySelect = env->addComboBox(rect(10, 230, 138, 255), wHostPrepare, COMBOBOX_HP_CATEGORY); @@ -756,7 +756,7 @@ bool Game::Initialize() { btnStartFilter->setRelativePosition(rect(260, 80 + 125 / 6, 390, 100 + 125 / 6)); btnClearFilter = env->addButton(rect(205, 80 + 125 / 6, 255, 100 + 125 / 6), wFilter, BUTTON_CLEAR_FILTER, dataManager.GetSysString(1304)); } - wCategories = env->addWindow(rect(600, 60, 1000, 305), false, dataManager.strBuffer); + wCategories = env->addWindow(rect(600, 60, 1000, 305), false, L""); wCategories->getCloseButton()->setVisible(false); wCategories->setDrawTitlebar(false); wCategories->setDraggable(false); @@ -774,7 +774,7 @@ bool Game::Initialize() { wCategories->setRelativePosition(rect(1000 - wcatewidth, 60, 1000, 305)); btnCategoryOK->setRelativePosition(recti(wcatewidth / 2 - 50, 210, wcatewidth / 2 + 50, 235)); btnMarksFilter = env->addButton(rect(60, 80 + 125 / 6, 190, 100 + 125 / 6), wFilter, BUTTON_MARKS_FILTER, dataManager.GetSysString(1374)); - wLinkMarks = env->addWindow(rect(700, 30, 820, 150), false, dataManager.strBuffer); + wLinkMarks = env->addWindow(rect(700, 30, 820, 150), false, L""); wLinkMarks->getCloseButton()->setVisible(false); wLinkMarks->setDrawTitlebar(false); wLinkMarks->setDraggable(false); @@ -1084,25 +1084,29 @@ void Game::BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 mProjection[14] = znear * zfar / (znear - zfar); } void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text) { - SetStaticText(pControl, cWidth, font, text); - if(font->getDimension(dataManager.strBuffer).Height <= cHeight) { + std::wstring format_text; + format_text = SetStaticText(pControl, cWidth, font, text); + if(font->getDimension(format_text.c_str()).Height <= cHeight) { scrCardText->setVisible(false); if(env->hasFocus(scrCardText)) env->removeFocus(scrCardText); return; } - SetStaticText(pControl, cWidth-25, font, text); + format_text = SetStaticText(pControl, cWidth-25, font, text); u32 fontheight = font->getDimension(L"A").Height + font->getKerningHeight(); - u32 step = (font->getDimension(dataManager.strBuffer).Height - cHeight) / fontheight + 1; + u32 step = (font->getDimension(format_text.c_str()).Height - cHeight) / fontheight + 1; scrCardText->setVisible(true); scrCardText->setMin(0); scrCardText->setMax(step); scrCardText->setPos(0); } -void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos) { +std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos) { int pbuffer = 0; u32 _width = 0, _height = 0; wchar_t prev = 0; + wchar_t strBuffer[4096]; + std::wstring ret; + for(size_t i = 0; text[i] != 0 && i < wcslen(text); ++i) { wchar_t c = text[i]; u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev); @@ -1110,7 +1114,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu if(text[i] == L'\r') { continue; } else if(text[i] == L'\n') { - dataManager.strBuffer[pbuffer++] = L'\n'; + strBuffer[pbuffer++] = L'\n'; _width = 0; _height++; prev = 0; @@ -1118,7 +1122,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu pbuffer = 0; continue; } else if(_width > 0 && _width + w > cWidth) { - dataManager.strBuffer[pbuffer++] = L'\n'; + strBuffer[pbuffer++] = L'\n'; _width = 0; _height++; prev = 0; @@ -1126,10 +1130,12 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu pbuffer = 0; } _width += w; - dataManager.strBuffer[pbuffer++] = c; + strBuffer[pbuffer++] = c; } - dataManager.strBuffer[pbuffer] = 0; - pControl->setText(dataManager.strBuffer); + strBuffer[pbuffer] = 0; + pControl->setText(strBuffer); + ret.assign(strBuffer); + return ret; } void Game::LoadExpansions() { FileSystem::TraversalDir(L"./expansions", [](const wchar_t* name, bool isdir) { diff --git a/gframe/game.h b/gframe/game.h index a41e0f31c..9edbf037e 100644 --- a/gframe/game.h +++ b/gframe/game.h @@ -137,7 +137,7 @@ class Game { void RefreshTimeDisplay(); void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar); void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text); - void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0); + std::wstring SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0); void LoadExpansions(); void RefreshCategoryDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck, bool selectlastused = true); void RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck); diff --git a/lflist.conf b/lflist.conf index 4342c8986..1125883ec 100644 --- a/lflist.conf +++ b/lflist.conf @@ -188,7 +188,6 @@ !2021.1 #forbidden -62472614 0 --疫病(tmp) 91869203 0 --アマゾネスの射手 20663556 0 --イレカエル 44910027 0 --ヴィクトリー・ドラゴン diff --git a/strings.conf b/strings.conf index 735c8b62e..d4ece3b6b 100644 --- a/strings.conf +++ b/strings.conf @@ -636,6 +636,8 @@ !counter 0x59 落魂指示物 !counter 0x5a 指示物(岩战之试炼) !counter 0x5b 指示物(北极天熊北斗星) +!counter 0x105c 燃烧指示物 +!counter 0x5d 指示物(机巧传-神使记纪图) #setnames, using tab for comment !setname 0x1 正义盟军 A・O・J !setname 0x2 次世代 ジェネクス @@ -1099,3 +1101,8 @@ !setname 0x161 溟界 !setname 0x162 七音服 ドレミコード !setname 0x163 北极天熊 ベアルクティ +!setname 0x164 死狱乡 デスピア +!setname 0x165 魔键 魔鍵 +!setname 0x166 军贯 軍貫 +!setname 0x1167 森之圣兽 森の聖獣 +!setname 0x2167 森之圣灵 森の聖霊