Each post will have an aspect of the design, and explain it. No part of the design is concrete, even the part is already implemented - if it can be done better, I plan to do it at some point, even if not immediately.
When RF2 starts, it executes setup.py, which is located in the scripts folder. setup.py is the script which sets options for RF2 to start with - resolution, fullscreen, color depth, etc. If any attribute in the script is not changed, it will use a default - for instance, if you don't set whether RF2 should start fullscreen, it will start in a window. This script is where you could show a dialog asking the user for video options - it's completely up to you, and RF2 is paused until you're done in setup.py. It runs the script just as you would if you executed "import setup" in the Python console, adding the scripts folder to the Python path (so it can find other scripts, if you wish to import other scripts into setup). After setup.py has finished executing, it initializes Ogre with the parameters set in the script, creating the window. Some of the parameters set in setup are ignored in the editor - things like resolution (which depends on the viewport size), fullscreen (it's always windowed), and so on.
A module called "rfsetup" is created before setup.py is run, and the options are stored in there. They are preset to their defaults, and can be changed as you wish - for instance, "rfsetup.fullscreen = True".
Brief example, loading fullscreen attribute from a file and using it appropriately:
Code: Select all
import rfsetup
options_file = file("options.cfg")
for line in options_file:
split_line = line.split()
if line.startswith("fullscreen") and len(split_line) == 2:
rfsetup.fullscreen = (split_line[1] == 'true')
options_file.close()