From 075802d31c11f047355cd999cdeaa8900b86920b Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sun, 10 Dec 2023 18:20:59 +0100 Subject: [PATCH 1/5] Do not pad macro argument --- addons/markers/ui/mts_markers_dialog.hpp | 16 ++++++++-------- addons/markers/ui/mts_markers_ui_macros.hpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/markers/ui/mts_markers_dialog.hpp b/addons/markers/ui/mts_markers_dialog.hpp index be1e815..c48634b 100644 --- a/addons/markers/ui/mts_markers_dialog.hpp +++ b/addons/markers/ui/mts_markers_dialog.hpp @@ -65,7 +65,7 @@ class GVAR(RscPreview): RscControlsGroupNoScrollbars { y = QPOS_H(0); w = QPOS_W(PREVIEW_W); h = QPOS_H(PREVIEW_H); - colorBackground[] = BG_COLOR; + colorBackground[] = {BG_COLOR}; }; class Grid: RscPicture { @@ -124,7 +124,7 @@ class GVAR(RscConfiguration): RscControlsGroupNoScrollbars { y = QPOS_H(0); w = QPOS_W(CONFIG_W); h = QPOS_H(CONFIG_H); - colorBackground[] = BG_COLOR; + colorBackground[] = {BG_COLOR}; }; class FrameBackground: RscPicture { @@ -519,7 +519,7 @@ class GVAR(RscPresets): RscControlsGroupNoScrollbars { y = QPOS_H(0); w = QPOS_W(PRESETS_W); h = QPOS_H(PRESETS_H - (SMALL_BUTTON_H + PADDING)); - colorBackground[] = BG_COLOR; + colorBackground[] = {BG_COLOR}; }; class DeleteButtonBackground: RscText { idc = DELETE_PRESETS_BG; @@ -527,7 +527,7 @@ class GVAR(RscPresets): RscControlsGroupNoScrollbars { y = QPOS_H(PRESETS_H - SMALL_BUTTON_W); w = QPOS_W(SMALL_BUTTON_W); h = QPOS_H(SMALL_BUTTON_H); - colorBackground[] = BG_COLOR; + colorBackground[] = {BG_COLOR}; }; class SearchEdit: GVAR(RscEdit) { @@ -622,8 +622,8 @@ class GVAR(RscPresets): RscControlsGroupNoScrollbars { w = QPOS_W(SMALL_BUTTON_W); h = QPOS_H(SMALL_BUTTON_H); tooltip = CSTRING(ui_general_deletePresetsBTN_tooltip); - onMouseEnter = QUOTE(((ctrlParent (_this select 0)) displayCtrl DELETE_PRESETS_BG) ctrlSetBackgroundColor [ARR_4(0, 0, 0, 1)]); - onMouseExit = QUOTE(((ctrlParent (_this select 0)) displayCtrl DELETE_PRESETS_BG) ctrlSetBackgroundColor [ARR_4(0, 0, 0, 0.7)]); + onMouseEnter = QUOTE(((ctrlParent (_this select 0)) displayCtrl DELETE_PRESETS_BG) ctrlSetBackgroundColor [ARR_4(0,0,0,1)]); + onMouseExit = QUOTE(((ctrlParent (_this select 0)) displayCtrl DELETE_PRESETS_BG) ctrlSetBackgroundColor [BG_COLOR]); onButtonClick = QUOTE(call FUNC(deletePreset);); }; }; @@ -712,7 +712,7 @@ class GVAR(DTG): RscControlsGroupNoScrollbars { y = QPOS_H(0); w = QPOS_W(DTG_W); h = QPOS_H(DTG_H); - colorBackground[] = BG_COLOR; + colorBackground[] = {BG_COLOR}; }; class DateText: GVAR(RscText) { @@ -822,7 +822,7 @@ class GVAR(DTG): RscControlsGroupNoScrollbars { x = QPOS_W(DTG_TEXT_W + 2 * (DTG_BUTTON_W + PADDING)); text = CSTRING(ui_dtg_systemUTCTime); tooltip = CSTRING(ui_dtg_setSystemUTCTime_tooltip); - onButtonClick = QUOTE([ARR_2(systemTimeUTC, 'Z')] call FUNC(setDTGUIData);); + onButtonClick = QUOTE([ARR_2(systemTimeUTC,'Z')] call FUNC(setDTGUIData);); }; }; }; diff --git a/addons/markers/ui/mts_markers_ui_macros.hpp b/addons/markers/ui/mts_markers_ui_macros.hpp index c2aa922..643184f 100644 --- a/addons/markers/ui/mts_markers_ui_macros.hpp +++ b/addons/markers/ui/mts_markers_ui_macros.hpp @@ -1,5 +1,5 @@ // Style -#define BG_COLOR {0, 0, 0, 0.7} +#define BG_COLOR 0,0,0,0.7 // Sizes #define MAX_W 40 From 6da002ffc3914501f90c42f150db6b9df1eeffda Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sun, 10 Dec 2023 18:26:21 +0100 Subject: [PATCH 2/5] Clean up arguments --- tools/markers/create_alphanumeric_markers.py | 19 ++++++++----------- tools/markers/create_dtg_markers.py | 19 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/tools/markers/create_alphanumeric_markers.py b/tools/markers/create_alphanumeric_markers.py index 085eb4f..a439b98 100644 --- a/tools/markers/create_alphanumeric_markers.py +++ b/tools/markers/create_alphanumeric_markers.py @@ -242,9 +242,6 @@ def main(args: argparse.Namespace): print('This tool is not support on non-windows devices due to missing Arma Tools.') sys.exit(2) - png_only = args.png_only - clean_images = not args.no_clean - font = ImageFont.truetype(str(args.font_file), size=35) # 26pt == 35px print('Using font:', font.getname()) @@ -254,14 +251,14 @@ def main(args: argparse.Namespace): print('Creating images...') images = create_all_images(printable_char_sets, anchors, font) - print('Cleaning export folder:', clean_images) - if clean_images and args.output_dir.exists(): + print('Cleaning export folder:', args.clean) + if args.clean and args.output_dir.exists(): shutil.rmtree(args.output_dir) - print('Exporting only PNG files:', png_only) + print('Exporting only PNG files:', args.png_only) # Export images in parallel - util.export_images(images, args.output_dir, args.workers, image_to_paa=image_to_paa, png_only=png_only) + util.export_images(images, args.output_dir, args.workers, image_to_paa=image_to_paa, png_only=args.png_only) print(f'Exported {len(images)} images.\n') @@ -294,10 +291,10 @@ def main(args: argparse.Namespace): help='Exports markers as *.png files.', ) parser.add_argument( - '-nc', '--no-clean', + '-c', '--clean', action='store_true', - dest='no_clean', - help='Does not remove all files and directories in the export directory before creating the markers.' + dest='clean', + help='Remove all files and directories in the export directory before creating the markers.' ) parser.add_argument( '-o', '--output', @@ -325,4 +322,4 @@ def main(args: argparse.Namespace): main(args) -# python create_alphanumeric_markers.py -o ./images +# python create_alphanumeric_markers.py -o ./images --clean diff --git a/tools/markers/create_dtg_markers.py b/tools/markers/create_dtg_markers.py index 7e25b37..94d9537 100644 --- a/tools/markers/create_dtg_markers.py +++ b/tools/markers/create_dtg_markers.py @@ -156,9 +156,6 @@ def main(args: argparse.Namespace): print('This tool is not support on non-windows devices due to missing Arma Tools.') sys.exit(2) - png_only = args.png_only - clean_images = not args.no_clean - font = ImageFont.truetype(str(args.font_file), size=35) # 26pt == 35px print('Using font:', font.getname()) @@ -168,14 +165,14 @@ def main(args: argparse.Namespace): print('Creating images...') images = create_all_images(alphabets, font) - print('Cleaning export folder:', clean_images) - if clean_images and args.output_dir.exists(): + print('Cleaning export folder:', args.clean) + if args.clean and args.output_dir.exists(): shutil.rmtree(args.output_dir) - print('Exporting only PNG files:', png_only) + print('Exporting only PNG files:', args.png_only) # Export images in parallel - util.export_images(images, args.output_dir, args.workers, image_to_paa=image_to_paa, png_only=png_only) + util.export_images(images, args.output_dir, args.workers, image_to_paa=image_to_paa, png_only=args.png_only) print(f'Exported {len(images)} images.\n') @@ -206,10 +203,10 @@ def main(args: argparse.Namespace): help='Exports markers as *.png files.', ) parser.add_argument( - '-nc', '--no-clean', + '-c', '--clean', action='store_true', - dest='no_clean', - help='Does not remove all files and directories in the export directory before creating the markers.' + dest='clean', + help='Remove all files and directories in the export directory before creating the markers.' ) parser.add_argument( '-o', '--output', @@ -237,4 +234,4 @@ def main(args: argparse.Namespace): main(args) -# python create_dtg_markers.py -o ./images +# python create_dtg_markers.py -o ./images --clean From fda94a03dc096a8e73c9f21c8e73dcb7257e082e Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sun, 10 Dec 2023 18:29:07 +0100 Subject: [PATCH 3/5] Formatting --- addons/markers/functions/fnc_setUIData.sqf | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/addons/markers/functions/fnc_setUIData.sqf b/addons/markers/functions/fnc_setUIData.sqf index 08f45a4..4457584 100644 --- a/addons/markers/functions/fnc_setUIData.sqf +++ b/addons/markers/functions/fnc_setUIData.sqf @@ -6,24 +6,20 @@ * Sets the core data for the UI. * * Parameter(s): - * 0: ARRAY - Frameshape. - * 1: ARRAY - Modifer. - * 2: ARRAY - Group size. - * 3: ARRAY - Left text. - * 4: STRING - Right text. + * Same marker configuration as in createMarkerLocal. * * Returns: * Nothing. * * Example: - * [["blu", false, false], [4,0,0], [4, false, true], ["3","3"], "9"] call mts_markers_fnc_setUIData + * _markerParameter call mts_markers_fnc_setUIData * */ params [ - ["_frameshape", ["",false,false], [[]]], - ["_modifier", [0,0,0], [[]], 3], - ["_size", [0,false,false], [[]], 3], + ["_frameshape", ["", false, false], [[]]], + ["_modifier", [0, 0, 0], [[]], 3], + ["_size", [0, false, false], [[]], 3], ["_uniqueDesignation", [], [[]]], ["_additionalInfo", "", [""]], ["_higherFormation", [], [[]]], @@ -31,8 +27,16 @@ params [ ["_dateTimeGroup", [], [[]]], ["_direction", "", [""]] ]; -_frameshape params [["_identity", "", [""]], ["_dashedFrameshape", false, [false]], ["_isHq", false, [false]]]; -_size params [["_grpsize", 0, [0]], ["_reinforced", false, [false]], ["_reduced", false, [false]]]; +_frameshape params [ + ["_identity", "", [""]], + ["_dashedFrameshape", false, [false]], + ["_isHq", false, [false]] +]; +_size params [ + ["_grpsize", 0, [0]], + ["_reinforced", false, [false]], + ["_reduced", false, [false]] +]; private _mainDisplay = findDisplay MAIN_DISPLAY; From c92db5b37d9678b395fe377d01654551acc35502 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sun, 10 Dec 2023 18:34:44 +0100 Subject: [PATCH 4/5] Add more safe guards --- addons/markers/functions/fnc_getTimeZone.sqf | 9 +++++---- addons/markers/functions/fnc_getTimeZoneIdentifier.sqf | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/markers/functions/fnc_getTimeZone.sqf b/addons/markers/functions/fnc_getTimeZone.sqf index ed27da9..f05ae85 100644 --- a/addons/markers/functions/fnc_getTimeZone.sqf +++ b/addons/markers/functions/fnc_getTimeZone.sqf @@ -6,11 +6,12 @@ * Returns the standard time zone for the given time. * * Parameter(s): - * 0: ARRAY - Hours and minutes (e.g. from systemTime). - * 1: ARRAY - UTC hours and minutes (e.g. from systemTimeUTC). + * 0: ARRAY - Hours and minutes or return value from systemTime command. + * 1: ARRAY - UTC hours and minutes or return value from systemTimeUTC command. * * Returns: * ARRAY - Standard time zone in the format [diffHours, diffMinutes]. + * Emtpy array on error. * diffHours is in range -12 ... +12. * E.g. [-9, 30] => UTC-09:30; [1, 0] => UTC+01:00 * @@ -19,9 +20,9 @@ * */ -params [["_time", [], [[]]], ["_timeUtc", [], [[]]]]; +params [["_time", [], [[]], [2, 7]], ["_timeUtc", [], [[]], [2, 7]]]; -CHECK((_time isEqualTo []) || (_timeUtc isEqualTo [])); +CHECKRET((_time isEqualTo []) || (_timeUtc isEqualTo []), []); // time is passed from systemTime command if ((count _time) isEqualTo 7) then { diff --git a/addons/markers/functions/fnc_getTimeZoneIdentifier.sqf b/addons/markers/functions/fnc_getTimeZoneIdentifier.sqf index a61c585..40af077 100644 --- a/addons/markers/functions/fnc_getTimeZoneIdentifier.sqf +++ b/addons/markers/functions/fnc_getTimeZoneIdentifier.sqf @@ -20,6 +20,7 @@ params [["_time", [], [[]]], ["_timeUtc", [], [[]]]]; private _timeZone = [_time, _timeUtc] call FUNC(getTimeZone); // _timeDiffH hour is in range -12..+12 +CHECKRET(_timeZone isEqualTo [], ""); // Simplify time zones according to ATP 6-02.70 Appendix E // Do not consider the minutes From 1df59af8f1280c3bff61244482fda543ad52f7e8 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sun, 10 Dec 2023 18:39:14 +0100 Subject: [PATCH 5/5] Improve docs --- addons/markers/functions/fnc_toDTGCharaters.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/markers/functions/fnc_toDTGCharaters.sqf b/addons/markers/functions/fnc_toDTGCharaters.sqf index 75e9225..f3b71da 100644 --- a/addons/markers/functions/fnc_toDTGCharaters.sqf +++ b/addons/markers/functions/fnc_toDTGCharaters.sqf @@ -6,7 +6,7 @@ * Constructs and returns the Date-Time Group charaters. * * Parameter(s): - * 0: ARRAY - Year, month, day, hours, minutes. + * 0: ARRAY - Year, month, day, hours, minutes from date, systemTime or systemTimeUTC command. * 1: STRING - Standard time zone identifier (one character). * * Returns: