Ok. Fairly major update just pushed to the SVN (parallel maps svn is at svn://svn.code.sf.net/p/parallelmaps/code/trunk for read access):
Viewports initial implementation complete.
This work leverages a lot of the multimap underpinnings (multimaps themselves are not yet complete however) to provide virtual maps which are viewports (windows if you like) into the underlying map (or maps once we have multimaps fully working).
The idea behind this is to increase (potentially significantly) the scalability of maps in Civ, since as far as the game engine is concerned the map is just the size of the viewport (graphically that is - the AI and so on still see the full map), so only graphical assets needed for that area are loaded (which should hopefully lead to very significant memory savings on large maps).
Each map can have one or more viewports associated with it (current demo just surfaces one, but the API supports an arbitrary number). At any one time, one of the viewports is the current viewport, and the current viewport of the current map is what get displayed. Obviously a UI is needed for switching/creating viewports, or at least moving the current one around wthin the larger underlying map. Long term my vision is to have a new advisor-like UI screen which gives an overview of viewports, which you define freely (so imagine having viewports for different theatres of war - say europe, north america, etc. on an earth map). You will have the ability to name viewports and switch between them by name, or of seeing them as outline overlays on a larger map of the entire planet and selecting by clicking.
In the current version I have seconded the military advisor to provide control over viewports. This works as follows:
- At game load (or new game start) the viewport will center on the initially active unit
- When you go into the military advisor the minimap there (the map in the advisor is just an instance of the minimap) will show the entire underlying map [not just the current viewport]. This is anyway necessary really, or else it would only tell you about that part of your military that happened to be within the current viewport, which is unlikely to be what you want
- Clicking on the map in the military advisor will set the main map viewing there (as it did before), and if that click was outside the current viewport it will also move the viewport to center on the point you clicked
Thus the military advisor is also a means to control the position of the viewport, in the absence of more advanced UI for this purpose
If you want to try it out, grab the current contents of the 'assets' folder from the SVN and set it up within a test mod folder ('parallel maps' say). To just test out the viewports you'll need to make two changes to the XML (which I've left set up by default as multimaps ON, viewports OFF, so that it doesn't disturb Lytning's work on the multimaps). In Assets/xml is a file called 'ParallelMaps_GlobalDefines.xml'. This contains:
Code:
<?xml version="1.0"?>
<!-- Global Defines -->
<Civ4Defines xmlns="x-schema:CIV4GlobalDefinesSchema.xml">
<Define>
<DefineName>ENABLE_MULTIMAPS</DefineName>
<iDefineIntVal>1</iDefineIntVal>
</Define>
<Define>
<DefineName>ENABLE_VIEWPORTS</DefineName>
<iDefineIntVal>0</iDefineIntVal>
</Define>
<Define>
<DefineName>VIEWPORT_SIZE_X</DefineName>
<iDefineIntVal>50</iDefineIntVal>
</Define>
<Define>
<DefineName>VIEWPORT_SIZE_Y</DefineName>
<iDefineIntVal>50</iDefineIntVal>
</Define>
</Civ4Defines>
To get viewports without mutlimaps (which is basically what more or less works now) set ENABLE_MULTIMAPS to 0, and ENABLE_VIEWPORTS to 1. The viewport size settings can also be changed as you see fit, but see notes below.
Notes:
- The switch into and out of the military advisor involves a virtual map switch, in order to change what the minimap used in the advisor displays. It thus takes the same amount of time (essentually) as a map switch does. This time is proportional to the area of the viewport, so smaller viewports result in faster switching. The 50 X 50 I have in the default XML is about 2 seconds for me, but your mileage may vary
- There are some bugs I'm still fighting the game engine over - occassionally (it's a bi erratic and I'v greatly redcued it, but not yet entirely eliminated it) you'll see the selected unit's selection highlight and/or its flag displace itself by a few tiles from the unit on switching back into the main map from the advisor. Clicking the unit (or clicking another one then back to it) resolves it, so it's just cosmetic (annoying though)
- Exiting the advisor by pressing escape does not work correctly right now. I still nee to fix that. Exiting by clicking the minimap or by pressing the 'Exit' button both should work ok
- Not really a viewports issue (more a multimap issue), but the settings you select for map script and map size are currently ignored, and are read from the MapInfos.xml file instead. The model for this will need to integrate better with the UI selectable map options, but that'll happen further down the road
- I have tweaked the selection group order for units (the order in which they select as you move them) to minimize viewport switching. It will cycle trhoguh tegh units that are in the current viewport first, and after there are none left there which require moving, will automatically select one not in the current viewport, and re-center the viewport there
A good way to get a feel for it is to just start a new game with debug mode (chipotle) enabled, reveal the entire world (ctrl-Z), and then switch around, possibly adding a few units in in far flung places using world-builder so you can see how it behaves with units not all on the current viewport.
My next steps will be:
- Fix the escape-to-exit-advisor bug
- Port what is done so far to C2C
- Make some memory usage measurements using mature save games from C2C on very large maps (GEM), to (hopefully) validate the memory savings
- Help Lytning as required with the other aspects of multimaps