huds.tf
Main menu buttons - Printable Version

+- huds.tf (https://huds.tf/forum)
+-- Forum: HUD General (https://huds.tf/forum/forumdisplay.php?fid=1)
+--- Forum: HUD Help & Development (https://huds.tf/forum/forumdisplay.php?fid=4)
+--- Thread: Main menu buttons (/showthread.php?tid=1648)



Main menu buttons - Timmy from english books - 31-05-2019

https://imgur.com/a/0ozJVVL

I added the text on image with photoshop just for example. Now the question is, how can I add this text to my main menu and most importantly, add commands when I press it. Im seeing a lot of HUDs do that but when copying the text from other HUD it only shows up as "CExImageButton". Thanks in advance!


RE: Main menu buttons - Revan - 31-05-2019

(31-05-2019, 12:33 PM)Timmy from english books Wrote: https://imgur.com/a/0ozJVVL

I added the text on image with photoshop just for example. Now the question is, how can I add this text to my main menu and most importantly, add commands when I press it. Im seeing a lot of HUDs do that but when copying the text from other HUD it only shows up as "CExImageButton". Thanks in advance!
So -- you want to make a regular element with the control name CExButton or CExImageButton, then add attributes
Code:
defaultbgcolor_override
armedbgcolor_override
depressedbgcolor_override
and set them all to "0 0 0 0"

then add/change 
Code:
border_default
border_armed
to NoBorder

Now for the text:
Text: "labelText"
font: "font"
text align: "textAlignment" - west, center, east, or north-west for top left etc otherwise vertically aligned center
indent text on the X axis: textinsetx
indent text on the Y axis: textinsety
to change text colour use the same format as the background color, except replace b with f (for foreground)

then add 
"sound_depressed" "UI/buttonclick.wav"
"sound_released" "UI/buttonclickrelease.wav"

"command" "dosomething"
put the tag "engine" before the command to make it execute in the console, e.g. "engine map tr_walkway_rc2

this should work, but I rushed writing this and might have forgotten something, let me know if you need any more help


RE: Main menu buttons - Timmy from english books - 31-05-2019

(31-05-2019, 01:51 PM)Revan Wrote:
(31-05-2019, 12:33 PM)Timmy from english books Wrote: https://imgur.com/a/0ozJVVL

I added the text on image with photoshop just for example. Now the question is, how can I add this text to my main menu and most importantly, add commands when I press it. Im seeing a lot of HUDs do that but when copying the text from other HUD it only shows up as "CExImageButton". Thanks in advance!
So -- you want to make a regular element with the control name CExButton or CExImageButton, then add attributes
Code:
defaultbgcolor_override
armedbgcolor_override
depressedbgcolor_override
and set them all to "0 0 0 0"

then add/change 
Code:
border_default
border_armed
to NoBorder

Now for the text:
Text: "labelText"
font: "font"
text align: "textAlignment" - west, center, east, or north-west for top left etc otherwise vertically aligned center
indent text on the X axis: textinsetx
indent text on the Y axis: textinsety
to change text colour use the same format as the background color, except replace b with f (for foreground)

then add 
"sound_depressed" "UI/buttonclick.wav"
"sound_released" "UI/buttonclickrelease.wav"

"command" "dosomething"
put the tag "engine" before the command to make it execute in the console, e.g. "engine map tr_walkway_rc2

this should work, but I rushed writing this and might have forgotten something, let me know if you need any more help

Edit : 

Code:
"ExampleButton"
{
"ControlName"    "CExButton"
"fieldName" "ExampleButton"
"xpos" "c-280"
"ypos" "180"
"wide" "169"
"tall" "24"
"visible" "1"
"enabled" "1"
"font" "BloggerSansRegular14"
"textAlignment" "west"
"labelText" "Okay"
"paintbackground" "0"
"default" "1"
"Command" "engine map tr_walkway_rc2"

   // default style
"defaultBgColor_override" "255 255 255 255"
"defaultFgColor_override" "255 255 255 255"
"border_default" "255 255 255 255"
       
// armed style
"armedBgColor_override" "255 255 200 240"
"armedFgColor_override" "255 255 200 240"
"border_armed" "255 255 200 240"
   
   // depressed style    
"depressedBgColor_override" "255 255 200 255"
"depressedFgColor_override" "255 255 200 255"

// button sounds
"sound_depressed" "UI/buttonclick.wav"
"sound_released" "UI/buttonclickrelease.wav"
}

The button is visible but doesnt work when I click it.


RE: Main menu buttons - Timmy from english books - 31-05-2019

oops, double post.
editing it to this.