16 static PluginKeyBinding instance;
19 void PluginKeyBinding()
21 if ( instance ==
null )
49 RegisterKeyBind(
MENU_ANY ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_F1 ,
"PluginDeveloper" ,
"ToggleHelpScreen" ,
"[LCTRL]+[F1]" ,
"Show/Hide help screen");
50 RegisterKeyBind(
MENU_ANY ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_F2 ,
"PluginDeveloper" ,
"ResetGUI" ,
"[LCTRL]+[F2]" ,
"Resets shown UI for testing purposes");
55 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_V ,
"PluginDeveloper" ,
"SpawnFromClipboard" ,
"[Right Shift]" ,
"Spawn item from clipboard");
59 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_INSERT ,-1 ,
"PluginDeveloper" ,
"TeleportAtCursor" ,
"[Insert]" ,
"Teleport player to cursor position");
60 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_HOME ,-1 ,
"PluginDeveloper" ,
"ToggleFreeCamera" ,
"[Home]" ,
"Toggle free camera and teleport player to its position");
61 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_DIVIDE ,-1 ,
"PluginDeveloper" ,
"ToggleFreeCameraBackPos" ,
"[Divide numeric]" ,
"Toggle free camera, no player teleport");
62 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_NUMPAD9 ,
"PluginDeveloperSync" ,
"ToggleFocus" ,
"[LCtrl]+[NUMPAD9]" ,
"Toggle game focus");
66 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_Z ,
"PluginDeveloper" ,
"SetDeveloperItemClient" ,
"Starts watching the item" ,
"Sets the target as Watched item for debug purposes");
67 RegisterKeyBind(
MENU_SCRIPTCONSOLE ,
KeyCode.KC_PRIOR ,-1 ,
"PluginDeveloper" ,
"ScriptHistoryBack" ,
"[Page Up]" ,
"Debug Console => Script history back");
68 RegisterKeyBind(
MENU_SCRIPTCONSOLE ,
KeyCode.KC_NEXT ,-1 ,
"PluginDeveloper" ,
"ScriptHistoryNext" ,
"[Page Down]" ,
"Debug Console => Script history next");
69 RegisterKeyBind(
MENU_SCENE_EDITOR ,
KeyCode.KC_DELETE ,-1 ,
"PluginSceneManager" ,
"DeleteSelectedObject" ,
"[Delete]" ,
"Scene Editor => Delete current selected object");
70 RegisterKeyBind(
MENU_SCENE_EDITOR ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_S ,
"PluginSceneManager" ,
"SceneSave" ,
"[LCtrl]+[S]" ,
"Scene Editor => Save Current Scene");
71 RegisterKeyBind(
MENU_SCENE_EDITOR ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_D ,
"PluginSceneManager" ,
"SelectedObjectDuplicate" ,
"[LCtrl]+[D]" ,
"Scene Editor => Duplicate current selected object");
72 RegisterKeyBind(
MENU_SCENE_EDITOR ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_F ,
"PluginSceneManager" ,
"SelectedObjectFocus" ,
"[LCtrl]+[F]" ,
"Scene Editor => Focus camera on selected object");
73 RegisterKeyBind(
MENU_SCENE_EDITOR ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_E ,
"PluginSceneManager" ,
"RulerToggle" ,
"[LCtrl]+[E]" ,
"Scene Editor => Enable/Disable addition of ruler points");
74 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_PRIOR ,
"PluginRecipesManager" ,
"CallbackGenerateCache" ,
"[LCtrl]+[BACKSPACE]" ,
"PluginRecipesManager => Generate recipe cache and save it to file");
75 RegisterKeyBind(
MENU_ANY ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_DECIMAL ,
"PluginItemDiagnostic" ,
"ToggleDebugWindowEvent" ,
"[LCtrl]+[DECIMAL]" ,
"Close the Item Debug window");
76 RegisterKeyBind(
MENU_ANY ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_NUMPAD0 ,
"PluginDayzPlayerDebug",
"ToggleDebugWindowEvent" ,
"[LCtrl]+[NUMPAD0]" ,
"Open/Close Player debug window");
77 RegisterKeyBind(
MENU_ANY ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_DECIMAL ,
"PluginDayzPlayerDebug",
"ToggleDebugWindowEventP" ,
"[LCtrl]+[DECIMAL]" ,
"Open/Close Player debug window");
78 RegisterKeyBind(
MENU_ANY ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_I ,
"PluginDayZInfectedDebug",
"ToggleDebugWindowEvent" ,
"[LCtrl]+[NUMPAD1]" ,
"Open/Close Infected debug window");
79 RegisterKeyBind(
MENU_ANY ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_O ,
"PluginDayZInfectedDebug",
"PossesInfected" ,
"[LCtrl]+[NUMPAD1]" ,
"Open/Close Infected debug window");
80 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_SCROLL ,
"PluginNutritionDumper" ,
"CheckInit" ,
"[LCtrl]+[SCROLL LOCK]" ,
"Enable Door Ruler");
81 RegisterKeyBind(
MENU_NONE ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_RBRACKET,
"PluginCharPlacement" ,
"CheckInit" ,
"[LCtrl]+[)]" ,
"Enable CharPlacer");
84 RegisterKeyBind(
MENU_CAMERA_TOOLS ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_S ,
"PluginCameraTools" ,
"Save" ,
"[X]" ,
"Recording Tools => Start Recording Camera Path");
85 RegisterKeyBind(
MENU_CAMERA_TOOLS ,
KeyCode.KC_P ,-1 ,
"PluginCameraTools" ,
"PlayPause" ,
"[C]" ,
"Recording Tools => Stop Recording Camera Path");
86 RegisterKeyBind(
MENU_CAMERA_TOOLS ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_Q ,
"PluginCameraTools" ,
"AddKeyframe" ,
"[C]" ,
"Recording Tools => Add Camera Point");
87 RegisterKeyBind(
MENU_CAMERA_TOOLS ,
KeyCode.KC_LCONTROL ,
KeyCode.KC_E ,
"PluginCameraTools" ,
"DeleteKeyframe" ,
"[V]" ,
"Recording Tools => Play Camera Line");
105 RegisterMouseBind(
MENU_NONE ,
MouseState.LEFT ,
MB_EVENT_CLICK ,
"PluginDayZCreatureAIDebug",
"Event_OnClick" ,
"[LMB] Click" ,
"DayZCreature graph debug => Capture entity during capture mode");
126 void OnKeyPress(
int key)
130 for (
int i = 0; i < m_KeyBindings.Count(); ++i )
132 KeyBinding key_binding = m_KeyBindings.Get(i);
134 if ( !IsCurrentUIPageValid( key_binding.GetUIMenuID() ) )
139 bool key1_match =
false;
140 bool key2_match =
false;
142 if ( key_binding.GetKey1() > -1 )
144 if ( IsKeyPressed(key_binding.GetKey1()) )
156 if ( key_binding.GetKey2() > -1 )
158 if ( IsKeyPressed(key_binding.GetKey2()) )
170 if ( key1_match && key2_match )
175 GetGame().GameScript.CallFunction(m, key_binding.GetCallbackFunction(), NULL, 0);
185 void OnKeyRelease(
int key)
192 void OnMouseButtonPress(
int button)
195 if (button_info == NULL)
return;
207 void OnMouseButtonRelease(
int button)
210 if (button_info == NULL)
return;
211 int time_curr =
GetGame().GetTime();
212 int time_last_press = button_info.GetTimeLastPress();
213 int time_last_release = button_info.GetTimeLastRelease();
214 int time_delta_press = time_curr - time_last_press;
215 int time_delta_relase = time_curr - time_last_release;
217 if ( time_delta_relase < DOUBLE_CLICK_TIME )
223 else if ( time_delta_press < CLICK_TIME )
234 button_info.Release();
242 for (
int i = 0; i < m_MouseButtons.Count(); ++i )
246 if ( info.IsButtonDown() )
248 int time_curr =
GetGame().GetTime();
249 int time_hold = info.GetTimeLastPress() + HOLD_CLICK_TIME_MIN;
251 if ( time_hold < time_curr )
266 return m_KeyBindings;
274 return m_MouseBindings;
277 protected const int CLICK_TIME = 200;
278 protected const int DOUBLE_CLICK_TIME = 300;
279 protected const int HOLD_CLICK_TIME_MIN = 300;
288 protected void RegisterKeyBind(
int ui_id,
int key_code1,
int key_code2,
string plugin_name,
string fnc_name,
string info_shortcut,
string info_description )
290 m_KeyBindings.Insert(
new KeyBinding(ui_id, key_code1, key_code2, plugin_name, fnc_name, info_shortcut, info_description) );
296 protected void RegisterMouseBind(
int ui_id,
int mouse_button,
int mouse_event,
string plugin_name,
string fnc_name,
string info_shortcut,
string info_description )
298 m_MouseBindings.Insert(
new MouseBinding(ui_id, mouse_button, mouse_event, plugin_name, fnc_name, info_shortcut, info_description) );
304 protected bool IsCurrentUIPageValid(
int ui_page_request )
308 if (
GetGame().GetUIManager().GetMenu() )
310 ui_page_current =
GetGame().GetUIManager().GetMenu().GetID();
313 if ( ui_page_current <
MENU_ANY || !CheckMask( ui_page_request, ui_page_current ) )
315 if ( CheckMask( ui_page_request,
MENU_NONE ) || !CheckMask( ui_page_request,
MENU_ANY ) )
324 bool CheckMask(
int source_mask,
int target_mask )
326 if ( ( source_mask & target_mask ) == target_mask )
337 protected void OnMouse(
int event_id,
int button )
339 for (
int i = 0; i < m_MouseBindings.Count(); ++i )
343 if ( mouse_binding.GetButtonID() == button && mouse_binding.GetMouseEvent() == event_id )
345 if ( IsCurrentUIPageValid( mouse_binding.GetUIMenuID() ) )
348 GetGame().GameScript.CallFunction(m, mouse_binding.GetCallbackFunction(), NULL, 0);
359 for (
int i = 0; i < m_MouseButtons.Count(); ++i )
363 if ( info.GetButtonID() == button )
374 protected bool IsKeyPressed(
int key)