About Store Forum Documentation Contact



Post Reply 
Disable highlighting.
Author Message
Salival Offline
Member

Post: #1
Disable highlighting.
I made a custom button to change hover image but how can I remove the highlight on the button? because in the left image the result of highlight makes the button hover image not transparent. I just want my hover image to show, nothing else.

lit = 0.

Cheers. wink

Ps, New design for the game is made, I will show off a preview soon.
(This post was last modified: 10-07-2010 04:10 PM by Salival.)
10-07-2010 03:52 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Disable highlighting.
could you paste the codes for drawing backpack and hover image?
pasting hover image would also make things simpler.
10-07-2010 05:13 PM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #3
RE: Disable highlighting.
I do not know what you want to test, what I want is to get rid of the highlighting when you hover your mouse over a button.

Maybe you can add support for hover and pressed action images in the normal button structure later on. Anyway In my GUI Test program I made simple like this to change image at hover:

Code:
struct CCustomButton : public Button
{
public:
    Image *pImg[2];

public:
    virtual void update(GuiPC &gpc);
};

Code:
void CCustomButton::update(GuiPC &gpc)
{
    if(Gui.msLit() == CAST(CCustomButton, this))
        image = pImg[1];
    else
        image = pImg[0];

    __super::update(gpc);
}

Code:
CCustomButton Btn;

Code:
//! Button Sizes
Vec2 Size = D.pixelToScreenSize(VecI2(51, 54));

//! Create Buttons
Gui += Btn.create(Rect_C(0,0,Size.x, Size.y));

//! Button Textures
Btn.pImg[0] = Images("BtnTex.gfx");
Btn.pImg[1] = Images("BtnTex_Hover.gfx");
10-08-2010 07:32 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Disable highlighting.
Thank you, there is a small bug which instead of highlighting RED it increases ALPHA, I'll fix that.
However there's no option to disable highlighting, you can just extend the draw method, and draw button completely manually.
There's tutorial for drawing button manually. "extending gui objects" or something like that
10-08-2010 11:56 AM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #5
RE: Disable highlighting.
(10-08-2010 11:56 AM)Esenthel Wrote:  Thank you, there is a small bug which instead of highlighting RED it increases ALPHA, I'll fix that.
However there's no option to disable highlighting, you can just extend the draw method, and draw button completely manually.
There's tutorial for drawing button manually. "extending gui objects" or something like that

Thank you for the alpha fix, drawing button manually is not a problem wink

I made this and it works just fine:

Code:
void CCustomButton::draw(GuiPC &gpc)
{
    if(Gui.msLit() == CAST(CCustomButton, this))
        pImg[1]->draw(rect);
    else
        pImg[0]->draw(rect);

    __super::update(gpc);
}
(This post was last modified: 10-08-2010 01:23 PM by Salival.)
10-08-2010 12:56 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #6
RE: Disable highlighting.
Quick question guys. I'm doing something similar to you salival as I had the same problem with buttons getting that square highlight on them that I didn't want.

I'm just wondering though, how do you size a button so the image is the same number of pixels on screen as the original source image? For example, I have a button image that is 32x32 pixels. In the game, I want this button image to come out on screen at exactly 32x32 pixels regardless of the screen resolution.

I've noticed you've got this line in your code.

Code:
//! Button Sizes
Vec2 Size = D.pixelToScreenSize(VecI2(51, 54));

Will this size the button to exactly 51x54 pixels on screen regardless of the resolution? I've read the comments in Display.h regarding this, but can't quite figure it out.
10-09-2010 01:32 AM
Find all posts by this user Quote this message in a reply
Post Reply