s25client icon indicating copy to clipboard operation
s25client copied to clipboard

Load campaign data only once

Open Flamefire opened this issue 1 year ago • 0 comments
trafficstars

This fixes #1705 but is a larger rework to make campaign handling easier and more flexible.

The reason for the bug was that the campaign file is loaded repeatedly, especially in the draw call to determine whether to draw the image.

So load data for all campaigns when opening the capaign selection window. We don't rescan the folders while the window is open so there is no need to load the lua files multiple times.

If we pass the parsed campaign to the mission selection screen we can also get rid of the invisible column for the filepath. Finally we can load all resources (images) in one go. The 2 mission selection classes share some code and essentially the same functionality and the difference in naming doesn't make it clear which is which. Especially problematic is the reliance on the "mission map" in the campaign description which may lead to an empty screen if dskCampaignMissionMapSelection is instantiated in absence of that. So just merge them so the campaign selection doesn't need to decide which one to use and the screen can use the representation that is available, i.e. either a map to select an area or the list as a fallback. The result looks exactly the same.

I noticed that we can rather use std::optional in 2 places for improved semantics. When modifying the test I noticed that the whole project gets recompiled instead of only libGamedata (I moved the test to the corresponding test suite) which was due to some superflous dependencies in CMake.

Flamefire avatar Oct 21 '24 12:10 Flamefire