- Joined
- Mar 18, 2012
- Messages
- 1,716
UIAPI
Collection of the entire API of the UIPackage.
JASS:
//! novjass
//*
//* Collection of the entire UIPackage API:
//* =======================================
//*
//* Some functions have a UI_ prefix to avoid code conflicts.
//*
//* ==========================
//* Constants:
//* ==========================
//* The dummy id should match a unit using the dummy.mdx from Vexorian.
constant integer EVENT_PLAYER_UI = 1
constant real UI_MOUSE_DOUBLE_CLICK = .5
constant timer UI_STAMP = CreateTimer()
constant rect UI_RECT = Rect(0, 0, 0, 0)
constant real UI_PERFECT_SCREEN_RATIO = 1.803
constant real UI_TILE_SIZE = 64.00
//* ==========================
//* Non constants:
//* ==========================
//* UIBorder related:
//* =================
//* You can change these values, between
//* two border creations. Make sure the string paths do exist.
//* "null" and "" are considered as valid ( empty ) string path.
boolean UI_BORDER_INCLUDED_IN_RECT = false//* Frames the rect or is inside borders?
real UI_BORDER_WIDTH = 32.
ARGB UI_BORDER_BACKGROUND_COLOR = 0xFFFFFFFF
integer UI_BORDER_IMAGE_TYPE = IMAGE_TYPE_OCCLUSION_MASK
string UI_BORDER_BACKGROUND = "war3mapImported\\background.TGA"
string UI_BORDER_LEFT = "war3mapImported\\BorderLeftNE.TGA"
string UI_BORDER_RIGHT = "war3mapImported\\BorderRightNE.TGA"
string UI_BORDER_TOP = "war3mapImported\\BorderUpNE.TGA"
string UI_BORDER_BOTTOM = "war3mapImported\\BorderDownNE.TGA"
string UI_BORDER_BOTTOM_LEFT = "war3mapImported\\BorderDownLeftNE.TGA"
string UI_BORDER_BOTTOM_RIGHT = "war3mapImported\\BorderDownRightNE.TGA"
string UI_BORDER_TOP_LEFT = "war3mapImported\\BorderUpLeftNE.TGA"
string UI_BORDER_TOP_RIGHT = "war3mapImported\\BorderUpRightNE.TGA"
//* ==========================
//* library UIPackage:
//* ==========================
//*
//* List UIPackage as requirement for your custom UIs to place all UI libraries in proper compile order.
uses UIBasic, UIBorder, UIButton, UIWindow, UICamera optional UISound optional UIBoard
//*
//* ==========================
//* library UIBasic:
//* ==========================
native UnitAlive takes unit id returns boolean
//* Analogous to GetLocalPlayer(), but faster.
constant function GetLocalClient takes nothing returns player
//* Use on EVENT_PLAYER_UI_SCREEN.
constant function UI_GetTriggerPlayer takes nothing returns player
//* Properly toogles on and off unit indexing tools.
//* Returns the previous "enabled" setting of the unit indexer.
function ToogleUnitIndexer takes boolean enable returns boolean
function IsPlayerUser takes player p returns boolean
function IsPlayerComputer takes player p returns boolean
//* Registers code to UI events.
//* Outsmarts pJass. Triggerconditions can return null.
function UI_RegisterPlayerEvent takes integer id, code func returns nothing
//* Returns the previous activity setup of the indexing tool.
//* So you can disable/enable it correctly after using this function.
function ToogleUnitIndexer takes boolean enable returns boolean
//* Searches for "static method init" in the struct and calls its.
module UIInit
//* ==========================
//* library UICamera:
//* ==========================
//* UICamera API runs automatically when an UI is shown/hidden.
//* UI_StartCamera is called after EVENT_PLAYER_UI fires.
function UI_StartCamera takes player p, real x, real y, real width, real height returns nothing
//* UI_StopCamera is called before EVENT_PLAYER_UI fires.
function UI_StopCamera takes player p returns nothing
//* ==========================
//* library UIScreen:
//* ==========================
function IsPlayerInUI takes player p returns boolean
function GetPlayerUI takes player p returns UIScreen
//* New jass custom type UIScreen
//* The parent struct of all custom UIs.
struct UIScreen
readonly player user
readonly integer userId
readonly real originX
readonly real originY
readonly real width
readonly real height
readonly boolean enabled
readonly real tileSize//* by default set to 64.
//* Shows or hides a UIScreen for player "user". Fires EVENT_PLAYER_UI.
//* Only one screen per player can be shown during the same time.
method show takes boolean flag returns nothing
//* Fires after calling method show.
stub method onShow takes boolean flag returns nothing
//* UIWindow related API:
//* =====================
//* typeId is the struct id of the UIWindow.
//* We have to add windows to screens manually,
//* because JassHelper doesn't support an onCreate stub method.
//* If "autostart" is true, the window always opens when the screen is shown.
method addWindowOfType takes integer typeId, integer index, boolean autostart returns nothing
//* Get(), Has() and IsOpen()
method getWindowOfType takes integer typeId returns UIWindow
method hasWindowOfType takes integer typeId returns boolean
method isWindowOfTypeOpen takes integer typeId returns boolean
//* UIs are based on 64x64 tile size. Changing the tile size affects the scaling of all objects.
//* --> setTileSize(32.) will automatically scale down all visual objects by the factor 2.
method setTileSize takes real newSize returns nothing
//* Creator:
static method create takes player p, real x, real y, real width, real height returns UIScreen
//* Destructor: Also destroys all added UIWindow instances.
//* You can clean up you child structs via method onDestroy.
method destroy takes nothing returns nothing
//* Open() and Close(). Internal API. Don't use those two.
method openWindowOfType takes integer typeId returns boolean
method closeWindowOfType takes integer typeId returns boolean
//* ==========================
//* library UIButton:
//* ==========================
constant function UI_GetLastCreatedButton takes nothing returns UIButton
//* New jass custom type UIButton.
//* Mostly internal API. Interesting for you is the public struct member "data".
struct UIButton
//* Create a new button. Uses destructable objects.
static method createDest takes integer whichType, player p, integer objectId, Track whichTrack, real size, boolean isEnabled returns UIButton
//* Create a new button. Uses the image type.
static method createImg takes integer whichType, player p, string file, Track whichTrack, real size, boolean isEnabled returns UIButton
method destroy takes nothing returns nothing
method show takes boolean flag returns nothing
//* Adds a temporary model on the button. Can be of type image or destructable.
method addDest takes integer id, boolean showNow returns nothing
method addImage takes string file, boolean showNow returns nothing
method purge takes nothing returns nothing
//* Purges current button model and restores the original.
method remove takes nothing returns nothing
//* Get button coordinates.
method operator x takes nothing returns real
method operator y takes nothing returns real
method operator z takes nothing returns real
method operator facing takes nothing returns real
//* Get & set default button model.
method operator defaultStr takes nothing returns string
method operator defaultId takes nothing returns integer
method operator defaultStr= takes string path returns nothing
method operator defaultId= takes integer id returns nothing
//* Struct members.
readonly player user
//* typeId is the id of the struct the button was created from.
readonly integer typeId
readonly real scale
readonly Track track
readonly string tempStr
readonly integer tempId
boolean enabled
//* Example store heal ability: button.data = 'Ahea'
//* UnitAddAbility(myUnit, clicked.button.data)
integer data
//* ==========================
//* library UIBorder:
//* ==========================
//* Variables:
//* ==========
//* You can change these values, between
//* two border creations. Make sure the string paths do exist.
//* "null" and "" are considered as valid ( empty ) string path.
boolean UI_BORDER_INCLUDED_IN_RECT = false//* Frames the rect or is inside borders?
real UI_BORDER_WIDTH = 32.
ARGB UI_BORDER_BACKGROUND_COLOR = 0xFFFFFFFF
integer UI_BORDER_IMAGE_TYPE = IMAGE_TYPE_OCCLUSION_MASK
string UI_BORDER_BACKGROUND = "war3mapImported\\background.TGA"
string UI_BORDER_LEFT = "war3mapImported\\BorderLeftNE.TGA"
string UI_BORDER_RIGHT = "war3mapImported\\BorderRightNE.TGA"
string UI_BORDER_TOP = "war3mapImported\\BorderUpNE.TGA"
string UI_BORDER_BOTTOM = "war3mapImported\\BorderDownNE.TGA"
string UI_BORDER_BOTTOM_LEFT = "war3mapImported\\BorderDownLeftNE.TGA"
string UI_BORDER_BOTTOM_RIGHT = "war3mapImported\\BorderDownRightNE.TGA"
string UI_BORDER_TOP_LEFT = "war3mapImported\\BorderUpLeftNE.TGA"
string UI_BORDER_TOP_RIGHT = "war3mapImported\\BorderUpRightNE.TGA"
//* New jass custom type UIBorder.
struct UIBorder
static method create takes nothing returns UIBorder
method destroy takes nothing returns nothing
method clear takes nothing returns nothing
//* Does not desync on GetLocalPlayer() usage.
//* Is called internally when showing an UI.
method show takes boolean show returns nothing
//* Square borders build from image handles.
method construct takes real centerX, real centerY, real sizeX, real sizeY, real borderScale returns thistype
method constructRect takes rect r, real borderScale returns thistype
method addImage takes string file, real sizeX, real sizeY, real posX, real posY, integer imageType returns image
//* Same, but from destructables. *NOT CODED YET*
method constructDest takes real originX, real originY, real width, real height, real borderScale returns thistype
method constructRectDest takes rect r, real borderScale returns thistype
method addDest takes integer destId, real x, real y, real face, real scale returns destructable
//* ==========================
//* library UIWindow:
//* ==========================
//* New jass custom type UIScreen.
//* Extend your custom libraries of this struct.
//* Example: struct GameMenu extends UIScreen.
struct UIScreen
//* Coordinates of the screen.
readonly real originX
readonly real originY
readonly real width
readonly real height
method operator centerX takes nothing returns real
method operator centerY takes nothing returns real
static method create takes player user, real originX, real originY, real width, real height returns thistype
method destroy takes nothing returns nothing
//* Increases an internal counter. Starts & stops the fogmodifier when co
method operator enable= takes boolean flag returns nothing
method operator enabled takes nothing returns boolean
debug public method highlight takes nothing returns nothing
//* New jass custom type UIWindow.
//* Parent struct of all windows in a UIScreen.
//* Example: Window w in a screen s.
//* UIScreen s:
//*
//* Y-axis:
//* _______________________________
//* | 128|¯¯¯¯¯¯¯¯¯¯¯¯| |
//* | | w2 | |
//* | |¯¯¯¯¯| |____________| |
//* |128| w1 | 0/0 128 256 |
//* | |_____| |
//* | 0/0 128 |
//* |_______________________________|
//* 0/0 X - axis
struct UIWindow
//* UIWindow offers various wrappers to UIBorder, UIButton, UISound and UIBoard.
//* always use them, because they automatically inherit the coordinates of the window.
static method create takes UIScreen whichScreen, real x, real y, real sx, real sy returns thistype
method destroy takes nothing returns nothing
method show takes boolean flag returns nothing
method operator enabled takes nothing returns boolean
//* stub methods for child struct.
stub method onHover takes integer whichType, UIButton hovered returns nothing
stub method onClick takes integer whichType, UIButton clicked returns nothing
stub method onShow takes integer whichType, boolean flag returns nothing
stub method onSwitchPage takes integer whichType, boolean flag returns nothing
method isDoubleClick takes nothing returns boolean
//* Readonly members:
//* =================
readonly UIScreen screen
readonly UIBorder border
readonly Table cells
readonly real lastClick
readonly real originX
readonly real originY
readonly real width
readonly real height
//* Get window player:
//* ==================
method operator user takes nothing returns player
method operator userId takes nothing returns integer
//* Get window dimensions:
//* ======================
method operator maxX takes nothing returns real
method operator minX takes nothing returns real
method operator maxY takes nothing returns real
method operator minY takes nothing returns real
method operator centerX takes nothing returns real
method operator centerY takes nothing returns real
//* Multiple pages:
//* ===============
//* The page API is still in its infancy. I will work on it when I have time.
readonly integer pages
readonly integer page
readonly integer pageSize
//* Add() generates x copies of the first page. Can be called only once.
//* And only during the window creation process.
method addPages takes integer amount, boolean import, boolean circulate returns nothing
//* Set(), Prev(), Next()
method setPage takes integer index returns boolean
method prevPage takes nothing returns boolean
method nextPage takes nothing returns boolean
//* UIButton related:
//* =================
//* Buttons are arranged in a stack.
//* Example: getButton(2)
method getButtonCount takes nothing returns integer
method getButton takes integer index returns UIButton
//* Add(), can be destructables or images. For perfect results stay with only one type.
method addDestButton takes string model, real x, real y, real z, real face, integer objectId, real scale returns UIButton
method addImageButton takes string model, real x, real y, real z, real face, string file, real scale returns UIButton
//* Window dummy:
//* =============
//* The dummy inherits the window coordinates. Just pass in a offset in x, y and z.
method createDummy takes integer dummyId, real offsetX, real offsetY, real offsetZ, real face, real scale returns unit
//* UIBorder related:
//* =================
//* FrameWindow(), FrameWindowEx(), AddBorder(), AddImageToBorder(), AddImageToScreen()
//* Sometimes frame() doesn't perfectly match. The use frameEx to add a extra size in x and y axis.
method frame takes real borderScale returns nothing
method frameEx takes real extraX, real extraY, real borderScale returns nothing
method addBorder takes real x, real y, real sizeX,real sizeY, real borderScale returns nothing
method addBorderImage takes string file, real x, real y, real sizeX, real sizeY, integer imageType returns image
method addScreenImage takes string file, real x, real y, real sizeX, real sizeY, integer imageType returns image
//* Destructable border API will come in the future.
//* Optional API:
//* =============
method operator board takes nothing returns UIBoard
method operator audio takes nothing returns UISound
//* Debug mode only API:
//* ====================
debug method highlight takes nothing returns nothing
//* ==========================
//* library UISound: ( optional )
//* ==========================
library UISound requires SoundTools
//* Info: UISound instances are player id based.
//* In any UIWindow and UIScreen child structs:
method operator audio takes nothing returns UISound
//* New jass custom type UISound.
//* User-friendly type-casting.
struct UISound extends array
//* Runs a sound for the UI player. Only runs sounds when the previous
//* pause is over or if the priority of the next sound is higher.
method play takes Sound instance, integer priority, real pause returns boolean
//* Most common sound files.
method error takes nothing returns boolean
method bigButtonClick takes nothing returns boolean
method wayPointBling takes nothing returns boolean
method mouseClick takes nothing returns boolean
//* You can register sounds to UISound on an integer ( index ). Only positive indexes are allowed.
//* Example: UISound.register('srbd', "Sound\\Units\\Combat\\MetalMediumChopMetal1.wav", 441, 2, .2)
static method register takes integer index, string file, integer duration, integer priority, real timeout returns nothing
//* Run registered sounds via method search.
//* Example: call search('srbd')
method search takes integer index returns boolean
//* You may also search by passing the sound path.
//* Here however you have to specify priority and timeout.
method searchSoundFile takes integer index, integer priority, real timeout returns boolean
//* If you don't need a specific index, you can use allocatedIndex instead of register.
//* UISound will returns a unique integer on which the sound file is saved on.
static method allocateIndex takes string file, integer duration, integer priority, real timeout returns integer
//* ==========================
//* library UIBoard: ( optional )
//* ==========================
//* Info: UIBoard instances are player id based.
//* In any UIWindow and UIScreen child structs:
method operator board takes nothing returns UIBoard
//* New jass custom type UIBoard.
//* User-friendly type-casting.
struct UIBoard extends array
//* Readonly member:
//* ================
readonly multiboard board
//* Create() & Destroy():
//* =====================
//* Visible for only one player ( Player(this) ).
method new takes integer rows, integer columns returns thistype
//* Releases a board only if an handle exists. 100% fail-safe.
method release takes nothing returns nothing
//* Wrapper around multiboarditems:
//* ===============================
//* I recommend to use the wrappers as they prevent multiboarditems from leaking.
method setText takes integer row, integer column, string str returns nothing
method setIcon takes integer row, integer column, string str returns nothing
method setColor takes integer row, integer column, integer red, integer green, integer blue, integer alpha returns nothing
method setStyle takes integer row, integer column, boolean showValue, boolean showIcon returns nothing
method setWidth takes integer row, integer column, real width returns nothing
//! endnovjass
Last edited: