OneLoneCoder / olcPixelGameEngine

The official distribution of olcPixelGameEngine, a tool used in javidx9's YouTube videos and projects
Other
3.83k stars 917 forks source link

olcPGEX_PopUpMenu.h feature request: Ability to remove items. #289

Open radekrudak opened 2 years ago

radekrudak commented 2 years ago

Would it be possible and feasible to add ability to remove items and tables ( and it's children) ? For example :


OlcPopUpMenu["MainMenu"].SetTable(1,2);
OlcPopUpMenu["MainMenu"]["New Game"].SetID(1);
OlcPopUpMenu["MainMenu"]["Load Game"].SetTable(1,2);
OlcPopUpMenu["MainMenu"]["Load Game"]["Chapter1"].SetTable(1,2);
OlcPopUpMenu["MainMenu"]["Load Game"]["Chapter1"]["Map1"].SetID(4);
OlcPopUpMenu["MainMenu"]["Load Game"]["Chapter1"]["Map2"].SetID(5); 
/*
now table contains 
New Game
Load Game 
       Chapter1
              Map1
              Map2

*/
OlcPopUpMenu["MainMenu"]["Load Game"].Remove("Chapter1");
/*
 now it only contains:
New Game
Load Game
*/ 

I'm working with this PGEX and among other this i want to use it to build inventory UI, inventory can be arbitrary size and size changes. It isn't deal breaker because having popup menu in pointer which gets destroyed and reconstructed works, but ability to remove objects would be handy(so i have one obj allocated on stack).

If someone with more knowledge about this PGEX is able to confirm that it is in fact possible and if javidx9 would be willing to accept such feature in pull request i would really like to try to implement it but first i would like to have confirmation that i'm not wasting time.

radekrudak commented 2 years ago

So, i implemented this feature myself and seems to work. Should i make pull request ?