Skip to content

Commit

Permalink
Merge pull request CBATeam#629 from CBATeam/cleanup-help
Browse files Browse the repository at this point in the history
fix and simplify the help component ui
  • Loading branch information
Killswitch00 authored Apr 8, 2017
2 parents dcf6cf5 + aef0104 commit 542490d
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 185 deletions.
15 changes: 0 additions & 15 deletions addons/help/CfgEventhandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,3 @@ class Extended_PostInit_EventHandlers {
clientInit = QUOTE(call COMPILE_FILE(XEH_postClientInit));
};
};

class Extended_DisplayLoad_EventHandlers {
class RscDisplayMain {
CBA_helpVersion = QUOTE(_this call (uiNamespace getVariable 'FUNC(setVersionLine)'));
CBA_helpCredits = QUOTE(_this call (uiNamespace getVariable 'FUNC(setCreditsLine)'));
};
class RscDisplayInterrupt {
CBA_helpVersion = QUOTE(_this call (uiNamespace getVariable 'FUNC(setVersionLine)'));
CBA_helpCredits = QUOTE(_this call (uiNamespace getVariable 'FUNC(setCreditsLine)'));
};
class RscDisplayMPInterrupt {
CBA_helpVersion = QUOTE(_this call (uiNamespace getVariable 'FUNC(setVersionLine)'));
CBA_helpCredits = QUOTE(_this call (uiNamespace getVariable 'FUNC(setCreditsLine)'));
};
};
76 changes: 0 additions & 76 deletions addons/help/CfgRscStd.hpp

This file was deleted.

3 changes: 2 additions & 1 deletion addons/help/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ class CfgPatches {
};

#include "CfgEventhandlers.hpp"
#include "CfgRscStd.hpp"

#include "gui.hpp"
29 changes: 5 additions & 24 deletions addons/help/fnc_setCreditsLine.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,17 @@ Description:
version and URL in the main menu and ingame in the pause menu.
Parameters:
0: _display - Either Main menu or Pause menu display or a control of these displays. <DISPLAY, CONTROL>
0: _control - Credits line control <CONTROL>
Returns:
None
---------------------------------------------------------------------------- */
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

disableSerialization;
params ["_control"];

// get display
params [["_display", displayNull, [displayNull, controlNull]]];

if (_display isEqualType controlNull) then {
_display = ctrlParent _display;
};

private _ctrl = _display displayCtrl CBA_CREDITS_CONT_IDC;

if !(ctrlText _ctrl isEqualTo "") exitWith {};
if !(ctrlText _control isEqualTo "") exitWith {};

// get settings
{
Expand Down Expand Up @@ -57,19 +48,9 @@ if (!CBA_MonochromeCredits) then {
_name = format ["<t color='#99cccc'>%1</t>", _name];
};

// author(s) name
// author name
private _author = getText (_entry >> "author");

if (isArray (_entry >> "authors")) then {
private _authors = getArray (_entry >> "authors");

{
if (_x isEqualType "") then {
_author = format ["%1, %2", _author, _x];
};
} forEach _authors;
};

// version if any
private _version = "";

Expand All @@ -78,4 +59,4 @@ if (isText (_entry >> "version")) then {
};

// add single line
_ctrl ctrlSetStructuredText parseText format ["%1%2 by %3 %4", _name, _version, _author];
_control ctrlSetStructuredText parseText format ["%1%2 by %3", _name, _version, _author];
55 changes: 17 additions & 38 deletions addons/help/fnc_setVersionLine.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Function: CBA_help_fnc_setVersionLine
Description:
Displays all CfgPatches with a "versionDesc" entry in the main menu.
Mods are cycled automatically every 3 seconds or can be browsed using LMB and RMB.
Mods are cycled automatically every 4 seconds or can be browsed using LMB and RMB.
Double clicking executes the script in "versionAct".
Parameters:
0: _display - Main menu display or a control of the display. <DISPLAY, CONTROL>
0: _control - Either version line or button control <CONTROL>
1: _key - 0: LMB - next mod, 1: RMB - previous mod <NUMBER> (optional, default: 0)
Returns:
Expand All @@ -17,72 +17,51 @@ Returns:
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

disableSerialization;
params ["_control", ["_key", 0]];

// get display
params [["_display", displayNull, [displayNull, controlNull]], ["_key", 0]];
private _display = ctrlParent _control;

if (_display isEqualType controlNull) then {
_display = ctrlParent _display;
};

private _ctrl = _display displayCtrl CBA_CREDITS_VER_IDC;
private _ctrlBtn = _display displayCtrl CBA_CREDITS_VER_BTN_IDC;

if (isNull _ctrl) exitWith {};
private _ctrlText = _display displayCtrl IDC_VERSION_TEXT;
private _ctrlButton = _display displayCtrl IDC_VERSION_BUTTON;

// create addon list
if (isNil {uiNamespace getVariable QGVAR(VerList)}) then {
private _verList = [];
uiNamespace setVariable [QGVAR(VerList), _verList];

// align with BI version position
private _posX = __RIX(-21);
private _posY = __IY(23);
private _posW = __IW(8);
private _posH = __IH(1);

_ctrl ctrlSetPosition [_posX, _posY, _posW, _posH];
_ctrl ctrlCommit 0;

// button align
_ctrlBtn ctrlSetPosition [_posX, _posY, _posW, _posH];
_ctrlBtn ctrlCommit 0;

// gather version info
_config = configFile >> "CfgPatches";

{
private _entry = _x;

private _verLine = format ["%1 v%2", getText (_entry >> "versionDesc"), getText (_entry >> "version")];
private _verAct = getText (_entry >> "versionAct");

_verList pushBack [_verLine, _verAct];
} forEach ("isText (_x >> 'versionDesc')" configClasses _config);
} forEach ("isText (_x >> 'versionDesc')" configClasses (configFile >> "CfgPatches"));
};

// start loop that cycles through all addons
terminate (uiNamespace getVariable [QGVAR(VerScript), scriptNull]);

private _verScript = [_display] spawn { // will terminate when main menu mission exits
uiSleep 3;
QUOTE(_this call COMPILE_FILE(fnc_setVersionLine)) configClasses (configFile >> "CBA_DirectCall");
private _verScript = [_control] spawn { // will terminate when main menu mission exits
uiSleep 4;
isNil (uiNamespace getVariable QFUNC(setVersionLine)); // execute unscheduled
};

uiNamespace setVariable [QGVAR(VerScript), _verScript];

// start loop with mouse moving event on main menu. this is used, because loops can't be used at that point
if (isNull (uiNamespace getVariable [QGVAR(VerScriptFlag), displayNull])) then {
uiNamespace setVariable [QGVAR(VerScriptFlag), _display];
_display displayAddEventHandler ["mouseMoving", {

_display displayAddEventHandler ["MouseMoving", {
params ["_display"];

if (!scriptDone (uiNamespace getVariable [QGVAR(VerScript), scriptNull])) exitWith {};

private _verScript = [_display] spawn { // will terminate when main menu mission exits
uiSleep 3;
QUOTE(_this call COMPILE_FILE(fnc_setVersionLine)) configClasses (configFile >> "CBA_DirectCall");
private _verScript = [allControls _display select 0] spawn { // will terminate when main menu mission exits
uiSleep 4;
isNil (uiNamespace getVariable QFUNC(setVersionLine)); // execute unscheduled
};

uiNamespace setVariable [QGVAR(VerScript), _verScript];
Expand Down Expand Up @@ -118,5 +97,5 @@ uiNamespace setVariable [QGVAR(VerNext), _next];
// add single line
(_verList select _next) params ["_verLine", "_verAct"];

_ctrl ctrlSetText _verLine; // print version line
_ctrlBtn ctrlSetEventHandler ["MouseButtonDblClick", _verAct]; // set double-click action if any
_ctrlText ctrlSetText _verLine; // print version line
_ctrlButton ctrlSetEventHandler ["MouseButtonDblClick", _verAct]; // set double-click action if any
79 changes: 79 additions & 0 deletions addons/help/gui.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

class RscText;
class RscButton;

class RscStructuredText {
class Attributes;
};

class GVAR(credits_base): RscStructuredText {
onLoad = QUOTE(_this call (uiNamespace getVariable 'FUNC(setCreditsLine)'));
size = POS_H(0.8);
x = POS_X_CENTERED(7);
y = POS_Y(23.1);
w = POS_W(26);
h = POS_H(0.8);
shadow = 0;

class Attributes: Attributes {
font = "RobotoCondensedLight";
align = "center";
valign = "middle";
color = "#bdcc9c";
};
};

class RscStandardDisplay;
class RscDisplayMain: RscStandardDisplay {
class controls {
class GVAR(CreditsVersion): RscText {
onLoad = QUOTE(_this call (uiNamespace getVariable 'FUNC(setVersionLine)'));
idc = IDC_VERSION_TEXT;
font = "RobotoCondensedLight";
shadow = 0;
style = ST_RIGHT;
sizeEx = POS_H(0.8);
x = POS_X_RIGHT(12);
y = POS_Y(24.1);
w = POS_W(10);
h = POS_H(0.8);
};

class GVAR(CreditsVersionButton): RscButton {
onMouseButtonClick = QUOTE(_this call (uiNamespace getVariable 'FUNC(setVersionLine)'));
idc = IDC_VERSION_BUTTON;
colorText[] = {1,1,1,0};
colorDisabled[] = {1,1,1,0};
colorBackground[] = {0,0,0,0};
colorBackgroundDisabled[] = {0,0,0,0};
colorBackgroundActive[] = {0,0,0,0};
colorFocused[] = {0,0,0,0};
soundClick[] = {"",1,1};

x = POS_X_RIGHT(12);
y = POS_Y(24.1);
w = POS_W(10);
h = POS_H(0.8);
};

class GVAR(credits): GVAR(credits_base) {
size = POS_H_MAIN_MENU(1);
x = POS_X_MAIN_MENU(0);
y = POS_Y_MAIN_MENU(2);
w = POS_W_MAIN_MENU(0);
h = POS_H_MAIN_MENU(1);
};
};
};

class RscDisplayInterrupt: RscStandardDisplay {
class controls {
class GVAR(credits): GVAR(credits_base) {};
};
};

class RscDisplayMPInterrupt: RscStandardDisplay {
class controls {
class GVAR(credits): GVAR(credits_base) {};
};
};
22 changes: 18 additions & 4 deletions addons/help/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,22 @@

#include "\x\cba\addons\main\script_macros.hpp"

#include "script_dialog_defines.hpp"
#include "\a3\ui_f\hpp\defineCommonGrids.inc"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
#include "\a3\ui_f\hpp\defineResincl.inc"

#define CBA_CREDITS_CONT_IDC 2222710
#define CBA_CREDITS_VER_IDC 2222712
#define CBA_CREDITS_VER_BTN_IDC 2222713
#define POS_X(N) ((N) * GUI_GRID_W + GUI_GRID_X)
#define POS_Y(N) ((N) * GUI_GRID_H + GUI_GRID_Y)
#define POS_W(N) ((N) * GUI_GRID_W)
#define POS_H(N) ((N) * GUI_GRID_H)

#define POS_X_CENTERED(N) ((N) * GUI_GRID_W + GUI_GRID_CENTER_X)
#define POS_X_RIGHT(N) (safezoneW - 1 * (N) * GUI_GRID_W + GUI_GRID_X)

#define POS_X_MAIN_MENU(N) safezoneX
#define POS_Y_MAIN_MENU(N) (safezoneY + safezoneH - 1 * (N) * (pixelH * pixelGrid * 2))
#define POS_W_MAIN_MENU(N) safezoneW
#define POS_H_MAIN_MENU(N) ((N) * (pixelH * pixelGrid * 2))

#define IDC_VERSION_TEXT 222712
#define IDC_VERSION_BUTTON 222713
Loading

0 comments on commit 542490d

Please sign in to comment.