- Joined
- Apr 3, 2010
- Messages
- 1,889
An extension to [System] ArrowKeyEvent.
Check out that thread for its features as I will talk about this extensions feature here.
Just import this extention to your map and it will be auto implemented into any struct that you use the latest update of Bribes [System] ArrowKeyEvent syetem with.
(this will not be directly useable to the public untill Bribe updates his system)
An extension to [System] ArrowKeyEvent.
Check out that thread for its features as I will talk about this extensions feature here.
Allows players to be removed and added to any arrow key event system with the use of implementing this module and Bribes [System] ArrowKeyEvent in appropriate structs.
Implement this module into a struct that you want to use Arrow Key Events for.
Check out description inside the trigger for how to use this.
Check out the demo for an example of how to use this.
Check out that thread for its features as I will talk about this extensions feature here.
Just import this extention to your map and it will be auto implemented into any struct that you use the latest update of Bribes [System] ArrowKeyEvent syetem with.
(this will not be directly useable to the public untill Bribe updates his system)
JASS:
library ArrowKeyPlayerEnabled /* v2.0.0.0, created by SA Dashie, Advice from IcemanBo with simplifying further
*/ uses /*
*/ ArrowKeyEvent /* http://www.hiveworkshop.com/forums/jass-resources-412/system-arrowkeyevent-205650/
Description
Extra for the ArrowKeyEvent system by Bribe.
Adds a condition if the the player index is enabled.
Just import this extention to your map and it will be auto
implemented into any struct that you use the latest update
of Bribes [System] ArrowKeyEvent syetem with.
Fields
boolean enabled
- is false by default
static boolean enabledAll
*/
//! textmacro ARROW_KEY_CONDITION_VARIABLE
boolean enabled
static boolean enabledAll = true
//! endtextmacro
//! textmacro ARROW_KEY_CONDITION_ITE
if not (enabledAll and thistype(.eventPlayerId).canPlayerPass) then
return
endif
//! endtextmacro
endlibrary
JASS:
library ArrowTest uses ArrowKeyEvent, ArrowKeyPlayerEnabled
struct ArrowTest extends array
private static method onArrowKeyEvent takes integer arrow, boolean pressed returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetPlayerName(Player(eventPlayerId)) + " enabled test")
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "//--")
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Setting enabledAll to false")
call enabledAll = false
endmethod
private static method onInit takes nothing returns nothing
call thistype[Player(0)].Enabled = true
call thistype(2).Enabled = true
endmethod
implement ArrowKey
endstruct
endlibrary
An extension to [System] ArrowKeyEvent.
Check out that thread for its features as I will talk about this extensions feature here.
Allows players to be removed and added to any arrow key event system with the use of implementing this module and Bribes [System] ArrowKeyEvent in appropriate structs.
JASS:
/* Created by DeathChef
module ArrowKeyEvent_PlayerRegister v1.0.0.0
Description
Extension of Bribes [System] ArrowKeyEvent
Allows players to be removed and added to any arrow
key event system with the use of implementing this
module and Bribes [System] ArrowKeyEvent
Use with
[System] ArrowKeyEvent [url]http://www.hiveworkshop.com/forums/jass-resources-412/system-arrowkeyevent-205650/[/url]
Methods
static method AddArrowKeysPlayerId takes thistype PlayerId returns nothing
static method RemoveArrowKeysPlayerId takes thistype PlayerId returns nothing
static method AddArrowKeysAllPlayers takes nothing returns nothing
static method RemoveArrowKeysAllPlayers takes nothing returns nothing
Fields
boolean IsPlayerRegistered
How to use
Check out the demo for a code example
1. Implement ArrowKeyEvent_PlayerRegister along side with the ArrowKey module
2. Within your onArrowKeyEvent method create as the first ITE line as
if thistype(.eventPlayerId).IsPlayerRegistered then
//code body
endif
3. Use the custom methods that come with the module
*/
module ArrowKeyEvent_PlayerRegister
boolean IsPlayerRegistered
static method AddArrowKeysPlayerId takes thistype PlayerId returns nothing
set PlayerId.IsPlayerRegistered = GetPlayerSlotState(Player(PlayerId)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(PlayerId)) == MAP_CONTROL_USER
endmethod
static method RemoveArrowKeysPlayerId takes thistype PlayerId returns nothing
set PlayerId.IsPlayerRegistered = false
endmethod
static method AddArrowKeysAllPlayers takes nothing returns nothing
local thistype this = 11
loop
set IsPlayerRegistered = GetPlayerSlotState(Player(this)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(this)) == MAP_CONTROL_USER
exitwhen this == 0
set this = this - 1
endloop
endmethod
static method RemoveArrowKeysAllPlayers takes nothing returns nothing
local thistype this = 11
loop
set IsPlayerRegistered = false
exitwhen this == 0
set this = this - 1
endloop
endmethod
endmodule
JASS:
library tester uses ArrowKeyEvent
struct tester extends array
method onArrowKeyEvent takes integer arrow, boolean pressed returns nothing
if thistype(.eventPlayerId).IsPlayerRegistered then
static if LIBRARY_ArrowKey then
call BJDebugMsg("Axis Focus: X: " + .getKeyName(thistype(0).getAxisKey(ARROW_KEY_X_AXIS)) + ", Y: " + .getKeyName(thistype(0).getAxisKey(ARROW_KEY_Y_AXIS)))
elseif DEBUG_MODE then
if pressed then
call BJDebugMsg("Key pressed: " + .getKeyName(arrow))
else
call BJDebugMsg("Key released: " + .getKeyName(arrow))
endif
endif
endif
endmethod
static method onInit takes nothing returns nothing
call AddArrowKeysAllPlayers()
endmethod
implement ArrowKeyEvent_PlayerRegister
implement ArrowKey
endstruct
endlibrary
Implement this module into a struct that you want to use Arrow Key Events for.
- Register and Unregister individual (or all players at once) players. This snippet allows different players to use different key events at the same time
- Just code the method into your struct for each individual arrow key event
Check out description inside the trigger for how to use this.
Check out the demo for an example of how to use this.
JASS:
module ArrowEvents /* v2.0.0.0, created by DeathChef
Description
Basic module for registering the arrow key events to
individual methods
Can register and unregister players arrow keys
If a key event static method does not exist then code
will not contain errors
Fields
boolean IsRegistered
//If a User Defined Method does not exist
//the corresponding field neither will
trigger PressUp
trigger PressDown
trigger PressLeft
trigger PressRight
trigger ReleaseUp
trigger ReleaseDown
trigger ReleaseLeft
trigger ReleaseRight
triggeraction ActionPressUp
triggeraction ActionPressDown
triggeraction ActionPressLeft
triggeraction ActionPressRight
triggeraction ActionReleaseUp
triggeraction ActionReleaseDown
triggeraction ActionReleaseLeft
triggeraction ActionReleaseRight
Methods
static method AddArrowKeysPlayerId takes thistype PlayerId returns nothing
static method RemoveArrowKeysPlayerId takes thistype PlayerId returns nothing
static method AddArrowKeysAllPlayers takes nothing returns nothing
static method RemoveArrowKeysAllPlayers takes nothing returns nothing
User Defined Methods
static method UpPress takes nothing returns nothing
static method DownPress takes nothing returns nothing
static method LeftPress takes nothing returns nothing
static method RightPress takes nothing returns nothing
static method UpRelease takes nothing returns nothing
static method DownRelease takes nothing returns nothing
static method LeftRelease takes nothing returns nothing
static method RightRelease takes nothing returns nothing
How to use
Check out the demo code for example
1. Copy and paste this whole library into your map in a
unique trigger
2. Implement ArrowEvents at the bottom of your desired struct
3. Create onInit static method
private static method onInit takes nothing returns nothing
call AddArrowKeysAllPlayers()
//or
call AddArrowKeysPlayerId(PlayerId)
endmethod
3. Code and use any of these static methods into your struct code
static method UpPress takes nothing returns nothing
static method DownPress takes nothing returns nothing
static method LeftPress takes nothing returns nothing
static method RightPress takes nothing returns nothing
static method UpRelease takes nothing returns nothing
static method DownRelease takes nothing returns nothing
static method LeftRelease takes nothing returns nothing
static method RightRelease takes nothing returns nothing
4. Use other methods or/and create body of code for arrow keys
*/
boolean IsRegistered
static if thistype.UpPress.exists then
private trigger PressUp
private triggeraction ActionPressUp
endif
static if thistype.DownPress.exists then
private trigger PressDown
private triggeraction ActionPressDown
endif
static if thistype.LeftPress.exists then
private trigger PressLeft
private triggeraction ActionPressLeft
endif
static if thistype.RightPress.exists then
private trigger PressRight
private triggeraction ActionPressRight
endif
static if thistype.UpRelease.exists then
private trigger ReleaseUp
private triggeraction ActionReleaseUp
endif
static if thistype.DownRelease.exists then
private trigger ReleaseDown
private triggeraction ActionReleaseDown
endif
static if thistype.LeftRelease.exists then
private trigger ReleaseLeft
private triggeraction ActionReleaseLeft
endif
static if thistype.RightRelease.exists then
private trigger ReleaseRight
private triggeraction ActionReleaseRight
endif
static method AddArrowKeysPlayerId takes thistype PlayerId returns nothing
if not PlayerId.IsRegistered and GetPlayerSlotState(Player(PlayerId)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(PlayerId)) == MAP_CONTROL_USER then
set PlayerId.IsRegistered = true
static if thistype.UpPress.exists then
set PlayerId.ActionPressUp = TriggerAddAction(PlayerId.PressUp, function thistype.UpPress)
endif
static if thistype.DownPress.exists then
set PlayerId.ActionPressDown = TriggerAddAction(PlayerId.PressDown, function thistype.DownPress)
endif
static if thistype.LeftPress.exists then
set PlayerId.ActionPressLeft = TriggerAddAction(PlayerId.PressLeft, function thistype.LeftPress)
endif
static if thistype.RightPress.exists then
set PlayerId.ActionPressRight = TriggerAddAction(PlayerId.PressRight, function thistype.RightPress)
endif
static if thistype.UpRelease.exists then
set PlayerId.ActionReleaseUp = TriggerAddAction(PlayerId.ReleaseUp, function thistype.UpRelease)
endif
static if thistype.DownRelease.exists then
set PlayerId.ActionReleaseDown = TriggerAddAction(PlayerId.ReleaseDown, function thistype.DownRelease)
endif
static if thistype.LeftRelease.exists then
set PlayerId.ActionReleaseLeft = TriggerAddAction(PlayerId.ReleaseLeft, function thistype.LeftRelease)
endif
static if thistype.RightRelease.exists then
set PlayerId.ActionReleaseRight = TriggerAddAction(PlayerId.ReleaseRight, function thistype.RightRelease)
endif
endif
endmethod
static method RemoveArrowKeysPlayerId takes thistype PlayerId returns nothing
if PlayerId.IsRegistered then
set PlayerId.IsRegistered = false
static if thistype.UpPress.exists then
call TriggerRemoveAction(PlayerId.PressUp, PlayerId.ActionPressUp)
endif
static if thistype.DownPress.exists then
call TriggerRemoveAction(PlayerId.PressDown, PlayerId.ActionPressDown)
endif
static if thistype.LeftPress.exists then
call TriggerRemoveAction(PlayerId.PressLeft, PlayerId.ActionPressLeft)
endif
static if thistype.RightPress.exists then
call TriggerRemoveAction(PlayerId.PressRight, PlayerId.ActionPressRight)
endif
static if thistype.UpRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseUp, PlayerId.ActionReleaseUp)
endif
static if thistype.DownRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseDown, PlayerId.ActionReleaseDown)
endif
static if thistype.LeftRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseLeft, PlayerId.ActionReleaseLeft)
endif
static if thistype.RightRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseRight, PlayerId.ActionReleaseRight)
endif
endif
endmethod
static method AddArrowKeysAllPlayers takes nothing returns nothing
local thistype this = 11
local player p = Player(this)
loop
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
call AddArrowKeysPlayerId(this)
endif
exitwhen this == 0
set this = this - 1
set p = Player(this)
endloop
set p = null
endmethod
static method RemoveArrowKeysAllPlayers takes nothing returns nothing
local thistype this = 11
local player p = Player(this)
loop
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
call RemoveArrowKeysPlayerId(this)
endif
exitwhen this == 0
set this = this - 1
set p = Player(this)
endloop
set p = null
endmethod
private static method onInit takes nothing returns nothing
local thistype this = 11
local player p = Player(this)
loop
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
static if thistype.UpPress.exists then
set PressUp = CreateTrigger()
call TriggerRegisterPlayerEvent(PressUp, p, EVENT_PLAYER_ARROW_UP_DOWN)
endif
static if thistype.DownPress.exists then
set PressDown = CreateTrigger()
call TriggerRegisterPlayerEvent(PressDown, p, EVENT_PLAYER_ARROW_DOWN_DOWN)
endif
static if thistype.LeftPress.exists then
set PressLeft = CreateTrigger()
call TriggerRegisterPlayerEvent(PressLeft, p, EVENT_PLAYER_ARROW_LEFT_DOWN)
endif
static if thistype.RightPress.exists then
set PressRight = CreateTrigger()
call TriggerRegisterPlayerEvent(PressRight, p, EVENT_PLAYER_ARROW_RIGHT_DOWN)
endif
static if thistype.UpRelease.exists then
set ReleaseUp = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseUp, p, EVENT_PLAYER_ARROW_UP_UP)
endif
static if thistype.DownRelease.exists then
set ReleaseDown = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseDown, p, EVENT_PLAYER_ARROW_DOWN_UP)
endif
static if thistype.LeftRelease.exists then
set ReleaseLeft = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseLeft, p, EVENT_PLAYER_ARROW_LEFT_UP)
endif
static if thistype.RightRelease.exists then
set ReleaseRight = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseRight, p, EVENT_PLAYER_ARROW_RIGHT_UP)
endif
endif
exitwhen this == 0
set this = this - 1
set p = Player(this)
endloop
set p = null
endmethod
endmodule
JASS:
library ArrowKeyDemo
struct ArrowKeyDemo extends array
boolean UpPressed
private static method UpPress takes nothing returns nothing
set thistype[GetPlayerId(GetTriggerPlayer())].UpPressed = true
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "UpPress")
//Function body
endmethod
private static method UpRelease takes nothing returns nothing
set thistype[GetPlayerId(GetTriggerPlayer())].UpPressed = false
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "UpRelease")
//Defunction body
endmethod
private static method LeftPress takes nothing returns nothing
call RemoveArrowKeysPlayerId(GetPlayerId(GetTriggerPlayer()))
//Defunction body
endmethod
private static method onInit takes nothing returns nothing
call AddArrowKeysAllPlayers()
endmethod
implement ArrowEvents
endstruct
endlibrary
JASS:
library ArrowEvents /* v1.1.0.0, created by DeathChef
*/ uses /*
*/ PlayerManager /*
module ArrowEvents
Description
Basic module for registering the arrow key events to
individual methods
Can register and unregister players arrow keys
If a key event static method does not exist then code
will not contain errors
Fields
boolean IsRegistered
//If a User Defined Method does not exist
//the corresponding field neither will
trigger PressUp
trigger PressDown
trigger PressLeft
trigger PressRight
trigger ReleaseUp
trigger ReleaseDown
trigger ReleaseLeft
trigger ReleaseRight
triggeraction ActionPressUp
triggeraction ActionPressDown
triggeraction ActionPressLeft
triggeraction ActionPressRight
triggeraction ActionReleaseUp
triggeraction ActionReleaseDown
triggeraction ActionReleaseLeft
triggeraction ActionReleaseRight
Methods
static method AddArrowKeysPlayerId takes thistype PlayerId returns nothing
static method RemoveArrowKeysPlayerId takes thistype PlayerId returns nothing
static method AddArrowKeysAllPlayers takes nothing returns nothing
static method RemoveArrowKeysAllPlayers takes nothing returns nothing
User Defined Methods
static method UpPress takes nothing returns nothing
static method DownPress takes nothing returns nothing
static method LeftPress takes nothing returns nothing
static method RightPress takes nothing returns nothing
static method UpRelease takes nothing returns nothing
static method DownRelease takes nothing returns nothing
static method LeftRelease takes nothing returns nothing
static method RightRelease takes nothing returns nothing
How to use
Check out the demo code for example
1. Copy and paste this whole library into your map in a
unique trigger
2. Implement ArrowEvents at the bottom of your desired struct
3. Create onInit static method
private static method onInit takes nothing returns nothing
call AddArrowKeysAllPlayers()
//or
call AddArrowKeysPlayerId(PlayerId)
endmethod
3. Code and use any of these static methods into your struct code
static method UpPress takes nothing returns nothing
static method DownPress takes nothing returns nothing
static method LeftPress takes nothing returns nothing
static method RightPress takes nothing returns nothing
static method UpRelease takes nothing returns nothing
static method DownRelease takes nothing returns nothing
static method LeftRelease takes nothing returns nothing
static method RightRelease takes nothing returns nothing
4. Use other methods or/and create body of code for arrow keys
*/
module ArrowEvents
boolean IsRegistered
static if thistype.UpPress.exists then
trigger PressUp
triggeraction ActionPressUp
endif
static if thistype.DownPress.exists then
trigger PressDown
triggeraction ActionPressDown
endif
static if thistype.LeftPress.exists then
trigger PressLeft
triggeraction ActionPressLeft
endif
static if thistype.RightPress.exists then
trigger PressRight
triggeraction ActionPressRight
endif
static if thistype.UpRelease.exists then
trigger ReleaseUp
triggeraction ActionReleaseUp
endif
static if thistype.DownRelease.exists then
trigger ReleaseDown
triggeraction ActionReleaseDown
endif
static if thistype.LeftRelease.exists then
trigger ReleaseLeft
triggeraction ActionReleaseLeft
endif
static if thistype.RightRelease.exists then
trigger ReleaseRight
triggeraction ActionReleaseRight
endif
static method AddArrowKeysPlayerId takes thistype PlayerId returns nothing
if not PlayerId.IsRegistered and Human[PlayerId].get != null then
set PlayerId.IsRegistered = true
static if thistype.UpPress.exists then
set PlayerId.ActionPressUp = TriggerAddAction(PlayerId.PressUp, function thistype.UpPress)
endif
static if thistype.DownPress.exists then
set PlayerId.ActionPressDown = TriggerAddAction(PlayerId.PressDown, function thistype.DownPress)
endif
static if thistype.LeftPress.exists then
set PlayerId.ActionPressLeft = TriggerAddAction(PlayerId.PressLeft, function thistype.LeftPress)
endif
static if thistype.RightPress.exists then
set PlayerId.ActionPressRight = TriggerAddAction(PlayerId.PressRight, function thistype.RightPress)
endif
static if thistype.UpRelease.exists then
set PlayerId.ActionReleaseUp = TriggerAddAction(PlayerId.ReleaseUp, function thistype.UpRelease)
endif
static if thistype.DownRelease.exists then
set PlayerId.ActionReleaseDown = TriggerAddAction(PlayerId.ReleaseDown, function thistype.DownRelease)
endif
static if thistype.LeftRelease.exists then
set PlayerId.ActionReleaseLeft = TriggerAddAction(PlayerId.ReleaseLeft, function thistype.LeftRelease)
endif
static if thistype.RightRelease.exists then
set PlayerId.ActionReleaseRight = TriggerAddAction(PlayerId.ReleaseRight, function thistype.RightRelease)
endif
endif
endmethod
static method RemoveArrowKeysPlayerId takes thistype PlayerId returns nothing
if PlayerId.IsRegistered then
set PlayerId.IsRegistered = false
static if thistype.UpPress.exists then
call TriggerRemoveAction(PlayerId.PressUp, PlayerId.ActionPressUp)
endif
static if thistype.DownPress.exists then
call TriggerRemoveAction(PlayerId.PressDown, PlayerId.ActionPressDown)
endif
static if thistype.LeftPress.exists then
call TriggerRemoveAction(PlayerId.PressLeft, PlayerId.ActionPressLeft)
endif
static if thistype.RightPress.exists then
call TriggerRemoveAction(PlayerId.PressRight, PlayerId.ActionPressRight)
endif
static if thistype.UpRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseUp, PlayerId.ActionReleaseUp)
endif
static if thistype.DownRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseDown, PlayerId.ActionReleaseDown)
endif
static if thistype.LeftRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseLeft, PlayerId.ActionReleaseLeft)
endif
static if thistype.RightRelease.exists then
call TriggerRemoveAction(PlayerId.ReleaseRight, PlayerId.ActionReleaseRight)
endif
endif
endmethod
static method AddArrowKeysAllPlayers takes nothing returns nothing
local thistype this = Human.first
loop
call AddArrowKeysPlayerId(this)
set this = Human[this].next
exitwhen Human[this].end
endloop
endmethod
static method RemoveArrowKeysAllPlayers takes nothing returns nothing
local thistype this = Human.first
loop
call RemoveArrowKeysPlayerId(this)
set this = Human[this].next
exitwhen Human[this].end
endloop
endmethod
private static method onInit takes nothing returns nothing
local thistype this = Human.first
local player p
loop
set p = Human[this].get
static if thistype.UpPress.exists then
set PressUp = CreateTrigger()
call TriggerRegisterPlayerEvent(PressUp, p, EVENT_PLAYER_ARROW_UP_DOWN)
endif
static if thistype.DownPress.exists then
set PressDown = CreateTrigger()
call TriggerRegisterPlayerEvent(PressDown, p, EVENT_PLAYER_ARROW_DOWN_DOWN)
endif
static if thistype.LeftPress.exists then
set PressLeft = CreateTrigger()
call TriggerRegisterPlayerEvent(PressLeft, p, EVENT_PLAYER_ARROW_LEFT_DOWN)
endif
static if thistype.RightPress.exists then
set PressRight = CreateTrigger()
call TriggerRegisterPlayerEvent(PressRight, p, EVENT_PLAYER_ARROW_RIGHT_DOWN)
endif
static if thistype.UpRelease.exists then
set ReleaseUp = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseUp, p, EVENT_PLAYER_ARROW_UP_UP)
endif
static if thistype.DownRelease.exists then
set ReleaseDown = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseDown, p, EVENT_PLAYER_ARROW_DOWN_UP)
endif
static if thistype.LeftRelease.exists then
set ReleaseLeft = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseLeft, p, EVENT_PLAYER_ARROW_LEFT_UP)
endif
static if thistype.RightRelease.exists then
set ReleaseRight = CreateTrigger()
call TriggerRegisterPlayerEvent(ReleaseRight, p, EVENT_PLAYER_ARROW_RIGHT_UP)
endif
set this = Human[this].next
exitwhen Human[this].end
endloop
set p = null
endmethod
endmodule
endlibrary
Last edited: