Skip to content

Commit

Permalink
Merge pull request #91 from gruppe-adler/direct-connect-refactor
Browse files Browse the repository at this point in the history
directConnect right-click feature
  • Loading branch information
McDiod authored Oct 2, 2018
2 parents 5183847 + 4f7eb42 commit 5de7ada
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 103 deletions.
1 change: 1 addition & 0 deletions addons/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ https://github.com/gruppe-adler/grad_connectButtonPort
#### Maintainer(s)

* McDiod
* DerZade
6 changes: 4 additions & 2 deletions addons/ui/cfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
class CfgFunctions {
class grad_ui {
class ADDON {
class directConnect {
file = "x\grad\addons\ui\functions\directConnect";
file = QPATHTOF(functions\directConnect);
class connectToServer {};
class onButtonConnect_rightClick {};
class onButtonConnect {};
class onButtonPasswordOK {};
class onButtonPortOK {};
class onLoadButtonConnect {};
class onLoadRscDisplayDirectConnectPassword {};
};
Expand Down
3 changes: 2 additions & 1 deletion addons/ui/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class CfgPatches {
weapons[] = {};
VERSION_CONFIG;
authors[] = {
"McDiod"
"McDiod",
"DerZade"
};
};
};
Expand Down
209 changes: 164 additions & 45 deletions addons/ui/dialog/directConnect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,32 @@ class RscPictureKeepAspectAllowPixelSplit;

class RscDisplayMain {
class Controls {
class grad_directConnectLogo: RscPictureKeepAspectAllowPixelSplit {
text = "\x\grad\addons\ui\dialog\logo_128.paa";
class GVAR(directConnectLogo): RscPictureKeepAspectAllowPixelSplit {
text = QPATHTOF(dialog\logo_128.paa);

x = GRAD_DIRECTCONNECT_LOGOX;
x = DIRECTCONNECT_LOGOX;
y = "safezoneY + 2.15 * (pixelH * pixelGrid * 2)";
w = "2.00 * (pixelH * pixelGrid * 2)";
h = "1.70 * (pixelH * pixelGrid * 2)";
};

class grad_directConnectButton: RscButtonMenu {
class GVAR(directConnectButton): RscButtonMenu {
idc = 62300;
colorBackground[]={0,0,0,0};
colorBackground2[]={1,1,1,1};
style="0x02 + 0xC0";
size="1.25 * (pixelH * pixelGrid * 2)";

text = "ERROR SETTING TEXT";
onLoad = "_this call compile preprocessFileLineNumbers '\x\grad\addons\ui\functions\directConnect\fn_onLoadButtonConnect.sqf'";
onLoad = QUOTE(_this call (uiNamespace getVariable QQFUNC(onLoadButtonConnect)));

x = GRAD_DIRECTCONNECT_X;
x = DIRECTCONNECT_X;
y = "safezoneY + 2 * (pixelH * pixelGrid * 2)";
w = "9 * (pixelW * pixelGrid * 2)";
h = "2 * (pixelH * pixelGrid * 2)";

action = "call compile preprocessFileLineNumbers '\x\grad\addons\ui\functions\directConnect\fn_onButtonConnect.sqf'";
action = QUOTE(call (uiNamespace getVariable QQFUNC(onButtonConnect)));
onMouseButtonClick = QUOTE(_this call (uiNamespace getVariable QQFUNC(onButtonConnect_rightClick)));

class Attributes {
align="center";
Expand All @@ -56,11 +57,11 @@ class RscDisplayMain {
};
};

class grad_RscDisplayDirectConnectPassword {
class GVAR(RscDisplayDirectConnectPassword) {
idd = -1;
movingEnable=0;
enableDisplay=1;
onLoad = "_this call (uiNamespace getVariable 'grad_ui_fnc_onLoadRscDisplayDirectConnectPassword')";
onLoad = QUOTE(_this call (uiNamespace getVariable QQFUNC(onLoadRscDisplayDirectConnectPassword)));

class ControlsBackground {
class Vignette: RscVignette {
Expand Down Expand Up @@ -93,19 +94,19 @@ class grad_RscDisplayDirectConnectPassword {
"(profilenamespace getvariable ['GUI_BCG_RGB_A',0.8])"
};
idc=1080;
x = GRAD_DIRECTCONNECT_TOTALX;
y = GRAD_DIRECTCONNECT_TOTALY;
w = GRAD_DIRECTCONNECT_TOTALW;
h = GRAD_DIRECTCONNECT_ELEMENTH;
x = DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_TOTALY;
w = DIRECTCONNECT_TOTALW;
h = DIRECTCONNECT_ELEMENTH;
};
class MainBackground: RscText
{
colorBackground[]={0,0,0,0.69999999};
idc=1082;
x= GRAD_DIRECTCONNECT_TOTALX;
y = GRAD_DIRECTCONNECT_MAINY;
w = GRAD_DIRECTCONNECT_TOTALW;
h = GRAD_DIRECTCONNECT_MAINH;
x= DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_MAINY;
w = DIRECTCONNECT_TOTALW;
h = DIRECTCONNECT_MAINH;
};
};

Expand All @@ -114,61 +115,179 @@ class grad_RscDisplayDirectConnectPassword {
colorBackground[] = {0,0,0,0};
style = 0;
idc = 1000;
text="$STR_GRAD_UI_DIRECTCONNECTPASSWORDWINDOWTITLE";
text= CSTRING(DIRECTCONNECTPASSWORDWINDOWTITLE);

x = GRAD_DIRECTCONNECT_TOTALX;
y = GRAD_DIRECTCONNECT_TOTALY;
w = GRAD_DIRECTCONNECT_TOTALW;
h = GRAD_DIRECTCONNECT_ELEMENTH;
x = DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_TOTALY;
w = DIRECTCONNECT_TOTALW;
h = DIRECTCONNECT_ELEMENTH;
};

class Text: RscText {
idc = GRAD_DIRECTCONNECT_IDC_PASSWORDTEXT;
idc = DIRECTCONNECT_IDC_PASSWORDTEXT;
text = "";
x = GRAD_DIRECTCONNECT_CONTENTX;
y = GRAD_DIRECTCONNECT_MAINY + GRAD_DIRECTCONNECT_PADDINGY;
w = GRAD_DIRECTCONNECT_CONTENTW;
h = GRAD_DIRECTCONNECT_TEXTBOXH;
x = DIRECTCONNECT_CONTENTX;
y = DIRECTCONNECT_MAINY + DIRECTCONNECT_PADDINGY;
w = DIRECTCONNECT_CONTENTW;
h = DIRECTCONNECT_TEXTBOXH;
colorBackground[]={0,0,0,0};
};

class PasswordText: RscText {
idc = -1;
text = "PASSWORD";
x = GRAD_DIRECTCONNECT_CONTENTX;
y = GRAD_DIRECTCONNECT_MAINY + GRAD_DIRECTCONNECT_PADDINGY + GRAD_DIRECTCONNECT_TEXTBOXH + GRAD_DIRECTCONNECT_PADDINGY;
w = GRAD_DIRECTCONNECT_XSCALE * 5;
h = GRAD_DIRECTCONNECT_ELEMENTH;
x = DIRECTCONNECT_CONTENTX;
y = DIRECTCONNECT_MAINY + DIRECTCONNECT_PADDINGY + DIRECTCONNECT_TEXTBOXH + DIRECTCONNECT_PADDINGY;
w = DIRECTCONNECT_XSCALE * 5;
h = DIRECTCONNECT_ELEMENTH;
colorBackground[] = {0,0,0,0};
};

class PasswordBox: RscEdit {
idc = GRAD_DIRECTCONNECT_IDC_PASSWORD;
idc = DIRECTCONNECT_IDC_PASSWORD;

x = GRAD_DIRECTCONNECT_CONTENTX + GRAD_DIRECTCONNECT_XSCALE * 5.5;
y = GRAD_DIRECTCONNECT_MAINY + GRAD_DIRECTCONNECT_PADDINGY + GRAD_DIRECTCONNECT_TEXTBOXH + GRAD_DIRECTCONNECT_PADDINGY;
w = GRAD_DIRECTCONNECT_CONTENTW - GRAD_DIRECTCONNECT_XSCALE * 5.5;
h = GRAD_DIRECTCONNECT_ELEMENTH;
x = DIRECTCONNECT_CONTENTX + DIRECTCONNECT_XSCALE * 5.5;
y = DIRECTCONNECT_MAINY + DIRECTCONNECT_PADDINGY + DIRECTCONNECT_TEXTBOXH + DIRECTCONNECT_PADDINGY;
w = DIRECTCONNECT_CONTENTW - DIRECTCONNECT_XSCALE * 5.5;
h = DIRECTCONNECT_ELEMENTH;
};

class ButtonCancel: RscButtonMenuCancel {
x = GRAD_DIRECTCONNECT_TOTALX;
y = GRAD_DIRECTCONNECT_BUTTONY;
w = GRAD_DIRECTCONNECT_BUTTONW;
h = GRAD_DIRECTCONNECT_ELEMENTH;
x = DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_BUTTONY;
w = DIRECTCONNECT_BUTTONW;
h = DIRECTCONNECT_ELEMENTH;
};

class ButtonOK: RscButtonMenu {
x = GRAD_DIRECTCONNECT_BUTTONOKX;
y = GRAD_DIRECTCONNECT_BUTTONY;
w = GRAD_DIRECTCONNECT_BUTTONW;
h = GRAD_DIRECTCONNECT_ELEMENTH;
x = DIRECTCONNECT_BUTTONOKX;
y = DIRECTCONNECT_BUTTONY;
w = DIRECTCONNECT_BUTTONW;
h = DIRECTCONNECT_ELEMENTH;

text = "OK";
style = 16;
shortcuts[] = {28,156};

onButtonClick = "_this call (uiNamespace getVariable 'grad_ui_fnc_onButtonPasswordOK')";
onButtonClick = QUOTE(_this call (uiNamespace getVariable QQFUNC(onButtonPasswordOK)));
};
};
};


class GVAR(RscDisplayDirectConnectPort) {
idd = -1;
movingEnable=0;
enableDisplay=1;
//onLoad = QUOTE(_this call (uiNamespace getVariable QQFUNC(onLoadRscDisplayDirectConnectPassword)));

class ControlsBackground {
class Vignette: RscVignette {
idc=114998;
};

class TileGroup: RscControlsGroupNoScrollbars {
idc=115099;
x="safezoneXAbs";
y="safezoneY";
w="safezoneWAbs";
h="safezoneH";

class Controls {
class Background: RscText {
idc=114999;
x=0;
y=0;
w="safezoneWAbs";
h="safezoneH";
colorBackground[]={0,0,0,0.5};
};
};
};
class RscTitleBackground: RscText {
colorBackground[]= {
"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.13])",
"(profilenamespace getvariable ['GUI_BCG_RGB_G',0.54])",
"(profilenamespace getvariable ['GUI_BCG_RGB_B',0.21])",
"(profilenamespace getvariable ['GUI_BCG_RGB_A',0.8])"
};
idc=1080;
x = DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_TOTALY;
w = DIRECTCONNECT_TOTALW;
h = DIRECTCONNECT_ELEMENTH;
};
class MainBackground: RscText
{
colorBackground[]={0,0,0,0.69999999};
idc=1082;
x= DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_MAINY;
w = DIRECTCONNECT_TOTALW;
h = DIRECTCONNECT_MAINH;
};
};

class Controls {
class Title: RscTitle {
colorBackground[] = {0,0,0,0};
style = 0;
idc = 1000;
text= CSTRING(DIRECTCONNECTPASSWORDWINDOWTITLE);

x = DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_TOTALY;
w = DIRECTCONNECT_TOTALW;
h = DIRECTCONNECT_ELEMENTH;
};

class Text: RscText {
idc = DIRECTCONNECT_IDC_PASSWORDTEXT;
text = CSTRING(DIRECTCONNECTPORTTEXT);
x = DIRECTCONNECT_CONTENTX;
y = DIRECTCONNECT_MAINY + DIRECTCONNECT_PADDINGY;
w = DIRECTCONNECT_CONTENTW;
h = DIRECTCONNECT_TEXTBOXH;
colorBackground[]={0,0,0,0};
};

class PortText: RscText {
idc = -1;
text = "PORT";
x = DIRECTCONNECT_CONTENTX;
y = DIRECTCONNECT_MAINY + DIRECTCONNECT_PADDINGY + DIRECTCONNECT_TEXTBOXH + DIRECTCONNECT_PADDINGY;
w = DIRECTCONNECT_XSCALE * 5;
h = DIRECTCONNECT_ELEMENTH;
colorBackground[] = {0,0,0,0};
};

class PortBox: RscEdit {
idc = DIRECTCONNECT_IDC_PASSWORD;
text="2302";
x = DIRECTCONNECT_CONTENTX + DIRECTCONNECT_XSCALE * 5.5;
y = DIRECTCONNECT_MAINY + DIRECTCONNECT_PADDINGY + DIRECTCONNECT_TEXTBOXH + DIRECTCONNECT_PADDINGY;
w = DIRECTCONNECT_CONTENTW - DIRECTCONNECT_XSCALE * 5.5;
h = DIRECTCONNECT_ELEMENTH;
};

class ButtonCancel: RscButtonMenuCancel {
x = DIRECTCONNECT_TOTALX;
y = DIRECTCONNECT_BUTTONY;
w = DIRECTCONNECT_BUTTONW;
h = DIRECTCONNECT_ELEMENTH;
};

class ButtonOK: RscButtonMenu {
x = DIRECTCONNECT_BUTTONOKX;
y = DIRECTCONNECT_BUTTONY;
w = DIRECTCONNECT_BUTTONW;
h = DIRECTCONNECT_ELEMENTH;

text = "OK";
style = 16;
shortcuts[] = {28,156};

onButtonClick = QUOTE(_this call (uiNamespace getVariable QQFUNC(onButtonPortOK)));
};
};
};
44 changes: 22 additions & 22 deletions addons/ui/dialog/directConnectDefines.hpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#define GRAD_DIRECTCONNECT_IDC_PASSWORDTEXT 1008
#define GRAD_DIRECTCONNECT_IDC_PASSWORD 1009
#define DIRECTCONNECT_IDC_PASSWORDTEXT 1008
#define DIRECTCONNECT_IDC_PASSWORD 1009

// =============================================================================

#define CENTER(PARENT_SIZE, CHILD_SIZE) ((PARENT_SIZE / 2) - (CHILD_SIZE / 2))

#define GRAD_DIRECTCONNECT_XSCALE (((safezoneW / safezoneH) min 1.2) / 40)
#define GRAD_DIRECTCONNECT_YSCALE ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)
#define DIRECTCONNECT_XSCALE (((safezoneW / safezoneH) min 1.2) / 40)
#define DIRECTCONNECT_YSCALE ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)

#define GRAD_DIRECTCONNECT_TOTALW (30 * GRAD_DIRECTCONNECT_XSCALE)
#define GRAD_DIRECTCONNECT_TOTALH (10 * GRAD_DIRECTCONNECT_YSCALE)
#define GRAD_DIRECTCONNECT_SPACERY (0.12 * GRAD_DIRECTCONNECT_YSCALE)
#define GRAD_DIRECTCONNECT_ELEMENTH (1 * GRAD_DIRECTCONNECT_YSCALE)
#define GRAD_DIRECTCONNECT_PADDINGY (1 * GRAD_DIRECTCONNECT_YSCALE)
#define GRAD_DIRECTCONNECT_PADDINGX (1 * GRAD_DIRECTCONNECT_XSCALE)
#define GRAD_DIRECTCONNECT_TEXTBOXH (2* GRAD_DIRECTCONNECT_XSCALE)
#define GRAD_DIRECTCONNECT_BUTTONW (6.25 * GRAD_DIRECTCONNECT_XSCALE)
#define DIRECTCONNECT_TOTALW (30 * DIRECTCONNECT_XSCALE)
#define DIRECTCONNECT_TOTALH (10 * DIRECTCONNECT_YSCALE)
#define DIRECTCONNECT_SPACERY (0.12 * DIRECTCONNECT_YSCALE)
#define DIRECTCONNECT_ELEMENTH (1 * DIRECTCONNECT_YSCALE)
#define DIRECTCONNECT_PADDINGY (1 * DIRECTCONNECT_YSCALE)
#define DIRECTCONNECT_PADDINGX (1 * DIRECTCONNECT_XSCALE)
#define DIRECTCONNECT_TEXTBOXH (2* DIRECTCONNECT_XSCALE)
#define DIRECTCONNECT_BUTTONW (6.25 * DIRECTCONNECT_XSCALE)

#define GRAD_DIRECTCONNECT_MAINH (GRAD_DIRECTCONNECT_TOTALH - 2*GRAD_DIRECTCONNECT_ELEMENTH - 2*GRAD_DIRECTCONNECT_SPACERY)
#define DIRECTCONNECT_MAINH (DIRECTCONNECT_TOTALH - 2*DIRECTCONNECT_ELEMENTH - 2*DIRECTCONNECT_SPACERY)

#define GRAD_DIRECTCONNECT_TOTALX (CENTER(1,GRAD_DIRECTCONNECT_TOTALW))
#define GRAD_DIRECTCONNECT_TOTALY (CENTER(1,GRAD_DIRECTCONNECT_TOTALH))
#define GRAD_DIRECTCONNECT_MAINY (GRAD_DIRECTCONNECT_TOTALY + GRAD_DIRECTCONNECT_ELEMENTH + GRAD_DIRECTCONNECT_SPACERY)
#define DIRECTCONNECT_TOTALX (CENTER(1,DIRECTCONNECT_TOTALW))
#define DIRECTCONNECT_TOTALY (CENTER(1,DIRECTCONNECT_TOTALH))
#define DIRECTCONNECT_MAINY (DIRECTCONNECT_TOTALY + DIRECTCONNECT_ELEMENTH + DIRECTCONNECT_SPACERY)

#define GRAD_DIRECTCONNECT_CONTENTW (GRAD_DIRECTCONNECT_TOTALW - 2*GRAD_DIRECTCONNECT_PADDINGX)
#define GRAD_DIRECTCONNECT_CONTENTX (GRAD_DIRECTCONNECT_TOTALX + GRAD_DIRECTCONNECT_PADDINGX)
#define GRAD_DIRECTCONNECT_BUTTONOKX (GRAD_DIRECTCONNECT_TOTALX + GRAD_DIRECTCONNECT_TOTALW - GRAD_DIRECTCONNECT_BUTTONW)
#define GRAD_DIRECTCONNECT_BUTTONY (GRAD_DIRECTCONNECT_MAINY + GRAD_DIRECTCONNECT_MAINH + GRAD_DIRECTCONNECT_SPACERY)
#define DIRECTCONNECT_CONTENTW (DIRECTCONNECT_TOTALW - 2*DIRECTCONNECT_PADDINGX)
#define DIRECTCONNECT_CONTENTX (DIRECTCONNECT_TOTALX + DIRECTCONNECT_PADDINGX)
#define DIRECTCONNECT_BUTTONOKX (DIRECTCONNECT_TOTALX + DIRECTCONNECT_TOTALW - DIRECTCONNECT_BUTTONW)
#define DIRECTCONNECT_BUTTONY (DIRECTCONNECT_MAINY + DIRECTCONNECT_MAINH + DIRECTCONNECT_SPACERY)

#define GRAD_DIRECTCONNECT_X (safeZoneX + 2 * GRAD_DIRECTCONNECT_XSCALE)
#define GRAD_DIRECTCONNECT_LOGOX (GRAD_DIRECTCONNECT_X - (1.8 * (pixelH * pixelGrid * 2)))
#define DIRECTCONNECT_X (safeZoneX + 2 * DIRECTCONNECT_XSCALE)
#define DIRECTCONNECT_LOGOX (DIRECTCONNECT_X - (1.8 * (pixelH * pixelGrid * 2)))
Loading

0 comments on commit 5de7ada

Please sign in to comment.