Icon Buttons
- DinkyDyeAussie
- Posts: 260
- Joined: Fri Feb 10, 2012 10:39 am
- Location: Australia
Icon Buttons
In the original warcraft 2, and in freecraft, all the icons depressed when you clicked them:
So from this: to this: But in stratagus, this doesn't exist. I'd like to request the small features like this, and the highlighting of all the game menu button's text when you hover the mouse/click the mouse on them be put back in the game. Subtleties like this make a good game better.
I'm being a nag I feel, but I like these features to be in the game.
So from this: to this: But in stratagus, this doesn't exist. I'd like to request the small features like this, and the highlighting of all the game menu button's text when you hover the mouse/click the mouse on them be put back in the game. Subtleties like this make a good game better.
I'm being a nag I feel, but I like these features to be in the game.
Re: Icon Buttons
That would indeed be nice, and if the code was already in freecraft and we have the source code for the version which had the feature, then it shouldn't be too hard to reimplement it.
- DinkyDyeAussie
- Posts: 260
- Joined: Fri Feb 10, 2012 10:39 am
- Location: Australia
Re: Icon Buttons
I've been looking through the old freecraft 1.18 source and trying to figure out how to port it accross to the newest source in stratagus. Fun times, but having a few pointers as to how to would be good.
Where are Cyber and Jarod when you need them? This room service sucks!
Where are Cyber and Jarod when you need them? This room service sucks!
- DinkyDyeAussie
- Posts: 260
- Joined: Fri Feb 10, 2012 10:39 am
- Location: Australia
Re: Icon Buttons
Still looking through stratagus code. To be honest, I feel the icons should be treated more like buttons than static images that you click. The code for the normal buttons (MenuButton and GameMenuButton) reflect this - with parameters for default, hover, and click, with the click activating the code to show the button has been clicked by changing the image.
Icons really don't have different images for the same icon, and as such it will be more of a code hack that makes it look as though the icon is depressed when clicked, like it is in freecraft. The code is there also in stratagus, but only for the tile button in the map editor, and even then it doesn't look depressed when clicked like the icons do in freecraft.
Here's the code from freecraft that (I think) shows the icon depressed:
...and the code from "editloop.cpp" in the stratagus code:
Pretty much exactly the same code, but it's exclusive to editloop.cpp and not available to icons.cpp to use for all the other icons - of course we could just rename, adjust and add this variable to icons.h, and both editloop and icons.cpp could use it then.
Also I find that whenever you click a button, the action isn't passed until you release the mouse button, where as with the icons the action is passed as soon as you click it. Again, Warcraft 2 icons behaved like the buttons do, and didn't pass the action until mouse release on the icon, and if you had clicked the icon, but then release OFF the icon, the action wouldn't be passed, just like the buttons.
This could be an LUA switch as well so if people wanted to have the old school "press the icon, and the icon looks pressed then the action is passed", or the newer "press the icon, action passed straight away with no pressed look", it would keep everyone happy. And this could be used by anyone, for any game being made with the stratagus engine.
Just a few ideas for you
Icons really don't have different images for the same icon, and as such it will be more of a code hack that makes it look as though the icon is depressed when clicked, like it is in freecraft. The code is there also in stratagus, but only for the tile button in the map editor, and even then it doesn't look depressed when clicked like the icons do in freecraft.
Here's the code from freecraft that (I think) shows the icon depressed:
Code: Select all
global void DrawUnitIcon(const Player* player, Icon* icon, unsigned flags, int x, int y)
{
int color;
int width;
int height;
DebugCheck(!icon);
//
// Black border around icon with gray border if active.
//
color = (flags & IconActive) ? ColorGray : ColorBlack;
width = icon->Width;
height = icon->Height;
VideoDrawRectangleClip(color, x, y, width + 7, height + 7);
VideoDrawRectangleClip(ColorBlack, x + 1, y + 1, width + 5, height + 5);
// _| Shadow
VideoDrawVLine(ColorGray, x + width + 4, y + 5, height - 1);
VideoDrawVLine(ColorGray, x + width + 5, y + 5, height - 1);
VideoDrawHLine(ColorGray, x + 5, y + height + 4, width + 1);
VideoDrawHLine(ColorGray, x + 5, y + height + 5, width + 1);
// |~ Light
color = (flags & IconClicked) ? ColorGray : ColorWhite;
VideoDrawHLine(color, x + 5, y + 3, width + 1);
VideoDrawHLine(color, x + 5, y + 4, width + 1);
VideoDrawVLine(color, x + 3, y + 3, height + 3);
VideoDrawVLine(color, x + 4, y + 3, height + 3);
if (flags & IconClicked) {
x += 5;
y += 5;
} else {
x += 4;
y += 4;
}
DrawIcon(player, icon, x, y);
if (flags & IconSelected) {
VideoDrawRectangleClip(ColorGreen, x, y, width, height);
} else if (flags & IconAutoCast) {
VideoDrawRectangleClip(ColorBlue, x, y, width, height);
}
}
Code: Select all
static void DrawTileIcon(unsigned tilenum, unsigned x, unsigned y, unsigned flags)
{
Uint32 color = (flags & IconActive) ? ColorGray : ColorBlack;
Video.DrawRectangleClip(color, x, y, PixelTileSize.x + 7, PixelTileSize.y + 7);
Video.DrawRectangleClip(ColorBlack, x + 1, y + 1, PixelTileSize.x + 5, PixelTileSize.y + 5);
// Icon Shadow Edge
Video.DrawVLine(ColorGray, x + PixelTileSize.x + 4, y + 5, PixelTileSize.y - 1); // _|
Video.DrawVLine(ColorGray, x + PixelTileSize.x + 5, y + 5, PixelTileSize.y - 1);
Video.DrawHLine(ColorGray, x + 5, y + PixelTileSize.y + 4, PixelTileSize.x + 1);
Video.DrawHLine(ColorGray, x + 5, y + PixelTileSize.y + 5, PixelTileSize.x + 1);
// Icon Light Edge
color = (flags & IconClicked) ? ColorGray : ColorWhite;
Video.DrawHLine(color, x + 5, y + 3, PixelTileSize.x + 1);
Video.DrawHLine(color, x + 5, y + 4, PixelTileSize.x + 1);
Video.DrawVLine(color, x + 3, y + 3, PixelTileSize.y + 3);
Video.DrawVLine(color, x + 4, y + 3, PixelTileSize.y + 3);
if (flags & IconClicked)
{
x += 5;
y += 5;
} else {
x += 4;
y += 4;
}
Map.TileGraphic->DrawFrameClip(Map.Tileset->tiles[tilenum].tile, x + 1, y + 1);
if (flags & IconSelected) {
Video.DrawRectangleClip(ColorGreen, x, y, PixelTileSize.x + 1, PixelTileSize.y + 1);
} else if (flags & IconAutoCast) {
Video.DrawRectangleClip(ColorBlue, x, y, PixelTileSize.x + 1, PixelTileSize.y + 1);
}
}
Also I find that whenever you click a button, the action isn't passed until you release the mouse button, where as with the icons the action is passed as soon as you click it. Again, Warcraft 2 icons behaved like the buttons do, and didn't pass the action until mouse release on the icon, and if you had clicked the icon, but then release OFF the icon, the action wouldn't be passed, just like the buttons.
This could be an LUA switch as well so if people wanted to have the old school "press the icon, and the icon looks pressed then the action is passed", or the newer "press the icon, action passed straight away with no pressed look", it would keep everyone happy. And this could be used by anyone, for any game being made with the stratagus engine.
Just a few ideas for you
- DinkyDyeAussie
- Posts: 260
- Joined: Fri Feb 10, 2012 10:39 am
- Location: Australia
Re: Icon Buttons
Also what's the go with this code:
It's just below this code:
which defines the menu button. So technically speaking, we should be able to define any button we want to use right? If so, can we use it to define a clickable icon?
Code: Select all
void DrawUserDefinedButtons()
{
for (size_t i = 0; i < UI.UserButtons.size(); ++i) {
const CUIUserButton &button = UI.UserButtons[i];
if (button.Button.X != -1) {
DrawUIButton(button.Button.Style,
(ButtonAreaUnderCursor == ButtonAreaUser
&& size_t(ButtonUnderCursor) == i ? MI_FLAGS_ACTIVE : 0) |
(button.Clicked ? MI_FLAGS_CLICKED : 0),
button.Button.X, button.Button.Y,
button.Button.Text);
}
}
}
Code: Select all
static void DrawMenuButtonArea_noNetwork()
{
if (UI.MenuButton.X != -1) {
DrawUIButton(UI.MenuButton.Style,
(ButtonAreaUnderCursor == ButtonAreaMenu
&& ButtonUnderCursor == ButtonUnderMenu ? MI_FLAGS_ACTIVE : 0) |
(GameMenuButtonClicked ? MI_FLAGS_CLICKED : 0),
UI.MenuButton.X, UI.MenuButton.Y,
UI.MenuButton.Text);
}
}
Re: Icon Buttons
I'm sorry, but I'm no longer active on stratagus...DinkyDyeAussie wrote:Where are Cyber and Jarod when you need them? This room service sucks!
Re: Icon Buttons
That's sad, but I'm very thankful for all the work you've put into the engine, merci!jarod42 wrote: I'm sorry, but I'm no longer active on stratagus...
- DinkyDyeAussie
- Posts: 260
- Joined: Fri Feb 10, 2012 10:39 am
- Location: Australia
Re: Icon Buttons
It's ok man, Will miss your contributions but you have helped alot with your knowledge of the engine too Are you still active in BOSWars?
Re: Icon Buttons
I'm no longer active on stratagus engine and games, sorry. (Anyway, I wasn't active on Bos, but on War*gus).DinkyDyeAussie wrote:It's ok man, Will miss your contributions but you have helped alot with your knowledge of the engine too Are you still active in BOSWars?
I'm now active on MaxR (a clone of Interplay Max).
- DinkyDyeAussie
- Posts: 260
- Joined: Fri Feb 10, 2012 10:39 am
- Location: Australia
Re: Icon Buttons
I had a look at MaxR yesterday. Looks alright Never played the original though.