Skip to content

Commit

Permalink
replace more %xy in mission names (#1166)
Browse files Browse the repository at this point in the history
* replace more %xx in mission names

* update encoding list
  • Loading branch information
commy2 committed Jun 20, 2019
1 parent 57f542e commit e02e5cb
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 6 deletions.
1 change: 1 addition & 0 deletions addons/strings/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CfgFunctions {
PATHTO_FNC(strLen);
PATHTO_FNC(trim);
PATHTO_FNC(sanitizeHTML);
PATHTO_FNC(decodeURL);
};
};
};
44 changes: 44 additions & 0 deletions addons/strings/fnc_decodeURL.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_decodeURL
Description:
Reverse URL encoded text to readable text.
Parameters:
_string - URL encoded text <STRING>
Returns:
_return - Human readable text <STRING>
Examples:
(begin example)
"Mission%20Name" call CBA_fnc_decodeURL; // "Mission Name"
(end)
Author:
commy2
---------------------------------------------------------------------------- */

params [["_string", "", [""]]];
if (_string isEqualTo "") exitWith {""};

private _cache = missionNamespace getVariable [QGVAR(URLCache), objNull];
private _return = _cache getVariable _string;

if (isNil "_return") then {
_return = _string;

{
_return = ([_return] + _x) call CBA_fnc_replace;
} forEach UTF8_TABLE;

if (isNull _cache) then {
_cache = [] call CBA_fnc_createNamespace;
missionNamespace setVariable [QGVAR(URLCache), _cache];
};

_cache setVariable [_string, _return];
};

_return
219 changes: 219 additions & 0 deletions addons/strings/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,222 @@
#endif

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

#define UTF8_TABLE [\
["%21","!"],\
["%22",""""],\
["%23","#"],\
["%24","$"],\
["%26","&"],\
["%27","'"],\
["%28","("],\
["%29",")"],\
["%2a","*"],\
["%2b","+"],\
["%2c",","],\
["%2d","-"],\
["%2e","."],\
["%2f","/"],\
["%30","0"],\
["%31","1"],\
["%32","2"],\
["%33","3"],\
["%34","4"],\
["%35","5"],\
["%36","6"],\
["%37","7"],\
["%38","8"],\
["%39","9"],\
["%3a",":"],\
["%3b",";"],\
["%3c","<"],\
["%3d","="],\
["%3e",">"],\
["%3f","?"],\
["%40","@"],\
["%41","A"],\
["%42","B"],\
["%43","C"],\
["%44","D"],\
["%45","E"],\
["%46","F"],\
["%47","G"],\
["%48","H"],\
["%49","I"],\
["%4a","J"],\
["%4b","K"],\
["%4c","L"],\
["%4d","M"],\
["%4e","N"],\
["%4f","O"],\
["%50","P"],\
["%51","Q"],\
["%52","R"],\
["%53","S"],\
["%54","T"],\
["%55","U"],\
["%56","V"],\
["%57","W"],\
["%58","X"],\
["%59","Y"],\
["%5a","Z"],\
["%5b","["],\
["%5c","\"],\
["%5d","]"],\
["%5e","^"],\
["%5f","_"],\
["%60","`"],\
["%61","a"],\
["%62","b"],\
["%63","c"],\
["%64","d"],\
["%65","e"],\
["%66","f"],\
["%67","g"],\
["%68","h"],\
["%69","i"],\
["%6a","j"],\
["%6b","k"],\
["%6c","l"],\
["%6d","m"],\
["%6e","n"],\
["%6f","o"],\
["%70","p"],\
["%71","q"],\
["%72","r"],\
["%73","s"],\
["%74","t"],\
["%75","u"],\
["%76","v"],\
["%77","w"],\
["%78","x"],\
["%79","y"],\
["%7a","z"],\
["%7b","{"],\
["%7c","|"],\
["%7d","}"],\
["%7e","~"],\
["%e2%82%ac","`"],\
["%e2%80%9a",""],\
["%c6%92","ƒ"],\
["%e2%80%9e",""],\
["%e2%80%a6",""],\
["%e2%80%a0",""],\
["%e2%80%a1",""],\
["%cb%86","ˆ"],\
["%e2%80%b0",""],\
["%c5%a0","Š"],\
["%e2%80%b9",""],\
["%c5%92","Œ"],\
["%c5%bd","Ž"],\
["%e2%80%98",""],\
["%e2%80%99",""],\
["%e2%80%9c",""],\
["%e2%80%9d",""],\
["%e2%80%a2",""],\
["%e2%80%93",""],\
["%e2%80%94",""],\
["%cb%9c","˜"],\
["%e2%84",""],\
["%c5%a1","š"],\
["%e2%80",""],\
["%c5%93","œ"],\
["%c5%be","ž"],\
["%c5%b8","Ÿ"],\
["%c2%a1","¡"],\
["%c2%a2","¢"],\
["%c2%a3","£"],\
["%c2%a4","¤"],\
["%c2%a5","¥"],\
["%c2%a6","¦"],\
["%c2%a7","§"],\
["%c2%a8","¨"],\
["%c2%a9","©"],\
["%c2%aa","ª"],\
["%c2%ab","«"],\
["%c2%ac","¬"],\
["%c2%ae","®"],\
["%c2%af","¯"],\
["%c2%b0","°"],\
["%c2%b1","±"],\
["%c2%b2","²"],\
["%c2%b3","³"],\
["%c2%b4","´"],\
["%c2%b5","µ"],\
["%c2%b6",""],\
["%c2%b7","·"],\
["%c2%b8","¸"],\
["%c2%b9","¹"],\
["%c2%ba","º"],\
["%c2%bb","»"],\
["%c2%bc","¼"],\
["%c2%bd","½"],\
["%c2%be","¾"],\
["%c2%bf","¿"],\
["%c3%80","À"],\
["%c3%81","Á"],\
["%c3%82","Â"],\
["%c3%83","Ã"],\
["%c3%84","Ä"],\
["%c3%85","Å"],\
["%c3%86","Æ"],\
["%c3%87","Ç"],\
["%c3%88","È"],\
["%c3%89","É"],\
["%c3%8a","Ê"],\
["%c3%8b","Ë"],\
["%c3%8c","Ì"],\
["%c3%8d","Í"],\
["%c3%8e","Î"],\
["%c3%8f","Ï"],\
["%c3%90","Ð"],\
["%c3%91","Ñ"],\
["%c3%92","Ò"],\
["%c3%93","Ó"],\
["%c3%94","Ô"],\
["%c3%95","Õ"],\
["%c3%96","Ö"],\
["%c3%97","×"],\
["%c3%98","Ø"],\
["%c3%99","Ù"],\
["%c3%9a","Ú"],\
["%c3%9b","Û"],\
["%c3%9c","Ü"],\
["%c3%9d","Ý"],\
["%c3%9e","Þ"],\
["%c3%9f","ß"],\
["%c3%a0","à"],\
["%c3%a1","á"],\
["%c3%a2","â"],\
["%c3%a3","ã"],\
["%c3%a4","ä"],\
["%c3%a5","å"],\
["%c3%a6","æ"],\
["%c3%a7","ç"],\
["%c3%a8","è"],\
["%c3%a9","é"],\
["%c3%aa","ê"],\
["%c3%ab","ë"],\
["%c3%ac","ì"],\
["%c3%ad","í"],\
["%c3%ae","î"],\
["%c3%af","ï"],\
["%c3%b0","ð"],\
["%c3%b1","ñ"],\
["%c3%b2","ò"],\
["%c3%b3","ó"],\
["%c3%b4","ô"],\
["%c3%b5","õ"],\
["%c3%b6","ö"],\
["%c3%b7","÷"],\
["%c3%b8","ø"],\
["%c3%b9","ù"],\
["%c3%ba","ú"],\
["%c3%bb","û"],\
["%c3%bc","ü"],\
["%c3%bd","ý"],\
["%c3%be","þ"],\
["%c3%bf","ÿ"],\
["%%","%"],\
["%25","%"]\
]
2 changes: 1 addition & 1 deletion addons/ui/fnc_initDisplayDiary.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _this spawn {
params ["_display"];

private _missionName = _display displayCtrl IDC_DIARY_MISSION_NAME;
private _text = [ctrlText _missionName, "%20", " "] call CBA_fnc_replace;
private _text = ctrlText _missionName call CBA_fnc_decodeURL;
_missionName ctrlSetText _text;
};
};
10 changes: 10 additions & 0 deletions addons/ui/fnc_initDisplayInterrupt.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#include "script_component.hpp"

_this spawn {
isNil {
params ["_display"];

private _missionName = _display displayCtrl IDC_INT_MISSIONNAME;
private _text = ctrlText _missionName call CBA_fnc_decodeURL;
_missionName ctrlSetText _text;
};
};

if (isNil QGVAR(MenuButtons)) exitWith {};

params ["_display"];
Expand Down
9 changes: 7 additions & 2 deletions addons/ui/fnc_initDisplayMultiplayerSetup.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ private _fnc_update = {
_playerList lbSetValue [_playerList lbAdd _text, _value];
};

// replace %20 with space
// replace URL encoding
private _missionName = _display displayCtrl IDC_MPSETUP_NAME;
private _text = [ctrlText _missionName, "%20", " "] call (uiNamespace getVariable "CBA_fnc_replace");

private _text = ctrlText _missionName;
with uiNamespace do {
_text = _text call CBA_fnc_decodeURL;
};

_missionName ctrlSetText _text;
};

Expand Down
8 changes: 5 additions & 3 deletions addons/ui/fnc_initDisplayRemoteMissions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ private _fnc_storeMapMissions = {_this spawn {isNil { // delay a frame
private _ctrlMissions = _display displayCtrl IDC_SERVER_MISSION;

private _missions = [];
private _fnc_replace = uiNamespace getVariable "CBA_fnc_replace";

for "_i" from 0 to (lbSize _ctrlMissions - 1) do {
private _name = [_ctrlMissions lbText _i, "%20", " "] call _fnc_replace; // replace %20 with space
private _name = _ctrlMissions lbText _i;
with uiNamespace do {
_name = _name call CBA_fnc_decodeURL;
};

private _value = _ctrlMissions lbValue _i;
private _data = _ctrlMissions lbData _i;
private _color = _ctrlMissions lbColor _i;
Expand Down

0 comments on commit e02e5cb

Please sign in to comment.