← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/bug-1397500 into lp:widelands

 

>  So, I would like the calls to look like load("buttons/button01.png") rather than load("images/buttons/button01.png")

If you desire this to be more concise, I think a better approach is to create a sub-filesystem that tracks the images directory. So instead of pulling out the constants into a file, you basically create multiple filesystems:

g_fs = createFilesystem("data/");
Tribes::SetGlobalFilesystem(g_fs->create_sub_filesystem("tribes"));
World::SetGlobalFilesytem(g_fs->create_sub_filesystem("world"));
Ui::SetGlobalFilesystem(g_fs->create_sub_filesystem("images"));

Though most of these functions should not be static, instead the constructor of World and Tribes should take the sub filesystem to search for their data so that ownership is clearly defined.

This does not solve the directory layout inside of the different sub directories of course. I also believe that this might take separation too far. Needing to list the full path allows more flexibility - i.e. you can use headquarters/menu.png also as the background of a window and you can use tribe graphics from the ui by just specifying the full path. 

There _is_ a directory layout, I think we have to acknowledge it is there and accept that having a full path to the files brings repetition, but has advantages and disadvantages.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1397500/+merge/243860
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1397500 into lp:widelands.


References