Wargus / wargus

Importer and scripts for Warcraft II: Tides of Darkness, the expansion Beyond the Dark Portal, and Aleonas Tales
GNU General Public License v2.0
355 stars 55 forks source link

Clickable Icons #107

Closed timfel closed 8 years ago

timfel commented 8 years ago

OK, so I've asked this on the stratagus forum, but I guess things don't move as fast there, so I will ask here.

I have managed to get the icons to animate properly so that when you click them the look as though they get depressed down. My problem is, that all the icons (except for the stop, and stand-ground icons) all react to the mouse click instantly, whereas in the original Warcraft 2, the icons didn't execute the action until after you had released the mouse button.

I skimmed through "buttons.cpp" and "buttons.h" to see if I could find anything that would help me to make the action happen after mouse button release. I found the variable:

void Button::mouseClick(int, int, int button, int)
{
    if (button == MouseInput::LEFT)
    {
        generateAction();   
    }
}

A few lines below that I found this:

void Button::mouseRelease(int, int, int button)
{
    if (button == MouseInput::LEFT && hasMouse())
    {
        mMouseDown = false;
    }
}

I put the "generateAction();" variable in the mouseRelease code, but had no luck. I think this code affects the buttons, and not the icons...Is there an equivelent kind of thing for the icons?

All I want is for icons to behave as follows:

Mouse over icon > click icon > icon shows it's been pressed > release button > icon returns to default look > action is executed.

and this:

Mouse over icon > click icon > icon shows it's been pressed > move mouse off icon (with mouse button still pressed) > icon returns to default look > action is NOT executed.


Imported from Launchpad using lp2gh.

timfel commented 8 years ago

(by iddqd-mail) Fixed in rev.1718

timfel commented 8 years ago

(by dinky-dye-aussie) Thanks Cybermind.

Here's a bit of code to put in icons.cpp, on line 211, after the "DrawUnitIcon" position shift code. Makes the icons look alot more like the original war2 ones did when they were pressed.

        Video.DrawRectangle(ColorGray, pos.x, pos.y, 48, 40);
        Video.DrawHLine(ColorDarkGray, pos.x - 1, pos.y - 1, 49);
        Video.DrawVLine(ColorDarkGray, pos.x - 1, pos.y, 39);
        Video.DrawHLine(ColorDarkGray, pos.x - 1, pos.y + 39, 2);

It's awesome work you're doing man with getting all these bugs sorted out :) Thanks again :) I'll have a vodka shot as a tribute to your efforts :)