Commit 7af8d174 authored by nanahira's avatar nanahira

Merge branch 'patch-drag-cardtext' of github.com:mercury233/ygopro

parents 9203055e fd4c3855
......@@ -12,6 +12,9 @@ namespace ygo {
ClientField::ClientField() {
panel = 0;
is_dragging_cardtext = false;
dragging_cardtext_start_pos = 0;
dragging_cardtext_start_y = 0;
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
......
......@@ -117,6 +117,9 @@ public:
void RefreshCardCountDisplay();
irr::gui::IGUIElement* panel;
bool is_dragging_cardtext;
int dragging_cardtext_start_pos;
int dragging_cardtext_start_y;
std::vector<int> ancard;
int hovered_controler;
int hovered_location;
......
......@@ -2046,6 +2046,46 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
}
break;
}
case irr::EET_MOUSE_INPUT_EVENT: {
switch(event.MouseInput.Event) {
case irr::EMIE_LMOUSE_PRESSED_DOWN: {
IGUIElement* root = mainGame->env->getRootGUIElement();
position2di mousepos = position2di(event.MouseInput.X, event.MouseInput.Y);
if(root->getElementFromPoint(mousepos) == mainGame->stText) {
if(!mainGame->scrCardText->isVisible()) {
break;
}
is_dragging_cardtext = true;
dragging_cardtext_start_pos = mainGame->scrCardText->getPos();
dragging_cardtext_start_y = event.MouseInput.Y;
return true;
}
break;
}
case irr::EMIE_LMOUSE_LEFT_UP: {
is_dragging_cardtext = false;
break;
}
case irr::EMIE_MOUSE_MOVED: {
if(is_dragging_cardtext) {
if(!mainGame->scrCardText->isVisible()) {
is_dragging_cardtext = false;
break;
}
int step = mainGame->guiFont->getDimension(L"A").Height + mainGame->guiFont->getKerningHeight();
int pos = dragging_cardtext_start_pos + (dragging_cardtext_start_y - event.MouseInput.Y) / step;
int max = mainGame->scrCardText->getMax();
if(pos < 0) pos = 0;
if(pos > max) pos = max;
mainGame->scrCardText->setPos(pos);
mainGame->SetStaticText(mainGame->stText, mainGame->stText->getRelativePosition().getWidth() - 25, mainGame->guiFont, mainGame->showingtext, pos);
}
break;
}
default: break;
}
break;
}
default: break;
}
return false;
......
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