WC3Jass.com Forum Index WC3Jass.com
"The Jass Vault"
 
 FAQ   Search   Memberlist   Usergroups   Register 
 Profile   Log in to check your private messages   Log in  
 Forum   Scripts   Files   Chat   Pastebin   Function finder  
Affiliates
The HIVE Workshop Games Modding
The Hubb Wc3Campaigns
WC3-Mapping.net

GUI-Friendly Double Click (GDC)

 
Post new topic   Reply to topic    WC3Jass.com Forum Index -> The Showcase
View previous script :: View next script  

Author
ToolTipError


Joined: 30 May 2010
Posts: 1
Back to top
Message
PostPosted: Sun May 30, 2010 1:54 pm    Post subject: GUI-Friendly Double Click (GDC) Reply with quote

Originally posted at Thehelper, GDC is a snippet inspired by Azlier's Double Click. I was upset at the fact that Azlier's required Event (Jesus4Lyf) and used vJASS, which is the scourge of Mac life. Originally GDC required Weep's GUI-Friendly Timer System, but it is now independent of all other systems, including JassHelper and the NewGen pack. The brilliance of GDC is that it can be run with the event Game - Value of MS_Event becomes Equal to 1.00.

Code:
//
//        .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.1C)
//
//
//       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: [url]www.thehelper.net/forums/showthread.php?t=151051[/url]
//
//       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


If you're on a Mac or don't use JassHelper, you can get the test map with the variable creator here.

(By the way, these [code] tags are prettier than thehelper's.)
_________________
e=mc˛
View user's profile Send private message

Display posts from previous:   
Post new topic   Reply to topic    WC3Jass.com Forum Index -> The Showcase All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


FSDark by SkaidonDesigns
Powered by phpBB © 2001, 2002 phpBB Group