Skip to content

Commit

Permalink
Added some stuff for dialog create function
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepPork committed Jun 22, 2019
1 parent ffe906d commit 82a569f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 4 deletions.
2 changes: 1 addition & 1 deletion addons/dialog/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PREP(empty);
PREP(create);
77 changes: 77 additions & 0 deletions addons/dialog/functions/fnc_create.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Author: CreepPork
* Creats a dynamic dialog with custom controls.
*
* Arguments:
* 0: Title <STRING>
* 1: Controls <ARRAY>
* 2: On Confirm <CODE>
* 3: On Cancel <CODE> (default: {})
* 4: Arguments <ANY> (default: [])
*
* Return Value:
* Dialog created <BOOL>
*
* Example:
* ["My Dialog", [["SLIDER", "Awesomeness", 0.5]], {diag_log _this}] call achilles_dialog_fnc_create
*
* Public: Yes
*/

#include "script_component.hpp"

if (canSuspend) exitWith {
[FUNC(create), _this] call CBA_fnc_directCall;
};

if (! hasInterface) exitWith {};

params [
["_title", "", [""]],
["_content", [], [[]]],
["_onConfirm", {}, [{}]],
["_onCancel", {}, [{}]],
["_arguments", []]
];

{
_x params [
["_controlType", "", [""]],
["_name", "", ["", [""]]],
["_values", []]
];

_name params [
["_displayName", "", [""]],
["_tooltip", "", [""]]
];

// Localize strings if they can be localized
if (isLocalized _displayName) then {
_displayName = localize _displayName;
};

if (isLocalized _tooltip) then {
_tooltip = localize _tooltip;
};

// If secondary control type is given then split it into two strings, e.g. MYTYPE:YESNO
(toUpper _controlType splitString ":") params [
["_primaryControl", "", [""]],
["_secondaryControl", "", [""]]
];

private "_defaultValue";
private _dialogControl = "";
private _rowSettings = [];

switch (_primaryControl) do {
case "CHECKBOX": {
_defaultValue = _values param [0, false, [false]];
_dialogControl = QGVAR(row_checkbox);
};
default {
ERROR_MSG_1("%1 is not a valid control type.",_primaryControl);
};
};
} forEach _content;
3 changes: 0 additions & 3 deletions addons/dialog/functions/fnc_empty.sqf

This file was deleted.

0 comments on commit 82a569f

Please sign in to comment.