wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Samples
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-03-2010, 03:21 AM   #1
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default WindowInterface

Based in the library DGUI it does pretty much the same but works for multiplayer.
(requires vJass) More scripts: htt://www.wc3c.net
(requires jassnewgenpack5b+)

Uses the library Math by Ashujon
http://www.wc3c.net/showthread.php?t=102351
Uses the library Camera by Ashujon
http://www.wc3c.net/showthread.php?t=102351
Uses the library TimerUtils by Vexorian (only tested with Blue Flavor):
http://www.wc3c.net/showthread.php?t=101322

This library consists of three structs (BUTTON, PICTURE and TEXT), the struct BUTTON draws heavily on the PICTURE struct, while the struct TEXT uses TextTags to show for different players. For BUTTON and PICTURE are required Dummys units that are nearly invisible to any player (at least in the minimap), so that the PICTURE structs are multiplayer only playing with the VertexColor.

I attach a map as an example (not as elaborate as that of Ashujon but only to illustrate how the system works, the coordinates on the screen and the detection of each player, as well as the button).

Collapse JASS:
library WindowInterface initializer Init requires Math, Camera, TimerUtils
//* ===================================================================================================== *
//* by Galled                                                                                             *
//* based in DGUI by Ashujon:  [url]http://www.wc3c.net/showthread.php?t=102351[/url]                                *
//*                                                                                                       *
//* (requires vJass)   More scripts: htt://www.wc3c.net                                                   *
//* (requires jassnewgenpack5b+)                                                                          *
//*                                                                                                       *
//* Uses the library Math by Ashujon							                                          * 
//* [url]http://www.wc3c.net/showthread.php?t=102351[/url]														      *
//* Uses the library Camera by Ashujon							                                          *
//* [url]http://www.wc3c.net/showthread.php?t=102351[/url] 														  * 
//* Uses the library TimerUtils by Vexorian (only tested with Blue Flavor):                               *
//* [url]http://www.wc3c.net/showthread.php?t=101322[/url]                                                           *
//*                                                                                                       *
//* This library consists of three structs (BUTTON, PICTURE and TEXT), the struct BUTTON draws heavily on *
//* the PICTURE struct, while the struct TEXT uses TextTags to show for different players. For BUTTON and *
//* PICTURE are required Dummys units that are nearly invisible to any player (at least in the minimap),  *
//* so that the PICTURE structs are multiplayer only playing with the VertexColor.                        *
//* ===================================================================================================== *
globals
    private constant integer TypeUnit = 'dgui' //Dummy unit masquerading as a button
    private integer TypeSkinChanger = 'A000' //Ability that changes the textures of the units posing as buttons or images 
    private location GL4DGUI = Location(0,0)
    private trigger trigLclick  //Trigger that detects when a player make a left click in a button.
    private trigger trigLclickControl  //Trigger that detects when a player make a left click in a not-button unit.
    private trigger trigRclick  //Trigger that detects when a player make a left click in a button.
    private timer PeriodicControl  //Timer that controls the selected buttons
    private real TimeControl = 0.03 //Interval in wich the timer review if a button has been selected
    private unit array LastSelectedUnit //Save the last unit for every player to prevent the timer PeriodicControl leave the selection of an unit blank.
    private boolean array ClearLastSelected //To lock the save the last unit for every player.
endglobals

//Function that you will use with the actions in the left or right click
function GetTriggerButton takes nothing returns BUTTON
    if ( BUTTON.IsRightClicked() ) then
        return GetUnitUserData(GetOrderTargetUnit())
    elseif ( BUTTON.IsLeftClicked() ) then
        return GetUnitUserData(GetTriggerUnit())
    endif
    return 0
endfunction

//Function extracted from DGUI by Ashujon. Allows you to locate the coordinate Z. Very useful for camera views.
private function GetZ4DGUI takes real X, real Y returns real
    call MoveLocation(GL4DGUI, X, Y)
    return GetLocationZ(GL4DGUI)
endfunction

private function FineIndexAnimModel takes real w, real h, real z returns integer
    local real W = w*WidthScreen*z  //WidthScreen variable from Camera library
    local real H = h*HeightScreen*z //HeightScreen variable from Camera library 
    local real anim
    if (H<W) then
        set anim = 10*(W/H-1)
        return R2I_n(anim)
    else
        set anim = 10*(H/W-1)
        if anim >= 0.5 then
            return 100+R2I_n(anim)
        endif
    endif
    return 0
endfunction

private function FineSizeModel takes real w, real h, real z returns real
    local real W = w*WidthScreen*z  //WidthScreen variable from Camera library
    local real H = h*HeightScreen*z //HeightScreen variable from Camera library 
    if (H<W) then
        return 0.5*H
    else
        return 0.5*W
    endif
endfunction

struct BUTTON
    static BUTTON array AllShow
    static integer CountShow = 0
    private integer index
    private CAMERA Camera
    
    private real centerx
    private real centery
    private real minx
    private real maxx
    private real miny
    private real maxy
    private real width
    private real height
    private real z
    unit picture
    private integer indexanim
    private effect model
    boolean show
    integer CostumValue
 
    static method New takes real minx, real maxy, real W, real H, real z, integer texture returns BUTTON
    local BUTTON this = BUTTON.create()
    local destructable tree    
        set .CostumValue = 0
        set .Camera = 0
        set .width = W
        set .height = H
        set .minx = minx
        set .maxx = minx+W
        set .maxy = maxy
        set .miny = maxy-H
        set .z = 100.2+z
        set .centerx = minx+W/2.0
        set .centery = maxy-H/2.0
        set .show = false
        set .picture = CreateUnit(Player(15), TypeUnit, 0, 0, 0)
        call UnitAddAbility(.picture, TypeSkinChanger)
        if (texture != 0) then
            set tree = CreateDestructable(texture,0,0,0,0,1)
            call IssueTargetOrder(.picture, "grabtree", tree)
            call RemoveDestructable(tree)
            set tree = null
        endif
        set .indexanim = FineIndexAnimModel(W, H, .z)
        call SetUnitAnimationByIndex(.picture, .indexanim)
        call SetUnitScale(.picture, FineSizeModel(W, H, .z), 0, 0)
        call UnitAddAbility(.picture, 'Aave')
        call UnitRemoveAbility(.picture, 'Aave')
        call ShowUnit(.picture, false)
        call SetUnitUserData(.picture, this)
        return this
    endmethod
    
    static method LockLastSelectedUnitForPlayer takes player p, boolean lock returns nothing
        set ClearLastSelected[GetPlayerId(p)] = lock
    endmethod
    
    static method ClearLastSelectedUnitForPlayer takes player p returns nothing
        call .LockLastSelectedUnitForPlayer(p,true)
        set LastSelectedUnit[GetPlayerId(p)] = null
    endmethod
    
    static method GetLastSelectedUnitForPlayer takes player p returns unit
        return LastSelectedUnit[GetPlayerId(p)]
    endmethod
    
    static method SaveLastSelectedUnitForPlayer takes unit u, player p returns nothing
        if( LastSelectedUnit[GetPlayerId(p)] != u) then    
            set LastSelectedUnit[GetPlayerId(p)] = u
        endif
    endmethod
        
    static method SaveLastSelectedUnit takes nothing returns nothing
    local player p = GetTriggerPlayer()
    local unit u = GetTriggerUnit()
        if ( ClearLastSelected[GetPlayerId(p)] == false) then
            if( LastSelectedUnit[GetPlayerId(p)] != u) then
                set LastSelectedUnit[GetPlayerId(p)] = u
            endif
        endif
    set u = null
    set p = null
    endmethod

    static method AddActionL takes code func returns triggeraction
        return TriggerAddAction(trigLclick, func)
    endmethod
    
    static method RemoveActionL takes triggeraction action returns nothing
        call TriggerRemoveAction(trigLclick, action)
    endmethod
    
    static method AddActionR takes code func returns triggeraction
        return TriggerAddAction(trigRclick, func)
    endmethod
    
    static method RemoveActionR takes triggeraction action returns nothing
        call TriggerRemoveAction(trigRclick, action)
    endmethod
    
    method Delete takes nothing returns nothing
        call RemoveUnit(.picture)
        if .show then
            set .AllShow[.index] = .AllShow[.CountShow]
            set .AllShow[.index].index = .index
            set .CountShow = .CountShow - 1
        endif
    endmethod
    
    //Method that updates the position of the buttons so that they appear properly on screen.
    method Update takes nothing returns nothing
        local VECTOR3 Pos = .Camera.Win2World(.centerx, .centery, .z)
        call SetUnitX(.picture, Pos.x)
        call SetUnitY(.picture, Pos.y)
        call MoveLocation(GL4DGUI, Pos.x, Pos.y)
        call SetUnitFlyHeight(.picture, Pos.z-GetLocationZ(GL4DGUI), 0)
        call Pos.destroy()
    endmethod
    
    method Show takes boolean show, CAMERA Cam returns nothing
        if Cam != -1 then
            set .Camera = Cam
        endif
        call ShowUnit(.picture, show)
        if show != .show then
            if show then
                set .AllShow[.CountShow] = this
                set .index = .CountShow
                set .CountShow = .CountShow + 1
                call .Update()
                call SetUnitAnimationByIndex(.picture, .indexanim)
            else
                set .CountShow = .CountShow - 1
                set .AllShow[.index] = .AllShow[.CountShow]
                set .AllShow[.index].index = .index
            endif
        endif
        set .show = show
    endmethod
    
    static method IsLeftClicked takes nothing returns boolean
    local unit isLeftButton = GetTriggerUnit()
    local boolean isLeft = false
    
        if(isLeftButton!=null)then
            set isLeft = GetUnitAbilityLevel(isLeftButton, TypeSkinChanger)>0 //Selected unit
            set isLeftButton = null
        endif

        return isLeft
    endmethod
    
    static method IsRightClicked takes nothing returns boolean
    local unit isRightButton = GetOrderTargetUnit()
    local boolean isRight = false
    
        if(isRightButton!=null)then
            set isRight = (GetUnitAbilityLevel(isRightButton, TypeSkinChanger)>0) //Target order with "smart" order
        endif

        if(isRight)then
            call PauseUnit(GetTriggerUnit(), true)
            call IssueImmediateOrder(GetTriggerUnit(), "stop")
            call PauseUnit(GetTriggerUnit(), false)
        endif
        
        set isRightButton = null
        
        return isRight
    endmethod
    
    static method IsClicked takes nothing returns boolean
    local boolean isRight = .IsRightClicked()
    local boolean isLeft = false
    
        if isRight==false then
            set isLeft = .IsLeftClicked()
        endif
        
        return isLeft or isRight
    endmethod
        
    method SetPosition takes real minx, real maxy returns nothing
        set .minx = minx
        set .maxx = minx+.width
        set .maxy = maxy
        set .miny = maxy-.height
        set .centerx = minx+.width/2.0
        set .centery = maxy-.height/2.0
        if .show then
            call .Update()
        endif
    endmethod
    
    method SetTexture takes integer texture returns nothing
    local destructable tree = CreateDestructable(texture,0,0,0,0,1)
        call ShowUnit(.picture, true)
        call SetUnitX(.picture, 0)
        call SetUnitY(.picture, 0)
        call IssueTargetOrder(.picture,"grabtree",tree)
        call ShowUnit(.picture, .show)
        call RemoveDestructable(tree)
        if .show then
            call .Update()
        endif
        set tree = null
    endmethod
    
    static method AllUpdate takes nothing returns nothing
        local integer i = .CountShow
        loop
            exitwhen i < 0
            call .AllShow[i].Update()
            set i = i - 1
        endloop
    endmethod
        
    static method ClickPeriodicSelect takes player p returns unit
        local integer i = .CountShow
        loop
            exitwhen i < 0
            if IsUnitSelected(.AllShow[i].picture, p) then
                return .AllShow[i].picture
            endif
            set i = i - 1
        endloop
        return null
    endmethod

endstruct

struct PICTURE
    private static PICTURE array AllShow
    private static integer CountShow = 0
    private integer index
    private CAMERA Camera
    
    private real centerx
    private real centery
    private real width
    private real height
    private real z
    unit picture
    private integer indexanim
    boolean array show2Player[12]
    integer CostumValue
    
    static method New takes real minx, real maxy, real W, real H, real z, integer texture returns PICTURE
        local PICTURE this = PICTURE.create()
        local destructable tree
        local integer i = 0
        loop
            set .show2Player[i]=false
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop
        set .CostumValue = 0
        set .Camera = 0
        set .width = W
        set .height = H
        set .centerx = minx+W/2.0
        set .centery = maxy-H/2.0
        set .z = 100.2+z
        set .picture = CreateUnit(Player(15), TypeUnit, 0, 0, 0)
        call SetUnitVertexColor(.picture,255,255,255,0)
        call UnitAddAbility(.picture, TypeSkinChanger)
        if (texture != 0) then
            set tree = CreateDestructable(texture,0,0,0,0,1)
            call IssueTargetOrder(.picture, "grabtree", tree)
            call RemoveDestructable(tree)
            set tree = null
        endif
        set .indexanim = FineIndexAnimModel(W, H, .z)
        call SetUnitAnimationByIndex(.picture, .indexanim)
        call SetUnitScale(.picture, FineSizeModel(W, H, .z), 0, 0)
        call UnitAddAbility(.picture, 'Aave')
        call UnitRemoveAbility(.picture, 'Aave')
        call UnitAddAbility(.picture, 'Aloc')
        call UnitRemoveAbility(.picture, 'Aloc')
        return this
    endmethod
    
    static method NewCostumModel takes real minx, real maxy, real z, real size, integer typeunit, real WidthModel, real HeightModel, integer texture returns PICTURE
        local PICTURE this = PICTURE.create()
        local destructable tree    
        local integer i = 0
        loop
            set .show2Player[i]=false
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop
        set .CostumValue = 0
        set .Camera = 0
        set .z = 100.2+z
        set .width = (WidthModel*size)/(WidthScreen*.z)
        set .height = (HeightModel*size)/(HeightScreen*.z)
        set .centerx = minx+.width/2.0
        set .centery = maxy-.height/2.0
        set .picture = CreateUnit(Player(15), typeunit, 0, 0, 0)
        call SetUnitVertexColor(.picture,255,255,255,0)
        call UnitAddAbility(.picture, TypeSkinChanger)
        if (texture != 0) then
            set tree = CreateDestructable(texture,0,0,0,0,1)
            call IssueTargetOrder(.picture, "grabtree", tree)
            call RemoveDestructable(tree)
            set tree = null
        endif
        call SetUnitScale(.picture, size, 0, 0)
        call UnitAddAbility(.picture, 'Aave')
        call UnitRemoveAbility(.picture, 'Aave')
        call UnitAddAbility(.picture, 'Aloc')
        call UnitRemoveAbility(.picture, 'Aloc')
        return this
    endmethod
        
    private method IsShowedToAnybody takes nothing returns boolean
    local integer i = 0
    local boolean b = false
        loop
            set b = b or .show2Player[i]
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop
        
        return b
    endmethod
    
    method Delete takes nothing returns nothing
        call RemoveUnit(.picture)
        if .IsShowedToAnybody() then
            set .AllShow[.index] = .AllShow[.CountShow]
            set .AllShow[.index].index = .index
            set .CountShow = .CountShow - 1
        endif
    endmethod
    
    method Update takes nothing returns nothing
        local VECTOR3 Pos = .Camera.Win2World(.centerx, .centery, .z)
        call SetUnitX(.picture, Pos.x)
        call SetUnitY(.picture, Pos.y)
        call MoveLocation(GL4DGUI, Pos.x, Pos.y)
        call SetUnitFlyHeight(.picture, Pos.z-GetLocationZ(GL4DGUI), 0)
        call Pos.destroy()
    endmethod
    
    method ShowAll takes boolean show, CAMERA Cam, boolean showUnit returns nothing
    local integer i = 0
    
        if(showUnit)then
            call ShowUnit(.picture, show)
        endif
        loop
            call .ShowToPlayer(show,Cam,Player(i))
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop
    endmethod
    
    method ShowToPlayer takes boolean show, CAMERA Cam, player p returns nothing
        if Cam != -1 then
            set .Camera = Cam
        endif
        if (show != .show2Player[GetPlayerId(p)]) then
            if show then
                set .AllShow[.CountShow] = this
                set .index = .CountShow
                set .CountShow = .CountShow + 1
                call .Update()
                if(GetLocalPlayer()==p)then
                    call SetUnitVertexColor(.picture,255,255,255,255)
                endif
            else
                if(GetLocalPlayer()==p)then
                    call SetUnitVertexColor(.picture,255,255,255,0)
                endif
                set .CountShow = .CountShow - 1
                set .AllShow[.index] = .AllShow[.CountShow]
                set .AllShow[.index].index = .index
            endif
        endif
        set .show2Player[GetPlayerId(p)] = show

    endmethod
    
    method SetPosition takes real minx, real maxy returns nothing
        set .centerx = minx+.width/2.0
        set .centery = maxy-.height/2.0
        if .IsShowedToAnybody() then
            call .Update()
        endif
    endmethod
    
    method SetTexture takes integer texture returns nothing
    local destructable tree = CreateDestructable(texture,0,0,0,0,1)
    local integer i = 0
    local boolean b = false
    
        call ShowUnit(.picture, true)
        call SetUnitX(.picture, 0)
        call SetUnitY(.picture, 0)
        call IssueTargetOrder(.picture,"grabtree",tree)
        call RemoveDestructable(tree)
        loop
            set b = b or .show2Player[i]
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop            
        if b then
            call .Update()
        endif
        set tree = null
    endmethod
    
    static method AllUpdate takes nothing returns nothing
        local integer i = .CountShow
        loop
            exitwhen i < 0
            call .AllShow[i].Update()
            set i = i - 1
        endloop
    endmethod

endstruct //PICTURE

struct TEXT
    private static TEXT array AllShow
    private static integer CountShow = 0
    private integer index
    private CAMERA Camera
    
    private real minx
    private real maxy
    private real z
    texttag textInScreen
    string textString
    boolean array show2Player[12]
    integer CostumValue
    
    static method New takes real minx, real maxy, real z returns TEXT
        local TEXT this = TEXT.create()
        local integer i = 0
        loop
            set .show2Player[i]=false
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop
        set .CostumValue = 0
        set .Camera = 0
        set .minx = minx
        set .maxy = maxy
        set .z = 100+z
        set .textInScreen = null
        set .textString = ""
        return this
    endmethod
    
    method SetText takes string text returns nothing
        set .textString = text
    endmethod
    
    private method IsShowedToAnybody takes nothing returns boolean
    local integer i = 0
    local boolean b = false
        loop
            set b = b or .show2Player[i]
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop
        
        return b
    endmethod
    
    method Delete takes nothing returns nothing
        if(.textInScreen!=null)then
            call DestroyTextTag(.textInScreen)
        endif
        if .IsShowedToAnybody() then
            set .AllShow[.index] = .AllShow[.CountShow]
            set .AllShow[.index].index = .index
            set .CountShow = .CountShow - 1
        endif
    endmethod
    
    method Update takes nothing returns nothing
        local VECTOR3 Pos = .Camera.Win2World(.minx, .maxy, .z)
        if(.textInScreen != null)then
            call SetTextTagPos(.textInScreen, Pos.x, Pos.y, Pos.z-GetZ4DGUI(Pos.x,Pos.y))
        endif
        call Pos.destroy()
    endmethod
    
    method SetPosition takes real minx, real maxy returns nothing
        set .minx = minx
        set .maxy = maxy
        if .IsShowedToAnybody() then
            call .Update()
        endif
    endmethod
    
    method ShowAll takes boolean show, CAMERA Cam returns nothing
    local integer i = 0
        loop
            call .ShowToPlayer(show,Cam,Player(i))
            set i = i + 1
            exitwhen i>=bj_MAX_PLAYERS
        endloop
    endmethod
    
    method ShowToPlayer takes boolean show, CAMERA Cam, player p returns nothing
    local boolean state = .show2Player[GetPlayerId(p)] != show
        set .show2Player[GetPlayerId(p)] = show
        
        if show then
            if(.textInScreen!=null)then
                call DestroyTextTag(.textInScreen)
                set .textInScreen = null
            endif
            set .textInScreen = CreateTextTag()
            call SetTextTagText(.textInScreen, .textString, 8 * 0.0023)
            call SetTextTagVisibility(.textInScreen, false)
            call .Update()        
            if (GetLocalPlayer()==p) then
                call SetTextTagVisibility(.textInScreen, true)
            endif
        else            
            if (.IsShowedToAnybody()==false) then
                call DestroyTextTag(.textInScreen)
                set .textInScreen = null
            endif
        endif
        if Cam != -1 then
            set .Camera = Cam
        endif
        if (state) then
            if show then
                set .AllShow[.CountShow] = this
                set .index = .CountShow
                set .CountShow = .CountShow + 1
                call .Update()
                if (GetLocalPlayer()==p) then
                    call SetTextTagVisibility(.textInScreen, true)
                endif
            else
                if (GetLocalPlayer()==p) then
                    if(.textInScreen!=null)then
                        call SetTextTagVisibility(.textInScreen, false)
                    endif
                endif
                set .CountShow = .CountShow - 1
                set .AllShow[.index] = .AllShow[.CountShow]
                set .AllShow[.index].index = .index
            endif
        endif
        
    endmethod
    
    static method AllUpdate takes nothing returns nothing
        local integer i = .CountShow
        loop
            exitwhen i < 0
            call .AllShow[i].Update()
            set i = i - 1
        endloop
    endmethod

endstruct

private function PeriodicClearSelect takes nothing returns nothing
local integer i = 0
local unit check = null

    loop
        set check = BUTTON.ClickPeriodicSelect(Player(i))
        if check != null then
            if (LastSelectedUnit[i] != null) then
                if(IsUnitSelected(LastSelectedUnit[i],Player(i))==false)then
                    if (GetLocalPlayer() == Player(i)) then
                        call ClearSelection()
                        call SelectUnit(LastSelectedUnit[i], true)
                    endif
                endif
            else
                if (GetLocalPlayer()==Player(i)) then
                    call ClearSelection()
                endif
            endif
            set check = null
        endif
        set i = i + 1
        exitwhen i>=bj_MAX_PLAYERS
    endloop
    
set check = null
endfunction

public function Update takes boolean but, boolean pic, boolean tex returns nothing
    if but then
        call BUTTON.AllUpdate()
    endif
    if pic then
        call PICTURE.AllUpdate()
    endif
    if tex then
        call TEXT.AllUpdate()
    endif
endfunction

private function Init takes nothing returns nothing
local integer i = 0

    set trigLclick = CreateTrigger()
    set trigLclickControl = CreateTrigger()
    set trigRclick = CreateTrigger()
    set PeriodicControl = NewTimer()
    call TimerStart(PeriodicControl, TimeControl, true, function PeriodicClearSelect)
    loop
        call TriggerRegisterPlayerUnitEvent(trigLclick, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
        call TriggerRegisterPlayerUnitEvent(trigLclickControl, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
        call TriggerRegisterPlayerUnitEvent(trigRclick, Player(i), EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER, null)
        set ClearLastSelected[i] = false
        set LastSelectedUnit[i] = null
        set i = i + 1
        exitwhen i>=bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddAction(trigLclickControl, function BUTTON.SaveLastSelectedUnit)
    call TriggerAddCondition(trigLclickControl, Not(Condition( function BUTTON.IsClicked)))
    
    call TriggerAddCondition(trigLclick,Condition( function BUTTON.IsClicked))
    call TriggerAddCondition(trigRclick,Condition( function BUTTON.IsClicked))
endfunction

endlibrary

There are the test in the map:
Collapse JASS:
scope Test

globals

    constant real WidthSlot = 0.08              //                                             		 |
    constant real HeightSlot = 0.08*AspectRatio //AspectRatio is a variable from Camera library 
    integer TypeTextureBlank = 'dbnk'
    private code FuncLClickSlot = null
    private code FuncRClickSlot = null
    PICTURE array pict
    TEXT array text    
endglobals

private function RaceToInt takes race raza returns integer
    if raza == RACE_HUMAN then
        return 0
    elseif raza == RACE_ORC then 
        return 1
    elseif raza == RACE_UNDEAD then
        return 2
    elseif raza == RACE_NIGHTELF then
        return 3
    endif

    return 0
endfunction

private function WhenLeftClick takes nothing returns nothing
local BUTTON but = GetTriggerButton()
local player p = GetTriggerPlayer()

    debug call BJDebugMsg("Player "+GetPlayerName(p)+" is left clicked in the button with the value: "+I2S(but.CostumValue))
    
    call pict[GetPlayerId(p)].ShowToPlayer(true, GameCamera, p)
    call text[GetPlayerId(p)].SetText("Player "+GetPlayerName(p)+" is left clicked in the button with the value: "+I2S(but.CostumValue))
    call text[GetPlayerId(p)].ShowToPlayer(true, GameCamera, p)
    
set p = null
endfunction

private function WhenRightClick takes nothing returns nothing
local BUTTON but = GetTriggerButton()
local player p = GetTriggerPlayer()
    
    debug call BJDebugMsg("Player "+GetPlayerName(p)+" is right clicked in the button with the value: "+I2S(but.CostumValue))
        
    call pict[GetPlayerId(p)].ShowToPlayer(false, GameCamera, p)
    call text[GetPlayerId(p)].ShowToPlayer(false, GameCamera, p)
    
set p = null
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
//Create three buttons
local BUTTON test1 = BUTTON.New(0, 0, WidthSlot, HeightSlot, 0.5, TypeTextureBlank)
local BUTTON test2 = BUTTON.New(0, 0, WidthSlot, HeightSlot, 0.5, TypeTextureBlank)
local BUTTON test3 = BUTTON.New(0, 0, WidthSlot, HeightSlot, 0.5, TypeTextureBlank)
local integer i = 0
local unit u 
    
    //Create the camera. That is very important!!! 
    set GameCamera = CAMERA.New()
    
    //... , one in the center of the screen
    set test1.CostumValue = 11
    call test1.SetPosition(0,0) //Coordenates in the screen, not in the map.
    call test1.Show(true, GameCamera)
    
    //... , one on the top right
    set test2.CostumValue = 22
    call test2.SetPosition(0.8,0.8) //Coordenates in the screen, not in the map.
    call test2.Show(true, GameCamera)    
    
    //... and the last one on the bottom left
    set test3.CostumValue = 33
    call test3.SetPosition(-0.8,-0.8) //Coordenates in the screen, not in the map.
    call test3.Show(true, GameCamera)
    
    set u = CreateUnit(Player(0), 'Hpal', 0,0, 180)
    call SelectUnitForPlayerSingle(u,Player(0))
    set u = CreateUnit(Player(1), 'Obla', 0,0, 180)
    call SelectUnitForPlayerSingle(u,Player(1))
    
    loop
        //Create a picture and text to each player
        //PICTURE method NewCostumModel takes real minx, real maxy, real z, real size, integer typeunit, real WidthModel, real HeightModel, integer texture                                 
        set pict[i] = PICTURE.NewCostumModel(-0.99, 0.95, 1, 0.26, 'dwin', 140.002, 122.646, 'D201'+RaceToInt(GetPlayerRace(Player(i))))
        //TEXT method New takes real minx, real maxy, real z returns TEXT
        set text[i] = TEXT.New(-0.9, 0.76, 1)
        set i = i + 1
        exitwhen i>=bj_MAX_PLAYER_SLOTS
    endloop    
    
    set FuncLClickSlot = function WhenLeftClick
    set FuncRClickSlot = function WhenRightClick
    
    call BUTTON.AddActionL(FuncLClickSlot)
    call BUTTON.AddActionR(FuncRClickSlot)
    
    
endfunction
endscope
Attached Images
File Type: png WC3ScrnShot_030910_205059_01.png (1.38 MB, 1465 views)
Attached Files
File Type: w3x Window Interface.w3x (70.9 KB, 398 views)
__________________
Actual Project:

War of Gods

Last edited by GALLED : 07-22-2010 at 08:44 PM.
GALLED is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-03-2010, 08:24 AM   #2
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Did you test this in multiplayer?
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 02-03-2010, 02:21 PM   #3
Tot
†6†
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

Is it possible to use this and "normal" ingame view?
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr
Tot is offline   Reply With Quote
Old 02-03-2010, 02:56 PM   #4
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default

Quote:
Originally Posted by Anachron
Did you test this in multiplayer?
Yep. It's works :D

Quote:
Originally Posted by Tot
Is it possible to use this and "normal" ingame view?
No, as far as I tested, only be used with the Camera of Ashujon. This is what happens by using units posing as images. I guess I should get a little more complex calculation for the units are seen in perspective with the normal view.
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Old 02-03-2010, 02:57 PM   #5
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Quote:
No, as far as I tested, only be used with the Camera of Ashujon. This is what happens by using units posing as images. I guess I should get a little more complex calculation for the units are seen in perspective with the normal view.
So that's the negative side.

Isn't it damn laggy in multiplayer in larger maps?
I mean you move units...
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 02-03-2010, 03:30 PM   #6
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default

Quote:
Originally Posted by Anachron
So that's the negative side.

Isn't it damn laggy in multiplayer in larger maps?
I mean you move units...

Yes, that's the downside. In fact, if I guess if you have many units on a large map may slow your game, although I have not test in large maps. After all now depends on how you use the system.
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Old 02-04-2010, 11:47 AM   #7
Tot
†6†
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

Quote:
Originally Posted by GALLED
No, as far as I tested, only be used with the Camera of Ashujon. This is what happens by using units posing as images. I guess I should get a little more complex calculation for the units are seen in perspective with the normal view.

maybe by using images/oversplats instead of units and some adjusted calculation it might be possible without locking the camera...(just thinking out loud)
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr
Tot is offline   Reply With Quote
Old 02-04-2010, 01:31 PM   #8
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default

Quote:
Originally Posted by Tot
maybe by using images/oversplats instead of units and some adjusted calculation it might be possible without locking the camera...(just thinking out loud)
Yes, but the bad part of use images are they are flat. You couldn´t use them in conjunction with the Ashujon´s camera.

Only a couple of things I forgot: This interface is for my Hero Selection System, so that only the PICTURE and TEXT can be seen in different locations for each player. The BUTTONs, are displayed for all players in the same position.
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Old 02-05-2010, 05:56 PM   #9
Tot
†6†
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

started to do something similiar, only with images (atm) and an more flexible camera
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr
Tot is offline   Reply With Quote
Old 03-02-2010, 03:21 PM   #10
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Can you post a screenshot in the first post? It's a submission requirement.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
¤ ICARUS
¤ Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 03-10-2010, 12:55 AM   #11
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default

Ok. I've added an image.
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Old 03-21-2010, 03:43 PM   #12
mattstheman
User
 
Join Date: Mar 2010
Posts: 1

mattstheman has little to show at this moment (0)

Default

How do I create more than 1 window per player?
mattstheman is offline   Reply With Quote
Old 04-06-2010, 03:14 PM   #13
Slaydon
User
 
Join Date: Jul 2009
Posts: 26

Slaydon has little to show at this moment (0)

Default

Would you or someone else make the math for all kinds of cameras, the camera is simply ruining abit, awesome that you get the values tho, +rep
Slaydon is offline   Reply With Quote
Old 04-16-2010, 03:42 PM   #14
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

You need to link to all required libraries in the first post, not just in the comments of the script.
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
¤ ICARUS
¤ Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 04-17-2010, 08:41 AM   #15
Slaydon
User
 
Join Date: Jul 2009
Posts: 26

Slaydon has little to show at this moment (0)

Default

Why arent i aviable to set the Buttons location to the GameCameras location but only in the center? i managed to get the camera to work but i cant get the buttons to move

EDIT: I managed to merge DGUI cam with this, but when i import it to another map i cant press the buttons and get the actions, I had to seperate StartGame and "Test" (SpellCast on my map)

Collapse JASS:
scope SpellCast initializer SpellCast

globals
    BUTTON array DGUIBUTTONS
    integer array TEXTUREUSING
    boolean array ISSLOTEMPTY
    constant real WidthSlot = 0.10              //                                             		 |
    constant real HeightSlot = 0.10*AspectRatio //AspectRatio is a variable from Camera library 
    integer TypeTextureBlank = 'dbnk'
    private code FuncLClickSlot = null
    private code FuncRClickSlot = null
    PICTURE array pict
    TEXT array text    
    boolean bdebug = false
    integer BUTTONCOUNT
    unit DGUIUNIT
    TEXT array SPELLCOOLDOWNTEXT
    unit u
endglobals

private function RaceToInt takes race raza returns integer
    if raza == RACE_HUMAN then
        return 0
    elseif raza == RACE_ORC then 
        return 1
    elseif raza == RACE_UNDEAD then
        return 2
    elseif raza == RACE_NIGHTELF then
        return 3
    endif

    return 0
endfunction

private function WhenLeftClick takes nothing returns nothing
local BUTTON but = GetTriggerButton()
local player p = GetTriggerPlayer()
local integer i = 1
local integer ii = 0
local integer iii = 0

    set bdebug = false
    call BJDebugMsg("Player "+GetPlayerName(p)+" is left clicked in the button with the value: "+I2S(but.CostumValue))
    
    call pict[GetPlayerId(p)].ShowToPlayer(true, GameCamera, p)
    call text[GetPlayerId(p)].SetText("Player "+GetPlayerName(p)+" is left clicked in the button with the value: "+I2S(but.CostumValue) + " With the Texture ID: " + I2S(TEXTUREUSING[but.CostumValue]))
    call text[GetPlayerId(p)].ShowToPlayer(true, GameCamera, p)
    
    loop
        exitwhen i > SPELLCOUNT
            if (( TEXTUREUSING[but.CostumValue] == SDESTTYPE[i] )) then
            set iii = i
            if (( COOLDOWNS[iii] > 0 )) then
                call SimError(Player(0), "Spell is not ready yet.")
            endif
            if (( IsCooldownOn[i] == false )) then
                if (( GetUnitState(DGUIUNIT, UNIT_STATE_MANA) < MANACOST[i] )) then
                    call SimError(Player(0), "Not enough mana.")
                endif
            if (( GetUnitState(DGUIUNIT, UNIT_STATE_MANA) >= MANACOST[i] )) then
                call UnitAddAbility(DGUIUNIT, SPELLTYPE[i])
                call SetUnitState(DGUIUNIT, UNIT_STATE_MANA, GetUnitState(DGUIUNIT, UNIT_STATE_MANA) - MANACOST[1])
                
                //
                if (( STARGET[i] == "null" )) then
                    call IssueImmediateOrder(DGUIUNIT, ORDERSTRING[i])
                endif
                //
                
                if (( STARGET[i] == "self" )) then
                    call IssueTargetOrder(DGUIUNIT, ORDERSTRING[i], DGUIUNIT)
                endif
                //
                
                set IsCooldownOn[i] = true
                set COOLDOWNS[i] = SCOOLDOWN[i]
                set ii = i
                call Cooldown()
            endif 
            endif
            endif
        set i = i + 1
    endloop
    call TriggerSleepAction(.25)
    call UnitRemoveAbility(DGUIUNIT, SPELLTYPE[ii])
set p = null
endfunction

private function WhenRightClick takes nothing returns nothing
local BUTTON but = GetTriggerButton()
local player p = GetTriggerPlayer()
    
    call BJDebugMsg("Player "+GetPlayerName(p)+" is right clicked in the button with the value: "+I2S(but.CostumValue))
        
    call pict[GetPlayerId(p)].ShowToPlayer(false, GameCamera, p)
    call text[GetPlayerId(p)].ShowToPlayer(false, GameCamera, p)
    
set p = null
endfunction

//===========================================================================
function SpellCast takes nothing returns nothing
//Create three buttons
local integer i = 0
local integer a = 1
local integer b = 1
local integer ar = 0
local integer ii = 1

set GameCamera = CAMERA.New()
    
    loop
     exitwhen a > 10
            set DGUIBUTTONS[a] = BUTTON.New(0, 0, WidthSlot, HeightSlot, 0.5, TypeTextureBlank)
            set DGUIBUTTONS[a].CostumValue = a
            call DGUIBUTTONS[a].SetPosition(-.60+.10*a, -.805)
            call DGUIBUTTONS[a].Show(true, GameCamera)
            set SPELLCOOLDOWNTEXT[a] = TEXT.New(-.59+.10*a, -.884, 1)
            call SPELLCOOLDOWNTEXT[a].ShowToPlayer(true, GameCamera, Player(0))
     set a = a + 1
    endloop
    
    
    loop
        //Create a picture and text to each player
        //PICTURE method NewCostumModel takes real minx, real maxy, real z, real size, integer typeunit, real WidthModel, real HeightModel, integer texture                                 
        set pict[i] = PICTURE.NewCostumModel(-0.99, 0.95, 1, 0.26, 'dwin', 140.002, 122.646, 'D201'+RaceToInt(GetPlayerRace(Player(i))))
        //TEXT method New takes real minx, real maxy, real z returns TEXT
        set text[i] = TEXT.New(-0.9, 0.70, 1)
        set i = i + 1
        exitwhen i>=bj_MAX_PLAYER_SLOTS
    endloop   
    
    
set u = CreateUnit(Player(0), 'hfoo', 0,0, 180)
call SelectUnitForPlayerSingle(u,Player(0))
set DGUIUNIT = u

    set FuncLClickSlot = function WhenLeftClick
    set FuncRClickSlot = function WhenRightClick
    
    call BUTTON.AddActionL(FuncLClickSlot)
    call BUTTON.AddActionR(FuncRClickSlot)
    

    set TEXTUREUSING[5] = SDESTTYPE[1]
    call DGUIBUTTONS[5].SetTexture(SDESTTYPE[1])
    
    set TEXTUREUSING[2] = SDESTTYPE[2]
    call DGUIBUTTONS[2].SetTexture(SDESTTYPE[2])
    
    set TEXTUREUSING[9] = SDESTTYPE[3]
    call DGUIBUTTONS[9].SetTexture(SDESTTYPE[3])
    
    set TEXTUREUSING[10] = SDESTTYPE[3]
    call DGUIBUTTONS[10].SetTexture(SDESTTYPE[3])
    
    set TEXTUREUSING[8] = SDESTTYPE[3]
    call DGUIBUTTONS[8].SetTexture(SDESTTYPE[3])
    

endfunction
endscope

Collapse JASS:
globals
    constant real GamePeriod = 0.04
    trigger GameTimer = null
    CAMERA GameCamera = NULL
    unit GameUnit = null
    player GamePlayer = null
endglobals


function Approximately takes real v1, real v2, real s returns boolean
    return v2-s < v1 and v1 < v2+s
endfunction

function GameUpdate takes nothing returns nothing
    local real ang = GetUnitFacing(GameUnit)*bj_DEGTORAD
    local real tx = GetUnitX(GameUnit)
    local real ty = GetUnitY(GameUnit)
    local real tz = GetTerrainZ(tx, ty)+GetUnitDefaultFlyHeight(GameUnit)+150
    local real dex = (tx-550*Cos(ang))-GameCamera.Eye.x
    local real dey = (ty-550*Sin(ang))-GameCamera.Eye.y
    local real dez = (tz+100)-GameCamera.Eye.z
    local real X = GameCamera.Eye.x+dex*0.07
    local real Y = GameCamera.Eye.y+dey*0.07
    local real Z = GameCamera.Eye.z+dez*0.07
    set ang = GetTerrainZ(X, Y)+170
    if Z < ang then
        set Z = ang
    endif
    if not(Approximately(X, GameCamera.Eye.x, 1) and Approximately(Y, GameCamera.Eye.y, 1) and Approximately(Z, GameCamera.Eye.z, 1) and Approximately(tx, GameCamera.At.x, 1) and Approximately(ty, GameCamera.At.y, 1) and Approximately(tz, GameCamera.At.z, 1)) then
        call GameCamera.SetEyeAndAt(X, Y, Z, tx, ty, tz)
    endif
endfunction

function GamePostUpdate takes nothing returns nothing
    if GameCamera.ApplyCameraForPlayer(Player(0), false) then
        call Update(true, true, true)
    endif
    //call UpdateFigure(GameCamera)
endfunction

function InitTrig_StartGame takes nothing returns nothing
    set GameUnit = u
    set GameTimer = CreateTrigger()
    call TriggerRegisterTimerEvent(GameTimer, GamePeriod, true)
    call TriggerAddAction(GameTimer, function GameUpdate)
    call TriggerAddAction(GameTimer, function GamePostUpdate)
    call DestroyTimer(GetExpiredTimer())
endfunction 

BUT it doesnt work properly by placing the textures nor the pressing

Last edited by Slaydon : 04-17-2010 at 01:36 PM.
Slaydon is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:44 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services