forked from CntoDev/cnto-additions-old
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ares_extras: add 'curatorMsg' and 'confirm' functions
Signed-off-by: freghar <freghar@dummy.tld>
- Loading branch information
Showing
3 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* wait for the curator to confirm something (Return = yes, Escape = no) | ||
* | ||
* your code will run unscheduled and will receive no argument (or your | ||
* custom one) | ||
* | ||
* this function uses global vars, but is recursion-safe | ||
* | ||
* [ | ||
* "Select source units", | ||
* { | ||
* private _units = curatorSelected select 0; | ||
* if (count _units == 0) exitWith { | ||
* ["No units selected.", "cancel"] | ||
* call a3aa_ares_extras_fnc_curatorMsg; | ||
* }; | ||
* [ | ||
* "Select target groups", | ||
* [_units, { | ||
* private _units = _this; | ||
* private _groups = curatorSelected select 1; | ||
* if (count _groups > 0) then { | ||
* systemChat format ["src units: %1", _units]; | ||
* systemChat format ["tgt groups: %1", _groups]; | ||
* }; | ||
* }] | ||
* ] call a3aa_ares_extras_fnc_confirm; | ||
* } | ||
* ] call a3aa_ares_extras_fnc_confirm; | ||
*/ | ||
|
||
#include "\A3\ui_f_curator\ui\defineResinclDesign.inc" | ||
#include "\A3\ui_f\hpp\defineDIKCodes.inc" | ||
|
||
params ["_msg", "_code"]; | ||
|
||
if (_code isEqualType []) then { | ||
a3aa_ares_extras_confim_codearg = _code select 0; | ||
a3aa_ares_extras_confim_code = _code select 1; | ||
} else { | ||
a3aa_ares_extras_confim_code = _code; | ||
}; | ||
|
||
disableSerialization; | ||
private _display = findDisplay IDD_RSCDISPLAYCURATOR; | ||
if (isNull _display) exitWith {}; | ||
|
||
/* another confirmation in progress */ | ||
if (!isNil "a3aa_ares_extras_confim_EH") then { | ||
_display displayRemoveEventHandler ["KeyDown", a3aa_ares_extras_confim_EH]; | ||
}; | ||
|
||
/* no _thisEventHandler for displayAddEventHandler */ | ||
a3aa_ares_extras_confim_EH = _display displayAddEventHandler ["KeyDown", | ||
{ | ||
params ["_display", "_key"]; | ||
switch (_key) do { | ||
case DIK_ESCAPE: { | ||
_display displayRemoveEventHandler | ||
["KeyDown", a3aa_ares_extras_confim_EH]; | ||
a3aa_ares_extras_confim_EH = nil; | ||
["Cancelled.", "cancel"] call a3aa_ares_extras_fnc_curatorMsg; | ||
true; | ||
}; | ||
case DIK_NUMPADENTER; | ||
case DIK_RETURN: { | ||
_display displayRemoveEventHandler | ||
["KeyDown", a3aa_ares_extras_confim_EH]; | ||
a3aa_ares_extras_confim_EH = nil; | ||
["Confirmed.", "normal"] call a3aa_ares_extras_fnc_curatorMsg; | ||
if (isNil "a3aa_ares_extras_confim_codearg") then { | ||
call a3aa_ares_extras_confim_code; | ||
} else { | ||
a3aa_ares_extras_confim_codearg | ||
call a3aa_ares_extras_confim_code; | ||
}; | ||
true; | ||
}; | ||
default { | ||
false; | ||
}; | ||
}; | ||
}]; | ||
|
||
if (!(_msg isEqualTo "")) then { | ||
[_msg, "action"] call a3aa_ares_extras_fnc_curatorMsg; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* custom message in the top bar, like BIS_fnc_showCuratorFeedbackMessage | ||
* but with customizable sound | ||
*/ | ||
|
||
#include "\A3\ui_f_curator\ui\defineResinclDesign.inc" | ||
|
||
/* sound: normal, action, cancel, ... or classname .. or "" for silent */ | ||
params ["_msg", ["_sound", "normal"]]; | ||
|
||
disableSerialization; | ||
private _display = findDisplay IDD_RSCDISPLAYCURATOR; | ||
private _ctrl = _display displayCtrl IDC_RSCDISPLAYCURATOR_FEEDBACKMESSAGE; | ||
if (isNull _ctrl) exitWith {}; | ||
|
||
switch (_sound) do { | ||
case "normal": { playSound "RscDisplayCurator_error01" }; | ||
case "action": { playSound "FD_Finish_F" }; | ||
case "cancel": { playSound "FD_Start_F" }; | ||
case "": {}; | ||
default { playSound _sound }; | ||
}; | ||
|
||
/* | ||
* replicate messaging logic from BIS_fnc_showCuratorFeedbackMessage, | ||
* including the msg fade - use BIS identifier for the script, so that | ||
* any BIS_fnc_showCuratorFeedbackMessage call can terminate it, making | ||
* this function fully BIS_fnc_showCuratorFeedbackMessage compatible | ||
*/ | ||
|
||
_ctrl ctrlSetText _msg; | ||
_ctrl ctrlSetFade 1; | ||
_ctrl ctrlCommit 0; | ||
_ctrl ctrlSetFade 0; | ||
_ctrl ctrlCommit 0.1; | ||
|
||
if (!isNil "BIS_fnc_moduleCurator_feedbackMessage") then { | ||
terminate BIS_fnc_moduleCurator_feedbackMessage; | ||
}; | ||
BIS_fnc_moduleCurator_feedbackMessage = _ctrl spawn { | ||
disableSerialization; | ||
uiSleep 3; | ||
_this ctrlSetFade 1; | ||
_this ctrlCommit 0.5; | ||
}; |