From f6fed505ccc7115e870e6d2c7656a8b9bd5ccf8a Mon Sep 17 00:00:00 2001 From: Ry Date: Thu, 12 Oct 2023 16:49:37 -0700 Subject: [PATCH] Fetcher: Add browser icons, pulled from icons.res at runtime --- applications/fetcher/Browser.okm | 30 +++++++++++++++++++++++++++++- applications/fetcher/OS.okm | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/applications/fetcher/Browser.okm b/applications/fetcher/Browser.okm index 4d76cba..7e7ed01 100644 --- a/applications/fetcher/Browser.okm +++ b/applications/fetcher/Browser.okm @@ -10,6 +10,8 @@ MODULE Browser; browserPrevPageButton: Fox32OSButtonWidget; browserDiskId: INT; browserFileList: ARRAY 341 OF CHAR; + browserHasIcons: CHAR; + browserIconsResPtr: PTR; EXTERN browserMenuItemsRoot: POINTER TO CHAR; EXTERN browserFileListFriendly: ARRAY 12 OF POINTER TO CHAR; @@ -36,14 +38,17 @@ MODULE Browser; browserRunning := 1; browserPage := 0; browserDiskId := diskId; + browserHasIcons := 0; + browserIconsResPtr := iconsResPtr; (* if icons.res was loaded, then pull the `dsk` resource from it *) IF hasIcons THEN - tempDskIconResPtr := get_resource(iconsResPtr, "dsk", 4096); + tempDskIconResPtr := get_resource(browserIconsResPtr, "dsk", 4096); IF tempDskIconResPtr THEN copy_memory_bytes(tempDskIconResPtr, PTROF(desktopDiskIcon), 4096); free_memory(tempDskIconResPtr); END; + browserHasIcons := 1; END; (* create the window and draw its initial contents *) @@ -123,6 +128,29 @@ MODULE Browser; fill_window(0FFFFFFFFH, PTROF(browserWindow)); SetupBrowserIconStructs(); draw_widgets_to_window(PTROF(browserWindow)); + IF browserHasIcons THEN + DrawBrowserIcons(); + END; + END; + + PROCEDURE DrawBrowserIcons(); + VAR i: INT; + icon: POINTER TO Fox32OSButtonWidget; + tempFileIconResPtr: PTR; + overlay: INT; + BEGIN + i := 0; + overlay := get_window_overlay_number(PTROF(browserWindow)); + WHILE i <| 12 DO + icon := PTROF(browserIcons[i]); + tempFileIconResPtr := get_resource(browserIconsResPtr, icon^.text + string_length(icon^.text) - 3, 4096); + IF tempFileIconResPtr THEN + set_tilemap(tempFileIconResPtr, 32, 32); + draw_tile_to_overlay(0, icon^.x, icon^.y, overlay); + free_memory(tempFileIconResPtr); + END; + i := i + 1; + END; END; PROCEDURE SetupBrowserIconStructs(); diff --git a/applications/fetcher/OS.okm b/applications/fetcher/OS.okm index 0539818..a0e8bdb 100644 --- a/applications/fetcher/OS.okm +++ b/applications/fetcher/OS.okm @@ -10,7 +10,7 @@ MODULE OS; set_window_flags, menu_update_event, menu_bar_click_event, close_menu, new_messagebox, launch_fxf_from_disk, get_boot_disk_id, string_to_int, set_tilemap, draw_tile_to_overlay, ryfs_get_file_list, copy_memory_bytes, IsRomDiskAvailable, end_current_task, sleep_task, - open, read, get_size, get_boot_disk_id, get_resource, allocate_memory, free_memory: INT; + open, read, get_size, get_boot_disk_id, get_resource, allocate_memory, free_memory, string_length: INT; EXTERN PROCEDURE brk: INT;