OpenFunscripter / OFS

A tool to create funscripts
GNU General Public License v3.0
84 stars 37 forks source link

Load recent project name glyph on start #48

Closed trassshhub closed 1 year ago

trassshhub commented 1 year ago

On OFS start up, recent projects with unicode names is not loaded correctly (showing as question marks). I added a AddText call before adding recent project to the menu item to load the necessary unicode glyph.

OpenFunscripter commented 1 year ago

Because this is immediate mode UI, this gets called every frame while the user is hovering the recent files menu item.

It's definetly a micro optimization but I would prefer this do be done once after the config.json was loaded in here. https://github.com/OpenFunscripter/OFS/blob/2ca73beacbd8758b28574ce2e075551bcd0d393f/src/UI/OFS_Settings.cpp#L35-L38 After the OFS::serializer::load. You could iterate scripterSettings.recentFiles and call OFS_DynFontAtlas::AddText on each item.

Sorry for being so pedantic 😔

trassshhub commented 1 year ago

I was thinking of the same thing when I was trying to modify the code. It's just that my c++ skill is not good enough. I tried adding a for loop after OFS::serializer::load but OFS wouldn't start, I think it's better to leave the fix to you to do it properly.

OpenFunscripter commented 1 year ago

Sure I'll fix it. I looked at it more closely and the reason it didn't work is initialization order. When load_config() is called OFS_DynFontAtlas::Init() hasn't been called yet and you get a null dereference.

I'll have to find a different place to put this.

OpenFunscripter commented 1 year ago

I just ended up putting it at the end of OpenFunscripter::setup. Not pretty but does the job.