• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Button Highlight Effect

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2020
Messages
86
Is there a trigger or pack to highlight a BTN or to show an arrow pointing to a BTN?

LTW has a shimmer around a button, kinda what I'm looking for (best image I could find)
1645174418358.png
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
I think all of the examples are in Lua, so you'd need to convert them to Jass. They're very similar though, in most cases you just need to add a word like "call" or "set" which the compiler will probably tell you about.

For example the AutoCast code in that tutorial looks like this:
Lua:
function Test()
    -- create the button and place it onto the center of the screen
    local button = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
    BlzFrameSetAbsPoint(button, FRAMEPOINT_CENTER, 0.4, 0.3)
    BlzFrameSetSize(button, 0.039, 0.039)

    -- create a Sprite that copies the button's positions
    local model =  BlzCreateFrameByType("SPRITE", "SpriteName", button, "", 0)
    BlzFrameSetAllPoints(model, button)
    -- apply the model
    BlzFrameSetModel(model, "UI\\Feedback\\Autocast\\UI-ModalButtonOn.mdl", 0)
    -- Models don't care about Frame Size, to resize them one needs to scale them. The default CommandButton has a Size of 0.039.
    BlzFrameSetScale(model, BlzFrameGetWidth(button)/0.039)
end

And here it is converted to Jass:
vJASS:
function Test takes nothing returns nothing
    // create the button and place it onto the center of the screen
    local framehandle button = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
    // create a Sprite frame
    local framehandle model =  BlzCreateFrameByType("SPRITE", "SpriteName", button, "", 0)

    // position and size the button frame
    call BlzFrameSetAbsPoint(button, FRAMEPOINT_CENTER, 0.4, 0.3)
    call BlzFrameSetSize(button, 0.039, 0.039)

    // Note: I had to create the Sprite frame a few lines up because you can only declare local variables at the start of a Jass function

    // this makes the model copy the position of the button
    call BlzFrameSetAllPoints(model, button)
    // apply the model
    call BlzFrameSetModel(model, "UI\\Feedback\\Autocast\\UI-ModalButtonOn.mdl", 0)
    // Models don't care about Frame Size, to resize them one needs to scale them. The default CommandButton has a Size of 0.039.
    call BlzFrameSetScale(model, BlzFrameGetWidth(button)/0.039)
endfunction
You may need to rename the local variables, the name button could be used for other things, I'm not sure.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
It wants you to rename the variable button as that name is already used for something else. So replace all instances of "button" with let's say "btn".

A type is an Integer, Boolean, Real, String, Player, Item, Unit, etc... so I guess Button is a type as well (maybe a Dialog button, that'd make sense).
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
Those are local variables in the code, you can't reference them outside of their function.

Also, the model is the autocast sprite, the button is what it's attached to. You could probably tweak the code to not even create the button in the first place and just get the model (sprite). I'm not sure though as I've never created a sprite before. The tutorial probably has the answer to this.

Anyway, you can try to add this to the code after creating the button (btn) to hide it but that might hide the model along with it since they're paired:
vJASS:
call BlzFrameSetVisible(btn, false)

There's tutorials on creating Icons that you can look into as well. They're pretty straightforward, just remember to convert the code from Lua to Jass. You can use my conversion example above as a guide.
 
Last edited:
Status
Not open for further replies.
Top