Project Zomboid

Project Zomboid

Mutie's Context Menu Icons
ㄥㄖ尺乇 19 Oct, 2024 @ 12:38pm
Making the mod more versatile
You can make a new helper function that can look for a partial string match instead of being the exact context menu option by creating this function:

require "ISUI/ISContextMenu";

function ISContextMenu:getOptionFromStringIncluded(name)
ㅤfor i, v in ipairs(self.options) do
ㅤㅤif string.find(string.lower(name), string.lower(v.name), 1, true) then
ㅤㅤㅤreturn v
ㅤㅤend
ㅤend
end


Then, some context menu options can be set like this:

require("MutiesContextMenuIcons/HelperFunctions");

MutiesContextMenuIcons.Options["Rename"] = "media/ui/icons/redrawn/small/Rename.png";


So it'll just see if the options include the word "Rename" and apply the icon. I think this would make things easier
Last edited by ㄥㄖ尺乇; 19 Oct, 2024 @ 1:01pm
< >
Showing 1-3 of 3 comments
ㄥㄖ尺乇 19 Oct, 2024 @ 11:48pm 
Made a mod for this:
Context Menu Icon MANIA

Feel free to check out the code. I reckoned the best way to apply the icon is to hook into addOption and make a separate object of options (Partial Match vs Exact Match)

And I made it so some can have a partial match, i.e. allowing in-between strings to exist but adding the same icon if a context option says "Remove [x] from [y]"
Last edited by ㄥㄖ尺乇; 20 Oct, 2024 @ 5:16pm
Mutie  [developer] 19 Dec, 2024 @ 10:42am 
I like this approach, and I'd like to write it up in my own way and add it to the community library[github.com] Chuck is building, if you don't mind.
That sounds awesome!

I should mention one caveat to this is that translations will need to be made manually. Maybe we could find a way around that, though
< >
Showing 1-3 of 3 comments
Per page: 1530 50