From da2a03501be504f1c4f1652f234500b198f7e317 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 7 Sep 2018 09:18:26 +0200 Subject: [PATCH 1/6] make serverbrowser remember last used password for every server --- addons/ui/RscDisplayPassword.hpp | 10 +++++++ addons/ui/XEH_preStart.sqf | 1 + addons/ui/config.cpp | 1 + addons/ui/fnc_initDisplayPassword.sqf | 39 +++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 addons/ui/RscDisplayPassword.hpp create mode 100644 addons/ui/fnc_initDisplayPassword.sqf diff --git a/addons/ui/RscDisplayPassword.hpp b/addons/ui/RscDisplayPassword.hpp new file mode 100644 index 000000000..b54f9aef9 --- /dev/null +++ b/addons/ui/RscDisplayPassword.hpp @@ -0,0 +1,10 @@ +class RscStandardDisplay; +class RscDisplayPassword: RscStandardDisplay { + class controlsbackground { + class GVAR(initScript): RscText { + onLoad = QUOTE(ctrlParent (_this select 0) call (uiNamespace getVariable 'FUNC(initDisplayPassword)')); + w = 0; + h = 0; + }; + }; +}; diff --git a/addons/ui/XEH_preStart.sqf b/addons/ui/XEH_preStart.sqf index 1c0dd3b78..e4e7fb526 100644 --- a/addons/ui/XEH_preStart.sqf +++ b/addons/ui/XEH_preStart.sqf @@ -2,3 +2,4 @@ PREP(initDisplayInterrupt); PREP(initDisplayMultiplayerSetup); +PREP(initDisplayPassword); diff --git a/addons/ui/config.cpp b/addons/ui/config.cpp index 5e7aa1d0f..625b45cce 100644 --- a/addons/ui/config.cpp +++ b/addons/ui/config.cpp @@ -18,6 +18,7 @@ class CfgPatches { #include "RscTitles.hpp" #include "CfgUIGrids.hpp" #include "RscDisplayOptionsLayout.hpp" +#include "RscDisplayPassword.hpp" //----------------------------------------------------------------------------- // TODO: Delete these rsc/_flexiMenu_RscShortcutButton classes soon and transfer properties to menu classes, if any. diff --git a/addons/ui/fnc_initDisplayPassword.sqf b/addons/ui/fnc_initDisplayPassword.sqf new file mode 100644 index 000000000..0db2f4239 --- /dev/null +++ b/addons/ui/fnc_initDisplayPassword.sqf @@ -0,0 +1,39 @@ +#include "script_component.hpp" + +params ["_display"]; +private _ctrlConfirm = _display displayCtrl IDC_OK; +private _ctrlPassword = _display displayCtrl IDC_PASSWORD; +private _ctrlServerList = (uinamespace getVariable "RscDisplayMultiplayer") displayCtrl IDC_MULTI_SESSIONS; + +_ctrlConfirm ctrlAddEventHandler ["ButtonClick", { + params ["_ctrlConfirm"]; + private _display = ctrlParent _ctrlConfirm; + private _ctrlPassword = _display displayCtrl IDC_PASSWORD; + private _ctrlServerList = (uinamespace getVariable "RscDisplayMultiplayer") displayCtrl IDC_MULTI_SESSIONS; + + private _server = _ctrlServerList lbData lbCurSel _ctrlServerList; + private _password = ctrlText _ctrlPassword; + //diag_log ["write", _server, _password]; + + // store password in cache + private _passwordCache = profileNamespace getVariable [QGVAR(ServerPasswords), [[], []]]; + private _index = (_passwordCache#0) find _server; + if (_index isEqualTo -1) then { + _index = (_passwordCache#0) pushBack _server; + }; + (_passwordCache#1) set [_index, _password]; + profileNamespace setVariable [QGVAR(ServerPasswords), _passwordCache]; + saveProfileNamespace; +}]; + +private _server = _ctrlServerList lbData lbCurSel _ctrlServerList; + +// read password from cache +private _passwordCache = profileNamespace getVariable [QGVAR(ServerPasswords), [[], []]]; +private _index = (_passwordCache#0) find _server; +private _password = (_passwordCache#1) param [_index, ""]; +//diag_log ["read", _server, _password]; + +if (_password != "") then { + _ctrlPassword ctrlSetText _password; +}; From 6981c461c3fa299d078893489ac794d8cf51dc50 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 7 Sep 2018 09:40:06 +0200 Subject: [PATCH 2/6] Travis can't handle # --- addons/ui/fnc_initDisplayPassword.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/ui/fnc_initDisplayPassword.sqf b/addons/ui/fnc_initDisplayPassword.sqf index 0db2f4239..164ccff78 100644 --- a/addons/ui/fnc_initDisplayPassword.sqf +++ b/addons/ui/fnc_initDisplayPassword.sqf @@ -17,9 +17,9 @@ _ctrlConfirm ctrlAddEventHandler ["ButtonClick", { // store password in cache private _passwordCache = profileNamespace getVariable [QGVAR(ServerPasswords), [[], []]]; - private _index = (_passwordCache#0) find _server; + private _index = (_passwordCache select 0) find _server; if (_index isEqualTo -1) then { - _index = (_passwordCache#0) pushBack _server; + _index = (_passwordCache select 0) pushBack _server; }; (_passwordCache#1) set [_index, _password]; profileNamespace setVariable [QGVAR(ServerPasswords), _passwordCache]; @@ -30,8 +30,8 @@ private _server = _ctrlServerList lbData lbCurSel _ctrlServerList; // read password from cache private _passwordCache = profileNamespace getVariable [QGVAR(ServerPasswords), [[], []]]; -private _index = (_passwordCache#0) find _server; -private _password = (_passwordCache#1) param [_index, ""]; +private _index = (_passwordCache select 0) find _server; +private _password = (_passwordCache select 1) param [_index, ""]; //diag_log ["read", _server, _password]; if (_password != "") then { From 888f65fb43d6e3eea8b58a8e28c8230707fd6a23 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 7 Sep 2018 09:41:34 +0200 Subject: [PATCH 3/6] Travis can't handle # --- addons/ui/fnc_initDisplayPassword.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ui/fnc_initDisplayPassword.sqf b/addons/ui/fnc_initDisplayPassword.sqf index 164ccff78..522bf841e 100644 --- a/addons/ui/fnc_initDisplayPassword.sqf +++ b/addons/ui/fnc_initDisplayPassword.sqf @@ -21,7 +21,7 @@ _ctrlConfirm ctrlAddEventHandler ["ButtonClick", { if (_index isEqualTo -1) then { _index = (_passwordCache select 0) pushBack _server; }; - (_passwordCache#1) set [_index, _password]; + (_passwordCache select 1) set [_index, _password]; profileNamespace setVariable [QGVAR(ServerPasswords), _passwordCache]; saveProfileNamespace; }]; From 98ed8e337913e8d2bfd729ffc7e0ac434b4d7851 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 7 Sep 2018 17:45:12 +0200 Subject: [PATCH 4/6] use DisplayLoad --- addons/ui/CfgEventHandlers.hpp | 3 +++ addons/ui/RscDisplayPassword.hpp | 10 ---------- addons/ui/config.cpp | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 addons/ui/RscDisplayPassword.hpp diff --git a/addons/ui/CfgEventHandlers.hpp b/addons/ui/CfgEventHandlers.hpp index b85678ae8..7a80d1bc1 100644 --- a/addons/ui/CfgEventHandlers.hpp +++ b/addons/ui/CfgEventHandlers.hpp @@ -20,4 +20,7 @@ class Extended_DisplayLoad_EventHandlers { class RscDisplayMultiplayerSetup { ADDON = QUOTE(_this call (uiNamespace getVariable 'FUNC(initDisplayMultiplayerSetup)')); }; + class RscDisplayPassword { + ADDON = QUOTE(_this call (uiNamespace getVariable 'FUNC(initDisplayPassword)')); + }; }; diff --git a/addons/ui/RscDisplayPassword.hpp b/addons/ui/RscDisplayPassword.hpp deleted file mode 100644 index b54f9aef9..000000000 --- a/addons/ui/RscDisplayPassword.hpp +++ /dev/null @@ -1,10 +0,0 @@ -class RscStandardDisplay; -class RscDisplayPassword: RscStandardDisplay { - class controlsbackground { - class GVAR(initScript): RscText { - onLoad = QUOTE(ctrlParent (_this select 0) call (uiNamespace getVariable 'FUNC(initDisplayPassword)')); - w = 0; - h = 0; - }; - }; -}; diff --git a/addons/ui/config.cpp b/addons/ui/config.cpp index 625b45cce..5e7aa1d0f 100644 --- a/addons/ui/config.cpp +++ b/addons/ui/config.cpp @@ -18,7 +18,6 @@ class CfgPatches { #include "RscTitles.hpp" #include "CfgUIGrids.hpp" #include "RscDisplayOptionsLayout.hpp" -#include "RscDisplayPassword.hpp" //----------------------------------------------------------------------------- // TODO: Delete these rsc/_flexiMenu_RscShortcutButton classes soon and transfer properties to menu classes, if any. From 0780395ecf4e8f92a807ded6eea598aeb58486d1 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 8 Sep 2018 09:07:08 +0200 Subject: [PATCH 5/6] password saving setting --- addons/ui/CfgEventHandlers.hpp | 2 +- addons/ui/XEH_preClientInit.sqf | 12 --------- addons/ui/XEH_preInit.sqf | 32 ++++++++++++++++++++++++ addons/ui/fnc_initDisplayPassword.sqf | 2 ++ addons/ui/stringtable.xml | 36 +++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 13 deletions(-) delete mode 100644 addons/ui/XEH_preClientInit.sqf create mode 100644 addons/ui/XEH_preInit.sqf diff --git a/addons/ui/CfgEventHandlers.hpp b/addons/ui/CfgEventHandlers.hpp index 7a80d1bc1..3309da733 100644 --- a/addons/ui/CfgEventHandlers.hpp +++ b/addons/ui/CfgEventHandlers.hpp @@ -6,7 +6,7 @@ class Extended_PreStart_EventHandlers { class Extended_PreInit_EventHandlers { class ADDON { - clientInit = QUOTE(call COMPILE_FILE(XEH_preClientInit)); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; diff --git a/addons/ui/XEH_preClientInit.sqf b/addons/ui/XEH_preClientInit.sqf deleted file mode 100644 index 6febc990e..000000000 --- a/addons/ui/XEH_preClientInit.sqf +++ /dev/null @@ -1,12 +0,0 @@ -#include "script_component.hpp" - -LOG(MSG_INIT); - -call COMPILE_FILE(flexiMenu\init); - -// recreate after loading a savegame -addMissionEventHandler ["Loaded", { - if (!isNil QGVAR(ProgressBarParams)) then { - QGVAR(ProgressBar) cutRsc [QGVAR(ProgressBar), "PLAIN"]; - }; -}]; diff --git a/addons/ui/XEH_preInit.sqf b/addons/ui/XEH_preInit.sqf new file mode 100644 index 000000000..7f7a4c4d2 --- /dev/null +++ b/addons/ui/XEH_preInit.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" + +[ + QGVAR(StorePasswords), "LIST", + ["STR_CBA_Ui_StoreServerPasswords", "STR_CBA_Ui_StoreServerPasswordsTooltip"], + "STR_CBA_Ui_Category", + [[1, 0, -1], [ + ["STR_CBA_Ui_SavePasswords", "STR_CBA_Ui_SavePasswordsTooltip"], + ["STR_CBA_Ui_DoNotSavePasswords", "STR_CBA_Ui_DoNotSavePasswordsTooltip"], + ["STR_CBA_Ui_DeletePasswords", "STR_CBA_Ui_DeletePasswordsTooltip"] + ], 0], + 2, + { + if (_this isEqualTo -1) then { + profileNamespace setVariable [QGVAR(ServerPasswords), nil]; + }; + + profileNamespace setVariable [QGVAR(StorePasswords), _this]; + saveProfileNamespace; + } +] call cba_settings_fnc_init; + +if (hasInterface) then { + call COMPILE_FILE(flexiMenu\init); + + // recreate after loading a savegame + addMissionEventHandler ["Loaded", { + if (!isNil QGVAR(ProgressBarParams)) then { + QGVAR(ProgressBar) cutRsc [QGVAR(ProgressBar), "PLAIN"]; + }; + }]; +}; diff --git a/addons/ui/fnc_initDisplayPassword.sqf b/addons/ui/fnc_initDisplayPassword.sqf index 522bf841e..854a32dc3 100644 --- a/addons/ui/fnc_initDisplayPassword.sqf +++ b/addons/ui/fnc_initDisplayPassword.sqf @@ -1,5 +1,7 @@ #include "script_component.hpp" +if (profileNamespace getVariable [QGVAR(StorePasswords), 1] < 1) exitWith {}; + params ["_display"]; private _ctrlConfirm = _display displayCtrl IDC_OK; private _ctrlPassword = _display displayCtrl IDC_PASSWORD; diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index 478700091..a8d188f11 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -29,5 +29,41 @@ 进度条的位置。 Pozycja paska postępu. + + CBA UI + CBA UI + + + Store server passwords + Serverpasswörter speichern + + + Setting to store the passwords entered when connecting to a multiplayer server. + Einstellung zum Speichern der beim Betreten eines Mehrspielerservers eingegebenen Passwörter. + + + Save passwords + Passwörter speichern + + + Passwords are stored when connecting to a multiplayer server. + Passwörter werden beim Verbinden mit einem Mehrspielerserver gespeichert. + + + Do not save passwords + Passwörter nicht speichern + + + Passwords are not stored when connecting to a multiplayer server. Already stored passwords will not be automatically entered. + Passwörter werden beim Verbinden mit einem Mehrspielerserver nicht gespeichert. Bereits gespeicherte Passwörter werden nicht automatisch eingegeben. + + + Delete passwords + Passwörter löschen + + + Passwords are not stored when connecting to a multiplayer server. Already stored passwords are deleted from the profile. + Passwörter werden beim Verbinden mit einem Mehrspielerserver nicht gespeichert. Bereits gespeicherte Passwörter werden aus dem Profil gelöscht. + From 0da678db4be520281cd6614c7a1c3df524433f6d Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 8 Sep 2018 10:54:52 +0200 Subject: [PATCH 6/6] LLSTRING --- addons/ui/XEH_preInit.sqf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/ui/XEH_preInit.sqf b/addons/ui/XEH_preInit.sqf index 7f7a4c4d2..b2b0c6be3 100644 --- a/addons/ui/XEH_preInit.sqf +++ b/addons/ui/XEH_preInit.sqf @@ -2,12 +2,12 @@ [ QGVAR(StorePasswords), "LIST", - ["STR_CBA_Ui_StoreServerPasswords", "STR_CBA_Ui_StoreServerPasswordsTooltip"], - "STR_CBA_Ui_Category", + [LLSTRING(StoreServerPasswords), LLSTRING(StoreServerPasswordsTooltip)], + LLSTRING(Category), [[1, 0, -1], [ - ["STR_CBA_Ui_SavePasswords", "STR_CBA_Ui_SavePasswordsTooltip"], - ["STR_CBA_Ui_DoNotSavePasswords", "STR_CBA_Ui_DoNotSavePasswordsTooltip"], - ["STR_CBA_Ui_DeletePasswords", "STR_CBA_Ui_DeletePasswordsTooltip"] + [LLSTRING(SavePasswords), LLSTRING(SavePasswordsTooltip)], + [LLSTRING(DoNotSavePasswords), LLSTRING(DoNotSavePasswordsTooltip)], + [LLSTRING(DeletePasswords), LLSTRING(DeletePasswordsTooltip)] ], 0], 2, {