Skip to content

Commit

Permalink
make server browser remember last used password for every server (#973)
Browse files Browse the repository at this point in the history
* make serverbrowser remember last used password for every server

* Travis can't handle #

* Travis can't handle #

* use DisplayLoad

* password saving setting

* LLSTRING
  • Loading branch information
commy2 committed Sep 10, 2018
1 parent ae98d8b commit e2e4266
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 13 deletions.
5 changes: 4 additions & 1 deletion addons/ui/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
};

Expand All @@ -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)'));
};
};
12 changes: 0 additions & 12 deletions addons/ui/XEH_preClientInit.sqf

This file was deleted.

32 changes: 32 additions & 0 deletions addons/ui/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "script_component.hpp"

[
QGVAR(StorePasswords), "LIST",
[LLSTRING(StoreServerPasswords), LLSTRING(StoreServerPasswordsTooltip)],
LLSTRING(Category),
[[1, 0, -1], [
[LLSTRING(SavePasswords), LLSTRING(SavePasswordsTooltip)],
[LLSTRING(DoNotSavePasswords), LLSTRING(DoNotSavePasswordsTooltip)],
[LLSTRING(DeletePasswords), LLSTRING(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"];
};
}];
};
1 change: 1 addition & 0 deletions addons/ui/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

PREP(initDisplayInterrupt);
PREP(initDisplayMultiplayerSetup);
PREP(initDisplayPassword);
41 changes: 41 additions & 0 deletions addons/ui/fnc_initDisplayPassword.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#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;
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 select 0) find _server;
if (_index isEqualTo -1) then {
_index = (_passwordCache select 0) pushBack _server;
};
(_passwordCache select 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 select 0) find _server;
private _password = (_passwordCache select 1) param [_index, ""];
//diag_log ["read", _server, _password];

if (_password != "") then {
_ctrlPassword ctrlSetText _password;
};
36 changes: 36 additions & 0 deletions addons/ui/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,41 @@
<Chinesesimp>进度条的位置。</Chinesesimp>
<Polish>Pozycja paska postępu.</Polish>
</Key>
<Key ID="STR_CBA_Ui_Category">
<English>CBA UI</English>
<German>CBA UI</German>
</Key>
<Key ID="STR_CBA_Ui_StoreServerPasswords">
<English>Store server passwords</English>
<German>Serverpasswörter speichern</German>
</Key>
<Key ID="STR_CBA_Ui_StoreServerPasswordsTooltip">
<English>Setting to store the passwords entered when connecting to a multiplayer server.</English>
<German>Einstellung zum Speichern der beim Betreten eines Mehrspielerservers eingegebenen Passwörter.</German>
</Key>
<Key ID="STR_CBA_Ui_SavePasswords">
<English>Save passwords</English>
<German>Passwörter speichern</German>
</Key>
<Key ID="STR_CBA_Ui_SavePasswordsTooltip">
<English>Passwords are stored when connecting to a multiplayer server.</English>
<German>Passwörter werden beim Verbinden mit einem Mehrspielerserver gespeichert.</German>
</Key>
<Key ID="STR_CBA_Ui_DoNotSavePasswords">
<English>Do not save passwords</English>
<German>Passwörter nicht speichern</German>
</Key>
<Key ID="STR_CBA_Ui_DoNotSavePasswordsTooltip">
<English>Passwords are not stored when connecting to a multiplayer server. Already stored passwords will not be automatically entered.</English>
<German>Passwörter werden beim Verbinden mit einem Mehrspielerserver nicht gespeichert. Bereits gespeicherte Passwörter werden nicht automatisch eingegeben.</German>
</Key>
<Key ID="STR_CBA_Ui_DeletePasswords">
<English>Delete passwords</English>
<German>Passwörter löschen</German>
</Key>
<Key ID="STR_CBA_Ui_DeletePasswordsTooltip">
<English>Passwords are not stored when connecting to a multiplayer server. Already stored passwords are deleted from the profile.</English>
<German>Passwörter werden beim Verbinden mit einem Mehrspielerserver nicht gespeichert. Bereits gespeicherte Passwörter werden aus dem Profil gelöscht.</German>
</Key>
</Package>
</Project>

0 comments on commit e2e4266

Please sign in to comment.