diff --git a/gframe/client_field.cpp b/gframe/client_field.cpp index 5beaf5c769..0851d161a1 100644 --- a/gframe/client_field.cpp +++ b/gframe/client_field.cpp @@ -1050,7 +1050,7 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir return; } int oseq = pcard->overlayTarget->sequence; - int mseq = (sequence < MAX_LAYER_COUNT) ? sequence : (MAX_LAYER_COUNT - 1); + int mseq = myclamp(sequence, 0, MAX_LAYER_COUNT - 1); if (pcard->overlayTarget->controler == 0) { t->X = (matManager.vFieldMzone[0][oseq][0].Pos.X + matManager.vFieldMzone[0][oseq][1].Pos.X) / 2 - 0.12f + 0.06f * mseq; t->Y = (matManager.vFieldMzone[0][oseq][0].Pos.Y + matManager.vFieldMzone[0][oseq][2].Pos.Y) / 2 + 0.05f; @@ -1175,7 +1175,7 @@ bool ClientField::CheckSelectSum() { int op1 = selected_cards[i]->opParam & 0xffff; int op2 = selected_cards[i]->opParam >> 16; int opmin = (op2 > 0 && op1 > op2) ? op2 : op1; - int opmax = op2 > op1 ? op2 : op1; + int opmax = std::max(op1, op2); select_curval_l += opmin; select_curval_h += opmax; } @@ -1198,7 +1198,7 @@ bool ClientField::CheckSelectSum() { int op1, op2; get_sum_params(sc->opParam, op1, op2); int opmin = (op2 > 0 && op1 > op2) ? op2 : op1; - int opmax = op2 > op1 ? op2 : op1; + int opmax = std::max(op1, op2); if (mm == -1 || opmin < mm) mm = opmin; if (mx == -1 || opmax < mx) diff --git a/gframe/config.h b/gframe/config.h index c28de2af8c..5f54388eee 100644 --- a/gframe/config.h +++ b/gframe/config.h @@ -57,6 +57,10 @@ template inline int mysnprintf(char(&buf)[N], const char* fmt, TR... args) { return std::snprintf(buf, N, fmt, args...); } +template +inline T myclamp(T v, T lo, T hi) { + return (v < lo) ? lo : (hi < v) ? hi : v; +} inline FILE* mywfopen(const wchar_t* filename, const char* mode) { FILE* fp{}; diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index 3d8c0f7489..bdfce1d7ff 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -1746,10 +1746,7 @@ void DeckBuilder::ShowBigCard(int code, float zoom) { mainGame->gMutex.unlock(); } void DeckBuilder::ZoomBigCard(irr::s32 centerx, irr::s32 centery) { - if(bigcard_zoom >= 4) - bigcard_zoom = 4; - if(bigcard_zoom <= 0.2f) - bigcard_zoom = 0.2f; + bigcard_zoom = myclamp(bigcard_zoom, 0.2f, 4.0f); auto img = imageManager.GetBigPicture(bigcard_code, bigcard_zoom); mainGame->imgBigCard->setImage(img); auto size = img->getSize(); diff --git a/gframe/event_handler.cpp b/gframe/event_handler.cpp index bfcad53268..ff0c92e54c 100644 --- a/gframe/event_handler.cpp +++ b/gframe/event_handler.cpp @@ -1934,6 +1934,26 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { return true; break; } + case CHECKBOX_SWAP_YES_NO_BUTTON: { + bool checked = mainGame->chkSwapYesNoButton->isChecked(); + mainGame->gameConf.swap_yes_no_button = checked; + mainGame->SwapYesNoButtons(checked); + return true; + break; + } + case CHECKBOX_RESIZE_SELECT_WINDOW: { + mainGame->gameConf.resize_select_window = mainGame->chkResizeSelectWindow->isChecked(); + mainGame->OnResize(); + return true; + break; + } + case CHECKBOX_RESIZE_POPUP_MENU: { + bool checked = mainGame->chkResizePopupMenu->isChecked(); + mainGame->gameConf.resize_popup_menu = checked ? mainGame->scrResizePopupMenu->getPos() : 0; + mainGame->ResizeCmdMenu(); + return true; + break; + } case CHECKBOX_LFLIST: { mainGame->gameConf.use_lflist = mainGame->chkLFlist->isChecked() ? 1 : 0; mainGame->cbLFlist->setEnabled(mainGame->gameConf.use_lflist); @@ -1997,13 +2017,21 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { break; } case SCROLL_VOLUME: { - mainGame->gameConf.sound_volume = (double)mainGame->scrSoundVolume->getPos() / 100; - mainGame->gameConf.music_volume = (double)mainGame->scrMusicVolume->getPos() / 100; + mainGame->gameConf.sound_volume = mainGame->scrSoundVolume->getPos(); + mainGame->gameConf.music_volume = mainGame->scrMusicVolume->getPos(); soundManager.SetSoundVolume(mainGame->gameConf.sound_volume); soundManager.SetMusicVolume(mainGame->gameConf.music_volume); return true; break; } + case SCROLL_RESIZE_POPUP_MENU: { + if(mainGame->chkResizePopupMenu->isChecked()) { + mainGame->gameConf.resize_popup_menu = mainGame->scrResizePopupMenu->getPos(); + mainGame->ResizeCmdMenu(); + } + return true; + break; + } case SCROLL_TAB_HELPER: { irr::core::rect pos = mainGame->tabHelper->getRelativePosition(); mainGame->tabHelper->setRelativePosition(irr::core::recti(0, mainGame->scrTabHelper->getPos() * -1, pos.LowerRightCorner.X, pos.LowerRightCorner.Y)); @@ -2311,27 +2339,27 @@ void ClientField::ShowMenu(int flag, int x, int y) { return; } menu_card = clicked_card; - int height = 1; - int offset = mainGame->gameConf.resize_popup_menu ? ((mainGame->yScale >= 0.666) ? 21 * mainGame->yScale : 14) : 21; + irr::s32 offset = 0; + irr::s32 height = mainGame->GetPopupMenuButtonHeight(); if(flag & COMMAND_ACTIVATE) { mainGame->btnActivate->setVisible(true); - mainGame->btnActivate->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnActivate->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnActivate->setVisible(false); if(flag & COMMAND_SUMMON) { mainGame->btnSummon->setVisible(true); - mainGame->btnSummon->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnSummon->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnSummon->setVisible(false); if(flag & COMMAND_SPSUMMON) { mainGame->btnSPSummon->setVisible(true); - mainGame->btnSPSummon->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnSPSummon->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnSPSummon->setVisible(false); if(flag & COMMAND_MSET) { mainGame->btnMSet->setVisible(true); - mainGame->btnMSet->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnMSet->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnMSet->setVisible(false); if(flag & COMMAND_SSET) { if(!(clicked_card->type & TYPE_MONSTER)) @@ -2339,8 +2367,8 @@ void ClientField::ShowMenu(int flag, int x, int y) { else mainGame->btnSSet->setText(dataManager.GetSysString(1159)); mainGame->btnSSet->setVisible(true); - mainGame->btnSSet->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnSSet->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnSSet->setVisible(false); if(flag & COMMAND_REPOS) { if(clicked_card->position & POS_FACEDOWN) @@ -2350,38 +2378,35 @@ void ClientField::ShowMenu(int flag, int x, int y) { else mainGame->btnRepos->setText(dataManager.GetSysString(1156)); mainGame->btnRepos->setVisible(true); - mainGame->btnRepos->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnRepos->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnRepos->setVisible(false); if(flag & COMMAND_ATTACK) { mainGame->btnAttack->setVisible(true); - mainGame->btnAttack->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnAttack->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnAttack->setVisible(false); if(flag & COMMAND_LIST) { mainGame->btnShowList->setVisible(true); - mainGame->btnShowList->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnShowList->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnShowList->setVisible(false); if(flag & COMMAND_OPERATION) { mainGame->btnOperation->setVisible(true); - mainGame->btnOperation->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnOperation->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnOperation->setVisible(false); if(flag & COMMAND_RESET) { mainGame->btnReset->setVisible(true); - mainGame->btnReset->setRelativePosition(irr::core::vector2di(1, height)); - height += offset; + mainGame->btnReset->setRelativePosition(irr::core::vector2di(0, offset)); + offset += height; } else mainGame->btnReset->setVisible(false); panel = mainGame->wCmdMenu; mainGame->wCmdMenu->setVisible(true); mainGame->btnBP->setEnabled(false); mainGame->btnM2->setEnabled(false); mainGame->btnEP->setEnabled(false); - if(mainGame->gameConf.resize_popup_menu) - mainGame->wCmdMenu->setRelativePosition(mainGame->Resize(x - 20, y - 20, x + 80, y - 20, 0, -height, 0, 0)); - else - mainGame->wCmdMenu->setRelativePosition(mainGame->Resize(x, y, x, y, -20, -(20 + height), 80, -20)); + mainGame->wCmdMenu->setRelativePosition(mainGame->Resize(x, y, x, y, -20, -(20 + offset), mainGame->GetPopupMenuButtonWidth() - 20, -20)); } void ClientField::HideMenu() { mainGame->wCmdMenu->setVisible(false); diff --git a/gframe/game.cpp b/gframe/game.cpp index f16f7f8c71..5e667a1514 100644 --- a/gframe/game.cpp +++ b/gframe/game.cpp @@ -451,12 +451,25 @@ bool Game::Initialize() { chkPreferExpansionScript = env->addCheckBox(false, irr::core::rect(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_PREFER_EXPANSION, dataManager.GetSysString(1379)); chkPreferExpansionScript->setChecked(gameConf.prefer_expansion_script != 0); posY += 30; + chkSwapYesNoButton = env->addCheckBox(false, irr::core::rect(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_SWAP_YES_NO_BUTTON, dataManager.GetSysString(1388)); + chkSwapYesNoButton->setChecked(gameConf.swap_yes_no_button); + posY += 30; + chkResizeSelectWindow = env->addCheckBox(gameConf.resize_select_window, irr::core::rect(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_RESIZE_SELECT_WINDOW, dataManager.GetSysString(1387)); + posY += 30; env->addStaticText(dataManager.GetSysString(1282), irr::core::rect(posX + 23, posY + 3, posX + 110, posY + 28), false, false, tabSystem); btnWinResizeS = env->addButton(irr::core::rect(posX + 115, posY, posX + 145, posY + 25), tabSystem, BUTTON_WINDOW_RESIZE_S, dataManager.GetSysString(1283)); btnWinResizeM = env->addButton(irr::core::rect(posX + 150, posY, posX + 180, posY + 25), tabSystem, BUTTON_WINDOW_RESIZE_M, dataManager.GetSysString(1284)); btnWinResizeL = env->addButton(irr::core::rect(posX + 185, posY, posX + 215, posY + 25), tabSystem, BUTTON_WINDOW_RESIZE_L, dataManager.GetSysString(1285)); btnWinResizeXL = env->addButton(irr::core::rect(posX + 220, posY, posX + 250, posY + 25), tabSystem, BUTTON_WINDOW_RESIZE_XL, dataManager.GetSysString(1286)); posY += 30; + chkResizePopupMenu = env->addCheckBox(gameConf.resize_popup_menu > 0, irr::core::rect(posX, posY, posX + 120, posY + 25), tabSystem, CHECKBOX_RESIZE_POPUP_MENU, dataManager.GetSysString(1386)); + scrResizePopupMenu = env->addScrollBar(true, irr::core::rect(posX + 116, posY + 4, posX + 250, posY + 21), tabSystem, SCROLL_RESIZE_POPUP_MENU); + scrResizePopupMenu->setMax(5); + scrResizePopupMenu->setMin(1); + scrResizePopupMenu->setPos(gameConf.resize_popup_menu > 0 ? gameConf.resize_popup_menu : 3); + scrResizePopupMenu->setLargeStep(1); + scrResizePopupMenu->setSmallStep(1); + posY += 30; chkLFlist = env->addCheckBox(false, irr::core::rect(posX, posY, posX + 110, posY + 25), tabSystem, CHECKBOX_LFLIST, dataManager.GetSysString(1288)); chkLFlist->setChecked(gameConf.use_lflist); cbLFlist = env->addComboBox(irr::core::rect(posX + 115, posY, posX + 250, posY + 25), tabSystem, COMBOBOX_LFLIST); @@ -471,7 +484,7 @@ bool Game::Initialize() { scrSoundVolume = env->addScrollBar(true, irr::core::rect(posX + 116, posY + 4, posX + 250, posY + 21), tabSystem, SCROLL_VOLUME); scrSoundVolume->setMax(100); scrSoundVolume->setMin(0); - scrSoundVolume->setPos(gameConf.sound_volume * 100); + scrSoundVolume->setPos(gameConf.sound_volume); scrSoundVolume->setLargeStep(1); scrSoundVolume->setSmallStep(1); posY += 30; @@ -480,7 +493,7 @@ bool Game::Initialize() { scrMusicVolume = env->addScrollBar(true, irr::core::rect(posX + 116, posY + 4, posX + 250, posY + 21), tabSystem, SCROLL_VOLUME); scrMusicVolume->setMax(100); scrMusicVolume->setMin(0); - scrMusicVolume->setPos(gameConf.music_volume * 100); + scrMusicVolume->setPos(gameConf.music_volume); scrMusicVolume->setLargeStep(1); scrMusicVolume->setSmallStep(1); posY += 30; @@ -958,6 +971,7 @@ bool Game::Initialize() { chkMusicMode->setEnabled(false); chkMusicMode->setVisible(false); } + SwapYesNoButtons(gameConf.swap_yes_no_button); env->getSkin()->setFont(guiFont); env->setFocus(wMainMenu); for (int i = 0; i < irr::gui::EGDC_COUNT; ++i) { @@ -1460,33 +1474,30 @@ void Game::LoadConfig() { gameConf.hide_player_name = std::strtol(valbuf, nullptr, 10); } else if(!std::strcmp(strbuf, "prefer_expansion_script")) { gameConf.prefer_expansion_script = std::strtol(valbuf, nullptr, 10); + } else if(!std::strcmp(strbuf, "swap_yes_no_button")) { + gameConf.swap_yes_no_button = std::strtol(valbuf, nullptr, 10) > 0; } else if(!std::strcmp(strbuf, "window_maximized")) { gameConf.window_maximized = std::strtol(valbuf, nullptr, 10) > 0; } else if(!std::strcmp(strbuf, "window_width")) { gameConf.window_width = std::strtol(valbuf, nullptr, 10); } else if(!std::strcmp(strbuf, "window_height")) { gameConf.window_height = std::strtol(valbuf, nullptr, 10); + } else if(!std::strcmp(strbuf, "resize_select_window")) { + gameConf.resize_select_window = std::strtol(valbuf, nullptr, 10) > 0; } else if(!std::strcmp(strbuf, "resize_popup_menu")) { - gameConf.resize_popup_menu = std::strtol(valbuf, nullptr, 10) > 0; + int val = std::strtol(valbuf, nullptr, 10); + gameConf.resize_popup_menu = myclamp(val, 0, 5); #ifdef YGOPRO_USE_AUDIO } else if(!std::strcmp(strbuf, "enable_sound")) { gameConf.enable_sound = std::strtol(valbuf, nullptr, 10) > 0; } else if(!std::strcmp(strbuf, "sound_volume")) { int vol = std::strtol(valbuf, nullptr, 10); - if (vol < 0) - vol = 0; - else if (vol > 100) - vol = 100; - gameConf.sound_volume = (double)vol / 100; + gameConf.sound_volume = myclamp(vol, 0, 100); } else if(!std::strcmp(strbuf, "enable_music")) { gameConf.enable_music = std::strtol(valbuf, nullptr, 10) > 0; } else if(!std::strcmp(strbuf, "music_volume")) { int vol = std::strtol(valbuf, nullptr, 10); - if (vol < 0) - vol = 0; - else if (vol > 100) - vol = 100; - gameConf.music_volume = (double)vol / 100; + gameConf.music_volume = myclamp(vol, 0, 100); } else if(!std::strcmp(strbuf, "music_mode")) { gameConf.music_mode = std::strtol(valbuf, nullptr, 10); #endif @@ -1581,18 +1592,18 @@ void Game::SaveConfig() { std::fprintf(fp, "draw_single_chain = %d\n", gameConf.draw_single_chain); std::fprintf(fp, "hide_player_name = %d\n", gameConf.hide_player_name); std::fprintf(fp, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script); + std::fprintf(fp, "swap_yes_no_button = %d\n", (chkSwapYesNoButton->isChecked() ? 1 : 0)); std::fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0)); std::fprintf(fp, "window_width = %d\n", gameConf.window_width); std::fprintf(fp, "window_height = %d\n", gameConf.window_height); - std::fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0); + std::fprintf(fp, "resize_select_window = %d\n", (chkResizeSelectWindow->isChecked() ? 1 : 0)); + std::fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu); #ifdef YGOPRO_USE_AUDIO std::fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0)); std::fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0)); std::fprintf(fp, "#Volume of sound and music, between 0 and 100\n"); - int vol = gameConf.sound_volume * 100; - std::fprintf(fp, "sound_volume = %d\n", vol); - vol = gameConf.music_volume * 100; - std::fprintf(fp, "music_volume = %d\n", vol); + std::fprintf(fp, "sound_volume = %d\n", gameConf.sound_volume); + std::fprintf(fp, "music_volume = %d\n", gameConf.music_volume); std::fprintf(fp, "music_mode = %d\n", (chkMusicMode->isChecked() ? 1 : 0)); #endif std::fclose(fp); @@ -1911,6 +1922,27 @@ int Game::ChatLocalPlayer(int player) { const wchar_t* Game::LocalName(int local_player) { return local_player == 0 ? dInfo.hostname : dInfo.clientname; } +void Game::SwapYesNoButtons(bool no_first) { + if(no_first) { + btnYes->setRelativePosition(irr::core::rect(200, 105, 250, 130)); + btnNo->setRelativePosition(irr::core::rect(100, 105, 150, 130)); + btnSurrenderYes->setRelativePosition(irr::core::rect(200, 105, 250, 130)); + btnSurrenderNo->setRelativePosition(irr::core::rect(100, 105, 150, 130)); + btnRSYes->setRelativePosition(irr::core::rect(170, 80, 240, 105)); + btnRSNo->setRelativePosition(irr::core::rect(70, 80, 140, 105)); + btnDMOK->setRelativePosition(irr::core::rect(170, 80, 240, 105)); + btnDMCancel->setRelativePosition(irr::core::rect(70, 80, 140, 105)); + } else { + btnYes->setRelativePosition(irr::core::rect(100, 105, 150, 130)); + btnNo->setRelativePosition(irr::core::rect(200, 105, 250, 130)); + btnSurrenderYes->setRelativePosition(irr::core::rect(100, 105, 150, 130)); + btnSurrenderNo->setRelativePosition(irr::core::rect(200, 105, 250, 130)); + btnRSYes->setRelativePosition(irr::core::rect(70, 80, 140, 105)); + btnRSNo->setRelativePosition(irr::core::rect(170, 80, 240, 105)); + btnDMOK->setRelativePosition(irr::core::rect(70, 80, 140, 105)); + btnDMCancel->setRelativePosition(irr::core::rect(170, 80, 240, 105)); + } +} void Game::OnResize() { #ifdef _WIN32 WINDOWPLACEMENT plc; @@ -2043,6 +2075,7 @@ void Game::OnResize() { //sound / music volume bar scrSoundVolume->setRelativePosition(irr::core::recti(scrSoundVolume->getRelativePosition().UpperLeftCorner.X, scrSoundVolume->getRelativePosition().UpperLeftCorner.Y, 20 + (300 * xScale) - 70, scrSoundVolume->getRelativePosition().LowerRightCorner.Y)); scrMusicVolume->setRelativePosition(irr::core::recti(scrMusicVolume->getRelativePosition().UpperLeftCorner.X, scrMusicVolume->getRelativePosition().UpperLeftCorner.Y, 20 + (300 * xScale) - 70, scrMusicVolume->getRelativePosition().LowerRightCorner.Y)); + scrResizePopupMenu->setRelativePosition(irr::core::recti(scrResizePopupMenu->getRelativePosition().UpperLeftCorner.X, scrResizePopupMenu->getRelativePosition().UpperLeftCorner.Y, 20 + (300 * xScale) - 70, scrResizePopupMenu->getRelativePosition().LowerRightCorner.Y)); irr::core::recti tabHelperPos = irr::core::recti(0, 0, 300 * xScale - 50, 365 * yScale - 65); tabHelper->setRelativePosition(tabHelperPos); @@ -2067,23 +2100,6 @@ void Game::OnResize() { } else scrTabSystem->setVisible(false); - if(gameConf.resize_popup_menu) { - int width = 100 * xScale; - int height = (yScale >= 0.666) ? 21 * yScale : 14; - wCmdMenu->setRelativePosition(irr::core::recti(1, 1, width + 1, 1)); - btnActivate->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnSummon->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnSPSummon->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnMSet->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnSSet->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnRepos->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnAttack->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnActivate->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnShowList->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnOperation->setRelativePosition(irr::core::recti(1, 1, width, height)); - btnReset->setRelativePosition(irr::core::recti(1, 1, width, height)); - } - wCardImg->setRelativePosition(ResizeCardImgWin(1, 1, 20, 18)); imgCard->setRelativePosition(ResizeCardImgWin(10, 9, 0, 0)); wInfos->setRelativePosition(Resize(1, 275, 301, 639)); @@ -2102,6 +2118,7 @@ void Game::OnResize() { btnEP->setRelativePosition(Resize(320, 0, 370, 20)); ResizeChatInputWindow(); + ResizeCmdMenu(); btnLeaveGame->setRelativePosition(Resize(205, 5, 295, 80)); wReplayControl->setRelativePosition(Resize(205, 143, 295, 273)); @@ -2133,9 +2150,26 @@ void Game::ResizeChatInputWindow() { wChat->setRelativePosition(irr::core::recti(x, window_size.Height - 25, window_size.Width, window_size.Height)); ebChatInput->setRelativePosition(irr::core::recti(3, 2, window_size.Width - wChat->getRelativePosition().UpperLeftCorner.X - 6, 22)); } +void Game::ResizeCmdMenu() { + irr::s32 width = GetPopupMenuButtonWidth(); + irr::s32 height = GetPopupMenuButtonHeight(); + wCmdMenu->setRelativePosition(irr::core::recti(0, 0, width, 0)); + btnActivate->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnSummon->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnSPSummon->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnMSet->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnSSet->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnRepos->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnAttack->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnShowList->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnOperation->setRelativePosition(irr::core::recti(0, 0, width, height)); + btnReset->setRelativePosition(irr::core::recti(0, 0, width, height)); +} void Game::ResizePosSelectButtons() { - irr::s32 imgHeight = CARD_IMG_HEIGHT * 0.5f * yScale + 0.5f; - irr::s32 gap = 5 * xScale + 0.5f; + float _xScale = gameConf.resize_select_window ? xScale : 1.0f; + float _yScale = gameConf.resize_select_window ? yScale : 1.2f; + irr::s32 imgHeight = CARD_IMG_HEIGHT * 0.5f * _yScale + 0.5f; + irr::s32 gap = 5 * _xScale + 0.5f; irr::s32 btnPosWidth = imgHeight + gap * 2; // Square buttons, width = height irr::s32 stride = btnPosWidth + gap; int totalWidth = 0, visCount = 0; @@ -2144,9 +2178,9 @@ void Game::ResizePosSelectButtons() { if(btnPSDU->isVisible()) { totalWidth += btnPosWidth; visCount++; } if(btnPSDD->isVisible()) { totalWidth += btnPosWidth; visCount++; } totalWidth += (visCount - 1) * gap; - irr::s32 posY = 19 + 16 * yScale; - irr::s32 windowWidth = 30 * xScale * 2 + stride * 3 - gap; - irr::s32 windowHeight = posY + 155 * yScale; + irr::s32 posY = 19 + 16 * _yScale; + irr::s32 windowWidth = 30 * _xScale * 2 + stride * 3 - gap; + irr::s32 windowHeight = posY + 155 * _yScale; irr::s32 posX = (windowWidth - totalWidth) / 2; if(btnPSAU->isVisible()) { btnPSAU->setRelativePosition(irr::core::recti(posX, posY, posX + btnPosWidth, posY + btnPosWidth)); @@ -2172,18 +2206,20 @@ void Game::ResizeCardSelectButtons(irr::gui::IGUIWindow* window, irr::gui::IGUIScrollBar* scrollbar, irr::gui::IGUIButton* buttonOK, const std::vector& cards) { - irr::s32 gap = 5 * xScale + 0.5f; - irr::s32 btnWidth = CARD_IMG_WIDTH * 0.55f * yScale + 0.5f; - irr::s32 btnHeight = CARD_IMG_HEIGHT * 0.55f * yScale + 0.5f; + float _xScale = gameConf.resize_select_window ? xScale : 1.0f; + float _yScale = gameConf.resize_select_window ? yScale : 1.2f; + irr::s32 gap = 5 * _xScale + 0.5f; + irr::s32 btnWidth = CARD_IMG_WIDTH * 0.55f * _yScale + 0.5f; + irr::s32 btnHeight = CARD_IMG_HEIGHT * 0.55f * _yScale + 0.5f; irr::s32 stride = btnWidth + gap; - int startpos = 30 * xScale; + int startpos = 30 * _xScale; int ct = 5; if (cards.size() < 5) { - startpos = 30 * xScale + stride * (5 - (int)cards.size()) / 2; + startpos = 30 * _xScale + stride * (5 - (int)cards.size()) / 2; ct = cards.size(); } - irr::s32 top = 19 + 11 * yScale; - irr::s32 labelHeight = 20 * yScale; + irr::s32 top = 19 + 11 * _yScale; + irr::s32 labelHeight = 20 * _yScale; irr::s32 minTextHeight = gameConf.textfontsize * 1.4f + 0.5f; if (labelHeight < minTextHeight) labelHeight = minTextHeight; irr::s32 btnTop = top + labelHeight + gap; @@ -2193,14 +2229,14 @@ void Game::ResizeCardSelectButtons(irr::gui::IGUIWindow* window, } irr::s32 barTop = btnTop + btnHeight + gap; irr::s32 barWidth = stride * ct - gap; - irr::s32 barHeight = 20 * yScale; + irr::s32 barHeight = 20 * _yScale; if (barHeight > 25) barHeight = 25; scrollbar->setRelativePosition(irr::core::recti(startpos, barTop, startpos + barWidth, barTop + barHeight)); - irr::s32 btnOKWidth = 80 * xScale; - irr::s32 btnOKHeight = 25 * yScale; + irr::s32 btnOKWidth = 80 * _xScale; + irr::s32 btnOKHeight = 25 * _yScale; if (btnOKHeight < minTextHeight) btnOKHeight = minTextHeight; buttonOK->setRelativePosition(irr::core::recti(startpos + barWidth / 2 - btnOKWidth / 2, barTop + barHeight + gap * 2, startpos + barWidth / 2 + btnOKWidth / 2, barTop + barHeight + gap * 2 + btnOKHeight)); - irr::s32 windowWidth = 30 * xScale * 2 + stride * 5 - gap; + irr::s32 windowWidth = 30 * _xScale * 2 + stride * 5 - gap; irr::s32 windowHeight = top + labelHeight + btnHeight + barHeight + btnOKHeight + gap * 6; window->setRelativePosition(irr::core::recti(663 * xScale - windowWidth / 2, 263 * yScale - windowHeight / 2, 663 * xScale + windowWidth / 2, 263 * yScale + windowHeight / 2)); } diff --git a/gframe/game.h b/gframe/game.h index d4be749827..23168a82f9 100644 --- a/gframe/game.h +++ b/gframe/game.h @@ -92,13 +92,15 @@ struct Config { int prefer_expansion_script{ 0 }; bool enable_sound{ true }; bool enable_music{ true }; - double sound_volume{ 0.5 }; - double music_volume{ 0.5 }; + int sound_volume{ 50 }; + int music_volume{ 50 }; int music_mode{ 1 }; bool window_maximized{ false }; int window_width{ GAME_WINDOW_WIDTH }; int window_height{ GAME_WINDOW_HEIGHT }; - bool resize_popup_menu{ false }; + int resize_popup_menu{ 0 }; + bool resize_select_window{ true }; + bool swap_yes_no_button{ false }; }; struct DuelInfo { @@ -209,6 +211,23 @@ class Game { int ChatLocalPlayer(int player); const wchar_t* LocalName(int local_player); + irr::s32 GetPopupMenuButtonWidth() const { + if(gameConf.resize_popup_menu > 0) { + return (xScale >= 0.7f) ? 100 * xScale : 70; + } else { + return 100; + } + } + + irr::s32 GetPopupMenuButtonHeight() const { + if(gameConf.resize_popup_menu > 0) { + float yScaleForMenu = yScale * (1 + (gameConf.resize_popup_menu - 1) * 0.33f); + return (yScaleForMenu >= 0.7f) ? 24 * yScaleForMenu : 16; + } else { + return 24; + } + } + bool HasFocus(irr::gui::EGUI_ELEMENT_TYPE type) const { irr::gui::IGUIElement* focus = env->getFocus(); return focus && focus->hasType(type); @@ -220,8 +239,11 @@ class Game { editbox->setText(text.c_str()); } + void SwapYesNoButtons(bool no_first); + void OnResize(); // caller must hold gMutex void ResizeChatInputWindow(); + void ResizeCmdMenu(); void ResizePosSelectButtons(); void ResizeCardSelectButtons(irr::gui::IGUIWindow* window, irr::gui::IGUIStaticText** labels, irr::gui::IGUIButton** images, irr::gui::IGUIScrollBar* scrollbar, irr::gui::IGUIButton* buttonOK, const std::vector& cards); @@ -366,6 +388,7 @@ class Game { irr::gui::IGUICheckBox* chkAutoSearch{}; irr::gui::IGUICheckBox* chkMultiKeywords{}; irr::gui::IGUICheckBox* chkPreferExpansionScript{}; + irr::gui::IGUICheckBox* chkSwapYesNoButton{}; irr::gui::IGUICheckBox* chkLFlist{}; irr::gui::IGUIComboBox* cbLFlist{}; irr::gui::IGUICheckBox* chkEnableSound{}; @@ -373,6 +396,9 @@ class Game { irr::gui::IGUIScrollBar* scrSoundVolume{}; irr::gui::IGUIScrollBar* scrMusicVolume{}; irr::gui::IGUICheckBox* chkMusicMode{}; + irr::gui::IGUICheckBox* chkResizeSelectWindow{}; + irr::gui::IGUICheckBox* chkResizePopupMenu{}; + irr::gui::IGUIScrollBar* scrResizePopupMenu{}; irr::gui::IGUIButton* btnWinResizeS{}; irr::gui::IGUIButton* btnWinResizeM{}; irr::gui::IGUIButton* btnWinResizeL{}; @@ -862,6 +888,10 @@ extern Game* mainGame; #define BUTTON_BIG_CARD_ZOOM_IN 381 #define BUTTON_BIG_CARD_ZOOM_OUT 382 #define BUTTON_BIG_CARD_ORIG_SIZE 383 +#define CHECKBOX_RESIZE_POPUP_MENU 384 +#define SCROLL_RESIZE_POPUP_MENU 385 +#define CHECKBOX_RESIZE_SELECT_WINDOW 386 +#define CHECKBOX_SWAP_YES_NO_BUTTON 387 #define AVAIL_OCG 0x1 #define AVAIL_TCG 0x2 diff --git a/gframe/image_manager.cpp b/gframe/image_manager.cpp index 5a30c1337f..4347b426da 100644 --- a/gframe/image_manager.cpp +++ b/gframe/image_manager.cpp @@ -103,7 +103,7 @@ void ImageManager::ResizeTexture() { irr::s32 imgHeightFit = CARD_IMG_HEIGHT * mul; irr::s32 bgWidth = GAME_WINDOW_WIDTH * mainGame->xScale; irr::s32 bgHeight = GAME_WINDOW_HEIGHT * mainGame->yScale; - float btnScale = 0.5f * mainGame->yScale; + float btnScale = 0.5f * (mainGame->gameConf.resize_select_window ? mainGame->yScale : 1.2f); irr::s32 btnImgWidth = CARD_IMG_WIDTH * btnScale; irr::s32 btnImgHeight = CARD_IMG_HEIGHT * btnScale; const char* coverFiles[2] = { "textures/cover.jpg", "textures/cover2.jpg" }; @@ -433,9 +433,9 @@ irr::video::ITexture* ImageManager::GetTextureButton(int code, bool defense) { auto tit = cache.find(code); if(tit != cache.end()) return tit->second; - float btnScale = 0.5f * mainGame->yScale; - irr::s32 width = (irr::s32)(CARD_IMG_WIDTH * btnScale); - irr::s32 height = (irr::s32)(CARD_IMG_HEIGHT * btnScale); + float btnScale = 0.5f * (mainGame->gameConf.resize_select_window ? mainGame->yScale : 1.2f); + irr::s32 width = CARD_IMG_WIDTH * btnScale; + irr::s32 height = CARD_IMG_HEIGHT * btnScale; irr::video::IImage* img = GetImage(code); if(!img) { cache[code] = nullptr; diff --git a/gframe/sound_manager.cpp b/gframe/sound_manager.cpp index 5202997550..59cb243164 100644 --- a/gframe/sound_manager.cpp +++ b/gframe/sound_manager.cpp @@ -322,20 +322,20 @@ void SoundManager::StopBGM() { engineMusic->stopAllSounds(); #endif } -void SoundManager::SetSoundVolume(double volume) { +void SoundManager::SetSoundVolume(int volume) { #ifdef YGOPRO_USE_MINIAUDIO - ma_engine_set_volume(&engineSound, volume); + ma_engine_set_volume(&engineSound, volume / 100.0f); #endif #ifdef YGOPRO_USE_IRRKLANG - engineSound->setSoundVolume(volume); + engineSound->setSoundVolume(volume / 100.0f); #endif } -void SoundManager::SetMusicVolume(double volume) { +void SoundManager::SetMusicVolume(int volume) { #ifdef YGOPRO_USE_MINIAUDIO - ma_engine_set_volume(&engineMusic, volume); + ma_engine_set_volume(&engineMusic, volume / 100.0f); #endif #ifdef YGOPRO_USE_IRRKLANG - engineMusic->setSoundVolume(volume); + engineMusic->setSoundVolume(volume / 100.0f); #endif } } diff --git a/gframe/sound_manager.h b/gframe/sound_manager.h index 94f0918e1c..9cfef9ecd2 100644 --- a/gframe/sound_manager.h +++ b/gframe/sound_manager.h @@ -44,8 +44,8 @@ class SoundManager { void PlayMusic(wchar_t* music, bool loop); void PlayBGM(int scene); void StopBGM(); - void SetSoundVolume(double volume); - void SetMusicVolume(double volume); + void SetSoundVolume(int volume); + void SetMusicVolume(int volume); }; extern SoundManager soundManager; diff --git a/strings.conf b/strings.conf index 09fa5c5b20..13517c20b2 100644 --- a/strings.conf +++ b/strings.conf @@ -431,6 +431,9 @@ !system 1382 人机信息: !system 1384 电脑锁定出剪刀 !system 1385 列表为空,可能未安装合适的人机 +!system 1386 放大菜单 +!system 1387 随窗口缩放选择卡片对话框 +!system 1388 左右互换「是/否」按钮位置 !system 1390 等待行动中... !system 1391 等待行动中.... !system 1392 等待行动中.....