Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions gframe/deck_con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,7 @@ void DeckBuilder::Initialize() {
mainGame->btnSideSort->setVisible(false);
mainGame->btnSideReload->setVisible(false);
if (mainGame->gameConf.use_lflist) {
if (mainGame->gameConf.default_lflist >= 0 && mainGame->gameConf.default_lflist < (int)deckManager._lfList.size()) {
filterList = &deckManager._lfList[mainGame->gameConf.default_lflist];
}
else {
mainGame->gameConf.default_lflist = 0;
filterList = &deckManager._lfList.front();
}
filterList = &deckManager._lfList[default_lflist_index];
}
else {
filterList = &deckManager._lfList.back();
Expand Down
1 change: 1 addition & 0 deletions gframe/deck_con.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class DeckBuilder: public irr::IEventReceiver {
std::mt19937 rnd;

const LFList* filterList{};
size_t default_lflist_index{};
std::vector<const CardDataC*> results;
wchar_t result_string[8]{};
std::vector<std::wstring> expansionPacks;
Expand Down
25 changes: 18 additions & 7 deletions gframe/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1951,10 +1951,18 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
break;
}
case CHECKBOX_LFLIST: {
mainGame->gameConf.use_lflist = mainGame->chkLFlist->isChecked() ? 1 : 0;
mainGame->cbLFlist->setEnabled(mainGame->gameConf.use_lflist);
mainGame->cbLFlist->setSelected(mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : mainGame->cbLFlist->getItemCount() - 1);
mainGame->cbHostLFlist->setSelected(mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : mainGame->cbHostLFlist->getItemCount() - 1);
if (mainGame->chkLFlist->isChecked()) {
mainGame->gameConf.use_lflist = 1;
mainGame->cbLFlist->setEnabled(true);
mainGame->cbLFlist->setSelected(mainGame->deckBuilder.default_lflist_index);
mainGame->cbHostLFlist->setSelected(mainGame->deckBuilder.default_lflist_index);
Comment thread
salix5 marked this conversation as resolved.
}
else {
mainGame->gameConf.use_lflist = 0;
mainGame->cbLFlist->setEnabled(false);
mainGame->cbLFlist->setSelected(mainGame->cbLFlist->getItemCount() - 1);
mainGame->cbHostLFlist->setSelected(mainGame->cbHostLFlist->getItemCount() - 1);
}
mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->cbLFlist->getSelected()];
return true;
break;
Expand All @@ -1965,9 +1973,12 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch(id) {
case COMBOBOX_LFLIST: {
mainGame->gameConf.default_lflist = mainGame->cbLFlist->getSelected();
mainGame->cbHostLFlist->setSelected(mainGame->gameConf.default_lflist);
mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->gameConf.default_lflist];
int sel = mainGame->cbLFlist->getSelected();
if (sel != -1) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently not necessary. One empty lflist is always be pushed to deckManager._lfList, also we never clear cbLFlist, nor setSelected to -1.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing -1 to index is not acceptable.
I don't think ygopro should fight against every combobox like:
Does this combobox return -1?
Surely not.
Oh wait...

I suppose that checking selected value of any combobox is a good practice.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, only the deck list combo box can be empty. The other combo boxes should never be empty in theory, so it's fine to use them directly.

mainGame->deckBuilder.default_lflist_index = mainGame->cbLFlist->getSelected();
mainGame->cbHostLFlist->setSelected(sel);
mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->deckBuilder.default_lflist_index];
Comment thread
salix5 marked this conversation as resolved.
Outdated
}
return true;
break;
}
Expand Down
8 changes: 5 additions & 3 deletions gframe/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ bool Game::Initialize() {
device->getLogger()->setLogLevel(irr::ELOG_LEVEL::ELL_ERROR);
#endif
deckManager.LoadLFList();
if (gameConf.default_lflist >= 0 && gameConf.default_lflist < (int)deckManager._lfList.size())
deckBuilder.default_lflist_index = gameConf.default_lflist;
driver = device->getVideoDriver();
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
driver->setTextureCreationFlag(irr::video::ETCF_OPTIMIZED_FOR_QUALITY, true);
Expand Down Expand Up @@ -240,7 +242,7 @@ bool Game::Initialize() {
cbHostLFlist = env->addComboBox(irr::core::rect<irr::s32>(140, 25, 300, 50), wCreateHost);
for(unsigned int i = 0; i < deckManager._lfList.size(); ++i)
cbHostLFlist->addItem(deckManager._lfList[i].listName.c_str(), deckManager._lfList[i].hash);
cbHostLFlist->setSelected(gameConf.use_lflist ? gameConf.default_lflist : cbHostLFlist->getItemCount() - 1);
cbHostLFlist->setSelected(gameConf.use_lflist ? deckBuilder.default_lflist_index : cbHostLFlist->getItemCount() - 1);
Comment thread
salix5 marked this conversation as resolved.
env->addStaticText(dataManager.GetSysString(1225), irr::core::rect<irr::s32>(20, 60, 220, 80), false, false, wCreateHost);
cbRule = env->addComboBox(irr::core::rect<irr::s32>(140, 55, 300, 80), wCreateHost);
cbRule->setMaxSelectionRows(10);
Expand Down Expand Up @@ -485,7 +487,7 @@ bool Game::Initialize() {
for(unsigned int i = 0; i < deckManager._lfList.size(); ++i)
cbLFlist->addItem(deckManager._lfList[i].listName.c_str());
cbLFlist->setEnabled(gameConf.use_lflist);
cbLFlist->setSelected(gameConf.use_lflist ? gameConf.default_lflist : cbLFlist->getItemCount() - 1);
cbLFlist->setSelected(gameConf.use_lflist ? deckBuilder.default_lflist_index : cbLFlist->getItemCount() - 1);
Comment thread
salix5 marked this conversation as resolved.
posY += 30;
chkEnableSound = env->addCheckBox(gameConf.enable_sound, irr::core::rect<irr::s32>(posX, posY, posX + 120, posY + 25), tabSystem, -1, dataManager.GetSysString(1279));
chkEnableSound->setChecked(gameConf.enable_sound);
Expand Down Expand Up @@ -1579,7 +1581,7 @@ void Game::SaveConfig() {
std::fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0));
std::fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0));
std::fprintf(fp, "use_lflist = %d\n", gameConf.use_lflist);
std::fprintf(fp, "default_lflist = %d\n", gameConf.default_lflist);
std::fprintf(fp, "default_lflist = %zu\n", deckBuilder.default_lflist_index);
Comment thread
salix5 marked this conversation as resolved.
Outdated
std::fprintf(fp, "default_rule = %d\n", gameConf.default_rule == DEFAULT_DUEL_RULE ? 0 : gameConf.default_rule);
std::fprintf(fp, "hide_setname = %d\n", gameConf.hide_setname);
std::fprintf(fp, "hide_hint_button = %d\n", gameConf.hide_hint_button);
Expand Down
Loading