Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup code #84

Merged
merged 5 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions addons/markers/functions/fnc_getTimeZone.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions addons/markers/functions/fnc_getTimeZoneIdentifier.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 15 additions & 11 deletions addons/markers/functions/fnc_setUIData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,37 @@
* 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", [], [[]]],
["_operationalCondition", 0, [0]],
["_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;

Expand Down
2 changes: 1 addition & 1 deletion addons/markers/functions/fnc_toDTGCharaters.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions addons/markers/ui/mts_markers_dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -519,15 +519,15 @@ 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;
x = QPOS_W(PRESETS_W - SMALL_BUTTON_W);
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) {
Expand Down Expand Up @@ -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););
};
};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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););
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion addons/markers/ui/mts_markers_ui_macros.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 8 additions & 11 deletions tools/markers/create_alphanumeric_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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')

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
19 changes: 8 additions & 11 deletions tools/markers/create_dtg_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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')

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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