- Joined
- Jun 3, 2010
- Messages
- 47
Per the request of The_Reborn_Devil, I've posted this here. So, this is GUI-Friendly Double Click event registration. Attatched map has variable creator and importation is simple as copying the GDC Trigger Category, and everything is done for you. You can register an event with the
Game - MS_Event becomes Equal to 1.00
event, and the rest is taken care of for you. Use MS_EventResponse
as the clicked unit. Weep has reported that triggering unit works to, but only tested in a local game. I'm suspecting the variable is slightly faster. Everything else in documentation.
JASS:
//
// .oooooo. oooooooooo. .oooooo.
// d8P' `Y8b `888' `Y8b d8P' `Y8b
// 888 888 888 888
// 888 888 888 888
// 888 ooooo 888 888 888
// `88. .88' 888 d88' `88b ooo
// `Y8bood8P' o888bood8P' `Y8bood8P'
// GUI-Double Click (1.1D)
//
//
// GUI-Double Click is a snippet designed for GUI, but it works with JASS, as well. In
// laymens' terms, it gives the support of a Double Click event. That's it, simple and
// lightweight. It no longer requires GTS.
//
// However, GTS can be still be found at: www.thehelper.net/forums/showthread.php?t=151051
//
// In order to import this system, open the demo map and copy the category "GDC" and
// then paste it in your map. Make sure that "Automatically create unknown variables
// while pasting trigger data" is enabled in your preferences before you do this.
//
// To create a Double-Click event trigger, use the event "Game - Real becomes Equal to 0.00" and
// select MS_Event as the real, and change "0.00" to "1.00". Example in the "DoubleClick"
// trigger.
//
// Please include this documentation inside your trigger editor, and do not delete it.
//
//
//
//
// (here is a global block you can un-comment if you
// would like to use this with vJASS instead of the
// plain world editor.)
//
// globals
// real udg_MS_Event=0
// unit udg_MS_EventResponse
// unit array udg_MS_CurrentUnit[11]
// timer array udg_MS_TimerArray[11]
// boolean array udg_MS_BooleanArray[11]
// endglobals
constant function MS_GetTime takes nothing returns real
// You know, for reading this far, you can
// adjust the amount of time that can pass between
// clicks to be considered a "double click".
return 1.00
endfunction
function MS_GetTimerPlayerId takes timer t returns integer
return GetHandleId(t)-GetHandleId(udg_MS_TimerArray[0])
endfunction
function MS_onExpire takes nothing returns nothing
set udg_MS_BooleanArray[MS_GetTimerPlayerId(GetExpiredTimer())]=false // They didn't double click? Damn.
endfunction
function MS_SingleSelect takes nothing returns boolean
local player p=GetTriggerPlayer()
local unit TriggerUnit=GetTriggerUnit()
local integer index=GetPlayerId(p)
if udg_MS_BooleanArray[index]==true and TriggerUnit==udg_MS_CurrentUnit[index] then
set udg_MS_EventResponse=TriggerUnit // HURRAH, EVENT RESPONSES.
set udg_MS_Event=1 // RUN THAT EVENT, DAWG.
set udg_MS_Event=0 // RUN THAT EVENT NASTY.
set udg_MS_BooleanArray[index]=false
set p=null
set TriggerUnit=null
return false
endif
call PauseTimer(udg_MS_TimerArray[index])
set udg_MS_BooleanArray[index]=true // We need to set a single click event to true, and,
set udg_MS_CurrentUnit[index]=TriggerUnit // save the selected unit.
call TimerStart(udg_MS_TimerArray[index],MS_GetTime(),false,function MS_onExpire)
set TriggerUnit=null
set p=null
return false
endfunction
function InitTrig_GDC takes nothing returns nothing
local trigger t=CreateTrigger()
local integer index=0
loop
set udg_MS_TimerArray[index]=CreateTimer()
set index=index+1
exitwhen index==12
endloop
set index=0
loop
call TriggerRegisterPlayerUnitEvent(t,Player(index),EVENT_PLAYER_UNIT_SELECTED,null)
set index=index+1
exitwhen index==12
endloop
call TriggerAddCondition(t,Condition(function MS_SingleSelect))
endfunction