- Joined
- Jul 18, 2010
- Messages
- 2,377
What is a SIMPLESTATUSBAR
A SIMPLESTATUSBAR is a simple frame that shows a blp texture partly (from left to right) based on the SIMPLESTATUSBAR current value vs its max value. The blp Texture is stretched to the total frames size. On default the value can be from 0 to 100 (0 beeing empty, 100 full). 40 would show 40% of the blp.
Its also possible to have a border an overlay text and adding a background blp texture. The barTexture is above the background and will hide more of it as nearer the value is to the max value.
Its also possible to have a border an overlay text and adding a background blp texture. The barTexture is above the background and will hide more of it as nearer the value is to the max value.
Functions
This 3 functions are the ones you should use when alterting the bars Value.
JASS:
native BlzFrameSetValue takes framehandle frame, real value returns nothing
native BlzFrameGetValue takes framehandle frame returns real
native BlzFrameSetMinMaxValue takes framehandle frame, real minValue, real maxValue returns nothing
BlzFrameSetValue
sets the current value.BlzFrameGetValue
gets the local current valueBlzFrameSetMinMaxValue
sets the min max values of the bar.You also might use
BlzFrameSetTexture takes framehandle frame, string texFile, integer flag, boolean blend
to change the used textures during the game.The Frame Definition File
There is no mainframe SIMPLESTATUSBAR in the default fdf, aka not createable without unwanted other frames. Therefore one has to write a custom one and load that custom one over a custom written toc.
Thats the fdf text for 3 SIMPLESTATUSBAR all beeing mainFrames. MyBarEx has a border while MyBar does not. The last has no additional features (background, border, text).
Without the border it is more suited for Faces. One could have the idea to hide or destroy the child but that is in that case no good idea, cause it would crash the game (its a String, Texture thing when one deals with simple frames).
MyBar.TOC
MyBar.fdf
Thats the fdf text for 3 SIMPLESTATUSBAR all beeing mainFrames. MyBarEx has a border while MyBar does not. The last has no additional features (
Without the border it is more suited for Faces. One could have the idea to hide or destroy the child but that is in that case no good idea, cause it would crash the game (its a String, Texture thing when one deals with simple frames).
MyBar.TOC
Code:
war3mapImported\myBar.fdf
Code:
String "MyBarTextTemplate" {
//FontColor 0.99 0.427 0.0705 1.0, //Red Green Blue Alpha 0.0 to 1.0
FontColor 1.0 1.0 1.0 1.0,
FontShadowColor 0.0 0.0 0.0 0.9,
FontShadowOffset 0.001 -0.001,
Font "MasterFont", 0.01, //MasterFont is only valid with "DecorateFileNames,"
}
Frame "SIMPLESTATUSBAR" "MyBarEx" {
Width 0.07, //Default Width
Height 0.012, //Default Height
BarTexture "Replaceabletextures\Teamcolor\Teamcolor00.blp", //Default BarTexture
Layer "BACKGROUND" { //A simpleFrames thing, where this is placed layer wise
Texture "MyBarExBackground"{ //the BACKGROUND Texture named "MyBarExBackground" its also a frame and a child
File "Replaceabletextures\Teamcolor\Teamcolor27.blp", //Default Texture for "MyBarExBackground"
}
}
Frame "SIMPLEFRAME" "MyBarExFrame" { //Child of "MyBarEx"
DecorateFileNames, //Lookup FileNames in a StringList
SetAllPoints, //copy "MyBarEx"
Layer "ARTWORK" {
Texture "MyBarExBorder" {
File "SimpleXpBarBorder", //Default Texture for "MyBarExBorder"
}
String "MyBarExText" INHERITS "MyBarTextTemplate" {
Text "MyBarEx", //Default Text for "MyBarExText" which takes over Data from "MyBarTextTemplate"
}
}
}
}
Frame "SIMPLESTATUSBAR" "MyBar" {
Width 0.07,
Height 0.012,
BarTexture "Replaceabletextures\Teamcolor\Teamcolor00.blp",
Layer "BACKGROUND" {
Texture "MyBarBackground" {
File "Replaceabletextures\Teamcolor\Teamcolor27.blp",
}
}
Frame "SIMPLEFRAME" "MyBarFrame" {
SetAllPoints,
DecorateFileNames,
Layer "ARTWORK" {
String "MyBarText" INHERITS "MyBarTextTemplate" {
Text "MyBar",
}
}
}
}
Frame "SIMPLESTATUSBAR" "MySimpleBar" {
Width 0.07,
Height 0.012,
}
Example MyBar
This jass code creates 3 simpleStatusBars 2 "MyBarEx" and 1 "MyBar". The "MyBarEx" will show the % life and mana of the unit selected. "MyBar" shows the 2 background bar usage with paladin enabled and paladin disabled icon.
Cause a SIMPLESTATUSBAR can only show blp one uses teamcolors to give a bar a color.
There is also the SimpleStatusbar_face2 map which randomly changes the face of arthas between living and deathknight.
It is also possible to use a white Texture and change the color of the bar using
This lines crashed for me in 1.31.1, but work fine in 1.32.1 (reforged).
Cause a SIMPLESTATUSBAR can only show blp one uses teamcolors to give a bar a color.
JASS:
function UpdateBars takes nothing returns nothing
local unit u = GetTriggerUnit()
call BlzFrameSetValue(BlzGetFrameByName("MyBarEx",1), GetUnitLifePercent(u)) //Load the Frame at ("MyBarEx",1) and set its value to the %HP
call BlzFrameSetValue(BlzGetFrameByName("MyBarEx",2), GetUnitManaPercent(u))
set u = null
endfunction
function MyBarCreate takes nothing returns nothing
local framehandle bar = BlzCreateSimpleFrame("MyBarEx", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 1) //Create Bar at createContext 1
local framehandle bar2 = BlzCreateSimpleFrame("MyBarEx", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 2) //createContext 2
local framehandle bar4 = BlzCreateSimpleFrame("MyBar", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 4) //createContext 4, other names so would not be needed.
call BlzFrameSetAbsPoint(bar, FRAMEPOINT_CENTER, 0.5, 0.3) // pos the bar
call BlzFrameSetPoint(bar2, FRAMEPOINT_TOP, bar, FRAMEPOINT_BOTTOM, 0.0, 0.0) // pos bar2 below bar
call BlzFrameSetPoint(bar4, FRAMEPOINT_BOTTOM, bar, FRAMEPOINT_TOP, 0.0, 0.0) // pos bar4 above bar
call BlzFrameSetSize(bar4, 0.04, 0.04) //change the size of bar4
call BlzFrameSetValue(bar4, 35) //Starting value for bar 4.
call BlzFrameSetTexture(bar, "Replaceabletextures\\Teamcolor\\Teamcolor00.blp", 0, true) //change the BarTexture of bar to color red
call BlzFrameSetTexture(bar2, "Replaceabletextures\\Teamcolor\\Teamcolor01.blp", 0, true) //color blue for bar2
call BlzFrameSetTexture(bar4, "Replaceabletextures\\CommandButtons\\BTNHeroPaladin.blp", 0, true) //bar4 to Paladin-Face
call BlzFrameSetTexture(BlzGetFrameByName("MyBarBackground",4), "Replaceabletextures\\CommandButtonsDisabled\\DISBTNHeroPaladin.blp", 0, true) //Change the background to DisabledPaladin-Face. ("MyBarBackground", 4) belongs to Bar4. would Bar4 be a "MyBarEx" one would have to write "MyBarExBackground" cause they are named differently in fdf.
call BlzFrameSetText(BlzGetFrameByName("MyBarExText",1), "Life")
call BlzFrameSetText(BlzGetFrameByName("MyBarExText",2), "Mana")
call BlzFrameSetText(BlzGetFrameByName("MyBarText",4), I2S(R2I(BlzFrameGetValue(bar4)))+"%")
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 99999, "Select an unit to update the Bars")
endfunction
//===========================================================================
function InitTrig_MyBar takes nothing returns nothing
local trigger trig = CreateTrigger()
set gg_trg_MyBar = CreateTrigger()
call TriggerRegisterTimerEventSingle( gg_trg_MyBar, 0.00 )
call TriggerAddAction( gg_trg_MyBar, function MyBarCreate )
call BlzLoadTOCFile("war3mapimported\\mybar.toc")
call TriggerRegisterPlayerSelectionEventBJ(trig, Player(0), true )
call TriggerAddAction(trig, function UpdateBars)
endfunction
There is also the SimpleStatusbar_face2 map which randomly changes the face of arthas between living and deathknight.
JASS:
function Change takes nothing returns nothing
local framehandle fh = BlzGetFrameByName("MyBar",0)
call BlzFrameSetValue(fh, BlzFrameGetValue(fh) + GetRandomReal(-3,3))
set fh = null
endfunction
function Trig_Nahkampf_Initialisierung_Actions takes nothing returns nothing
local framehandle fh = BlzCreateSimpleFrame("MyBar", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0)
call BlzFrameSetAbsPoint(fh, FRAMEPOINT_CENTER, 0.5, 0.4)
call BlzFrameSetValue(fh, 50)
call BlzFrameSetText(BlzGetFrameByName("MyBarText",0), "")
call BlzFrameSetTexture(BlzGetFrameByName("MyBarBackground",0), "Replaceabletextures\\CommandButtons\\BTNHeroDeathKnight.blp", 0,true)
call BlzFrameSetTexture(fh, "Replaceabletextures\\CommandButtons\\BTNArthas.blp", 0,true)
call BlzFrameSetSize(fh, 0.08, 0.08)
call TimerStart(CreateTimer(), 0.08, true, function Change)
endfunction
//===========================================================================
function InitTrig_MyBar takes nothing returns nothing
set gg_trg_MyBar = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_MyBar, 0.00 )
call TriggerAddAction( gg_trg_MyBar, function Trig_Nahkampf_Initialisierung_Actions )
call LoadToc("war3mapimported\\mybar.toc")
endfunction
It is also possible to use a white Texture and change the color of the bar using
JASS:
BlzFrameSetTexture(bar, "ui\\feedback\\progressbar\\human-statbar-color", 0, true)
BlzFrameSetVertexColor(bar, BlzConvertColor(255, 255, 255, 1))
Other UI-Frame Tutorials
The following links might provide more insight into this subject.
UI: Change Lumber Text
[JASS/AI] - UI: Create a TextButton
[JASS/AI] - UI: Positionate Frames (important)
UI: toc-Files
UI: Reading a FDF
UI - The concept of Parent-Frames
[JASS/AI] - UI: FrameEvents and FrameTypes
UI: Frames and Tooltips
[JASS/AI] - UI: Creating a Bar
UI - Simpleframes
UI: What are BACKDROPs?
UI: GLUEBUTTON
UI: TEXTAREA the scrolling Text Frame
UI: EditBox - Text Input
[JASS/AI] - UI: Creating a Cam control
UI: Showing 3 Multiboards
UI: OriginFrames
Default Names for BlzGetFrameByName (Access to Existing game-Frames)
[JASS/AI] - UI: List - Default MainFrames (built in CreateAble)
UI: Change Lumber Text
[JASS/AI] - UI: Create a TextButton
[JASS/AI] - UI: Positionate Frames (important)
UI: toc-Files
UI: Reading a FDF
UI - The concept of Parent-Frames
[JASS/AI] - UI: FrameEvents and FrameTypes
UI: Frames and Tooltips
[JASS/AI] - UI: Creating a Bar
UI - Simpleframes
UI: What are BACKDROPs?
UI: GLUEBUTTON
UI: TEXTAREA the scrolling Text Frame
UI: EditBox - Text Input
[JASS/AI] - UI: Creating a Cam control
UI: Showing 3 Multiboards
UI: OriginFrames
Default Names for BlzGetFrameByName (Access to Existing game-Frames)
[JASS/AI] - UI: List - Default MainFrames (built in CreateAble)
Attachments
Last edited by a moderator: