Commit fd4c3855 authored by mercury233's avatar mercury233

drag cardtext

parent 392e6d9b
......@@ -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;
......
......@@ -114,6 +114,9 @@ public:
void UpdateDeclarableList();
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;
......
......@@ -1998,6 +1998,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