Guest User

Untitled

a guest
Feb 7th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. -- Sukritact_HotkeyManager
  2. -- Author: Sukrit
  3. -- DateCreated: 2/4/2016 8:14:30 AM
  4. --=======================================================================================================================
  5. -- Prevent Duplicates
  6. --=======================================================================================================================
  7. if MapModData.Sukritact_HotkeyManager then return end
  8. MapModData.Sukritact_HotkeyManager = true
  9. Events.SequenceGameInitComplete.Add(function() MapModData.Sukritact_HotkeyManager = nil end)
  10. --=======================================================================================================================
  11. -- Globals
  12. --=======================================================================================================================
  13. tNoMods = {}
  14. tShift = {}
  15. tCtrl = {}
  16. tAlt = {}
  17.  
  18. -- 2 Modifiers
  19. tShiftCtrl = {}
  20. tShiftAlt = {}
  21. tCtrlAlt = {}
  22.  
  23. -- 3 Modifiers
  24. tShiftCtrlAlt = {}
  25.  
  26. for tRow in GameInfo.Sukritact_HotkeyManager() do
  27.  
  28. local sLuaEvent = tRow.LuaEventName
  29. local iHotKey = Keys[tRow.Hotkey]
  30.  
  31. if sLuaEvent and iHotKey then
  32. local bShift = tRow.ShiftDown
  33. local bCtrl = tRow.CtrlDown
  34. local bAlt = tRow.AltDown
  35.  
  36. if bShift and bCtrl and bAlt then
  37. tShiftCtrlAlt[iHotKey] = LuaEvents[sLuaEvent]
  38.  
  39. elseif bShift and bCtrl then
  40. tShiftCtrl[iHotKey] = LuaEvents[sLuaEvent]
  41.  
  42. elseif bShift and bAlt then
  43. tShiftAlt[iHotKey] = LuaEvents[sLuaEvent]
  44.  
  45. elseif bCtrl and bAlt then
  46. tCtrlAlt[iHotKey] = LuaEvents[sLuaEvent]
  47.  
  48. elseif bShift then
  49. tShift[iHotKey] = LuaEvents[sLuaEvent]
  50.  
  51. elseif bCtrl then
  52. tCtrl[iHotKey] = LuaEvents[sLuaEvent]
  53.  
  54. elseif bAlt then
  55. tAlt[iHotKey] = LuaEvents[sLuaEvent]
  56.  
  57. else
  58. tNoMods[iHotKey] = LuaEvents[sLuaEvent]
  59. end
  60. end
  61. end
  62. --=======================================================================================================================
  63. -- InputHandler
  64. --=======================================================================================================================
  65. function InputHandler(uiMsg, wParam, lParam)
  66. if not(uiMsg == KeyEvents.KeyDown) then return end
  67.  
  68. local bShift = UIManager:GetShift()
  69. local bCtrl = UIManager:GetControl()
  70. local bAlt = UIManager:GetAlt()
  71.  
  72. if bShift and bCtrl and bAlt then
  73. if tShiftCtrlAlt[wParam] then
  74. tShiftCtrlAlt[wParam]()
  75. end
  76. elseif bShift and bCtrl then
  77. if tShiftCtrl[wParam] then
  78. tShiftCtrl[wParam]()
  79. end
  80.  
  81. elseif bShift and bAlt then
  82. if tShiftAlt[wParam] then
  83. tShiftAlt[wParam]()
  84. end
  85.  
  86. elseif bCtrl and bAlt then
  87. if tCtrlAlt[wParam] then
  88. tCtrlAlt[wParam]()
  89. end
  90.  
  91. elseif bShift then
  92. if tShift[wParam] then
  93. tShift[wParam]()
  94. end
  95.  
  96. elseif bCtrl then
  97. if tCtrl[wParam] then
  98. tCtrl[wParam]()
  99. end
  100.  
  101. elseif bAlt then
  102. if tAlt[wParam] then
  103. tAlt[wParam]()
  104. end
  105.  
  106. else
  107. if tNoMods[wParam] then
  108. tNoMods[wParam]()
  109. end
  110. end
  111. end
  112. ContextPtr:SetInputHandler(InputHandler)
  113. --=======================================================================================================================
  114. --=======================================================================================================================
Add Comment
Please, Sign In to add comment