The Options code seems to be behaving, so here is
version 0.5. The new options screen is accessed via Ctrl-Alt-O.
The options code consists of a few new modules and classes.
BugOptions Module
This is the main module for accessing options. It contains four important classes:
Option and OptionList Classes
This new class holds the metadata for a single option: name, INI section and key, title, tooltip, and default. OptionList adds values and format string for float dropdowns to Option. All the classes tie everything together internally using "name" while the INI file uses section/key.
BugOptions Class
This new class holds all of the Options metadata objects, provides access to the values, and reads/writes the INI file.
You shouldn't use this class directly.
OptionsFacade Class
This was the old BugOptions class and fulfills the same role as before: a facade to be used as a base class for creating your own option sets.
An example is BugScoreOptions. Each subclass's module should now provide a getOptions() top-level function (at the bottom of the file). To use one, it's similar to before:
Code:
# top of module
import BugScoreOptions
BugScore = BugScoreOptions.getOptions()
...
# throughout module as necessary
if (BugScore.isShowDeadCivs()):
...
BugInitOptions
This is a new module that simply imports all the specific option group modules (see above) in one place to set them up properly.
If you create a group of options, add it to this module.
Building the Options Screen
This next group of modules is responsible for building the BUG options screen (Ctrl-Alt-O) and saving the settings.
BugOptionsScreen Class
This class puts together the frame of the options screen: a TabControl consisting of any number of Tabs for grouping options.
When you add a Tab, add it to this module.
Tabs don't have to relate one-for-one to option groups. The idea is for option groups to provide mod-specific granular access to options. Groups with few options will probably be put onto a single Tab (like Misc or General).
BugOptionsTab Class
This is the base class for all of the Tabs that make up the screen. It provides functions for building the Tab visually: adding boxes, separators, labels, checkboxes, dropdowns, and edit boxes. Screen layout is a PITA in most all windowing toolkits, and BtS's is no exception. I tried to provide some basic building blocks that will allow the most common layouts to be created easily. See the example Tabs, but be forewarned that they probably won't be enough.
When you want to create a new Tab, you'll extend this class (see BugScoreOptionsTab as an example).
CvOptionsScreenCallbackInterface Module
The callbacks for handling events in the options screen are at the end of this file. Unfortunately, I cannot figure out how to get BtS to allow me to use a separate file for this.
You shouldn't need to use this module directly.
Examples
Working Options with Tabs:
- NJAGC
- Scores
- Alerts - Civ4lerts, reminders