From 858a2c439eb333b83514b8b7ee93421a0e54369d Mon Sep 17 00:00:00 2001 From: mercury233 Date: Sat, 3 Oct 2020 14:06:16 +0800 Subject: [PATCH 1/3] add wheel switch card in deck --- gframe/deck_con.cpp | 154 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index b5fc8bf560..b56b8da506 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -750,6 +750,160 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ZoomBigCard(mouse_pos.X, mouse_pos.Y); break; } + if(hovered_pos >= 1 && hovered_pos <= 3 && hovered_seq != -1) { + position2di dest; + int pos = hovered_pos; + int seq = hovered_seq; + switch(pos) { + case 1: { + if(event.MouseInput.Wheel > 0) { + if(seq <= 0) { + if(deckManager.current_deck.side.size() > 0) { + pos = 3; + seq = deckManager.current_deck.side.size() - 1; + } else if(deckManager.current_deck.extra.size() > 0) { + pos = 2; + seq = deckManager.current_deck.extra.size() - 1; + } else if(deckManager.current_deck.main.size() > 0) { + pos = 1; + seq = deckManager.current_deck.main.size() - 1; + } else + pos = -1; + } else + seq--; + } else { + if(seq + 1 >= deckManager.current_deck.main.size()) { + if(deckManager.current_deck.extra.size() > 0) { + pos = 2; + seq = 0; + } else if(deckManager.current_deck.side.size() > 0) { + pos = 3; + seq = 0; + } else if(deckManager.current_deck.main.size() > 0) { + pos = 1; + seq = 0; + } else + pos = -1; + } else + seq++; + } + break; + } + case 2: { + if(event.MouseInput.Wheel > 0) { + if(seq <= 0) { + if(deckManager.current_deck.main.size() > 0) { + pos = 1; + seq = deckManager.current_deck.main.size() - 1; + } else if(deckManager.current_deck.side.size() > 0) { + pos = 2; + seq = deckManager.current_deck.side.size() - 1; + } else if(deckManager.current_deck.extra.size() > 0) { + pos = 1; + seq = deckManager.current_deck.extra.size() - 1; + } else + pos = -1; + } else + seq--; + } else { + if(seq + 1 >= deckManager.current_deck.extra.size()) { + if(deckManager.current_deck.side.size() > 0) { + pos = 3; + seq = 0; + } else if(deckManager.current_deck.main.size() > 0) { + pos = 1; + seq = 0; + } else if(deckManager.current_deck.extra.size() > 0) { + pos = 2; + seq = 0; + } else + pos = -1; + } else + seq++; + } + break; + } + case 3: { + if(event.MouseInput.Wheel > 0) { + if(seq <= 0) { + if(deckManager.current_deck.extra.size() > 0) { + pos = 2; + seq = deckManager.current_deck.extra.size() - 1; + } else if(deckManager.current_deck.main.size() > 0) { + pos = 1; + seq = deckManager.current_deck.main.size() - 1; + } else if(deckManager.current_deck.side.size() > 0) { + pos = 3; + seq = deckManager.current_deck.side.size() - 1; + } else + pos = -1; + } else + seq--; + } else { + if(seq + 1 >= deckManager.current_deck.side.size()) { + if(deckManager.current_deck.main.size() > 0) { + pos = 1; + seq = 0; + } else if(deckManager.current_deck.extra.size() > 0) { + pos = 2; + seq = 0; + } else if(deckManager.current_deck.side.size() > 0) { + pos = 3; + seq = 0; + } else + pos = -1; + } else + seq++; + } + break; + } + } + if(pos < 0) + break; + int lx; + float dx; + switch(pos) { + case 1: { + if(deckManager.current_deck.main.size() <= 40) { + dx = 436.0f / 9; + lx = 10; + } else { + lx = (deckManager.current_deck.main.size() - 41) / 4 + 11; + dx = 436.0f / (lx - 1); + } + dest.X = 314 + CARD_THUMB_WIDTH / 2 + (seq % lx) * dx; + dest.Y = 164 + CARD_THUMB_HEIGHT / 2 + (seq / lx) * 68; + break; + } + case 2: { + if(deckManager.current_deck.extra.size() <= 10) + dx = 436.0f / 9; + else + dx = 436.0f / (deckManager.current_deck.extra.size() - 1); + dest.X = 314 + CARD_THUMB_WIDTH / 2 + seq * dx; + dest.Y = 466 + CARD_THUMB_HEIGHT / 2; + break; + } + case 3: { + if(deckManager.current_deck.side.size() <= 10) + dx = 436.0f / 9; + else + dx = 436.0f / (deckManager.current_deck.side.size() - 1); + dest.X = 314 + CARD_THUMB_WIDTH / 2 + seq * dx; + dest.Y = 564 + CARD_THUMB_HEIGHT / 2; + break; + } + } + dest = mainGame->Resize(dest.X, dest.Y); +#ifdef _WIN32 + POINT pt; + pt.x = dest.X; + pt.y = dest.Y; + ClientToScreen(mainGame->hWnd, &pt); + SetCursorPos(pt.x, pt.y); +#endif + break; + } if(!mainGame->scrFilter->isVisible()) break; if(mainGame->env->hasFocus(mainGame->scrFilter)) From 4964681f35c5caca6e09330fcc463d910d706bdd Mon Sep 17 00:00:00 2001 From: mercury233 Date: Sun, 18 Oct 2020 23:37:15 +0800 Subject: [PATCH 2/3] add sound --- gframe/deck_con.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index b56b8da506..00e21c438e 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -902,6 +902,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ClientToScreen(mainGame->hWnd, &pt); SetCursorPos(pt.x, pt.y); #endif + soundManager.PlaySoundEffect(SOUND_CARD_DROP); break; } if(!mainGame->scrFilter->isVisible()) From c3574c79cba7aed63f07fa6df478e49cc526e45f Mon Sep 17 00:00:00 2001 From: mercury233 Date: Sun, 1 May 2022 11:56:42 +0800 Subject: [PATCH 3/3] update wheel --- gframe/deck_con.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/gframe/deck_con.cpp b/gframe/deck_con.cpp index 7fef194495..dce46454a8 100644 --- a/gframe/deck_con.cpp +++ b/gframe/deck_con.cpp @@ -1195,6 +1195,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { break; } if(hovered_pos >= 1 && hovered_pos <= 3 && hovered_seq != -1) { + mainGame->env->setFocus(0); position2di dest; int pos = hovered_pos; int seq = hovered_seq; @@ -1308,15 +1309,43 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { float dx; switch(pos) { case 1: { - if(deckManager.current_deck.main.size() <= 40) { - dx = 436.0f / 9; + float dy = 68; + if(showing_pack) { + if(mainGame->scrPackCards->isVisible() && seq > 0) { + seq = seq - 12 * mainGame->scrPackCards->getPos(); + } + int mainsize = deckManager.current_deck.main.size(); lx = 10; + if(mainsize > 10 * 7) + lx = 11; + if(mainsize > 11 * 7) + lx = 12; + if(mainsize > 60) + dy = 66; + dx = (mainGame->scrPackCards->isVisible() ? 414.0f : 436.0f) / (lx - 1); + if(mainGame->scrPackCards->isVisible() && seq >= 12 * 7) { + int l = (seq - 12 * 6) / 12; + mainGame->scrPackCards->setPos(mainGame->scrPackCards->getPos() + l); + seq = seq - 12 * l; + } + if(seq < 0) { + mainGame->scrPackCards->setPos(mainGame->scrPackCards->getPos() - 1); + seq = seq + 12; + } + if(seq == 0) { + mainGame->scrPackCards->setPos(0); + } } else { - lx = (deckManager.current_deck.main.size() - 41) / 4 + 11; - dx = 436.0f / (lx - 1); + if(deckManager.current_deck.main.size() <= 40) { + dx = 436.0f / 9; + lx = 10; + } else { + lx = (deckManager.current_deck.main.size() - 41) / 4 + 11; + dx = 436.0f / (lx - 1); + } } dest.X = 314 + CARD_THUMB_WIDTH / 2 + (seq % lx) * dx; - dest.Y = 164 + CARD_THUMB_HEIGHT / 2 + (seq / lx) * 68; + dest.Y = 164 + CARD_THUMB_HEIGHT / 2 + (seq / lx) * dy; break; } case 2: {