Plugin Configuration: An Adventure in GUIland

So, we've got plugins, but we don't have any way to actually run them yet. For that, we need a GUI.

Implementing all this in a relatively sane way required a fair amount of work and classes, so I won't go into as much detail here as I have on other posts. I've created something like a dozen new classes and nib files to support the configuration and execution of ALife models.

I haven't been documenting this as I code, so I don't have a nice step-by-step genesis of the changes as I've done for other posts. Instead, here's a walkthrough of what happens to make this window:

configuration.png

and then to turn it into this window:

game of life window.png

Briefly, then:

  1. When "New" is picked from the File menu, a list of plugins (as described in the last post) is generated by the AppController, and a new ALifeWindowController is created and fed with these classes.
  2. The ALifeWindowController creates a list of model names to populate the left-hand side.
  3. Once a model's name is picked, the ALifeWindowController queries the selected ALifeController for its configuration (an addition to the ALifeController protocol).
  4. The ALifeConfigurationViewController on the right-hand side is populated with this list of configuration options, which might look something like this: game of life configuration.png
  5. For each entry in the configuration array, a new *OptionViewController is created and added to the main configuration view. So far, there are only IntegerOptionViewControllers, and FloatOptionViewControllers, which are virtually identical except for the types they handle. (There is a lot of DRYing up that needs to be done on this code.)
  6. Each OptionViewController manages its own state. When the "Start" button is clicked, the ALifeConfigurationViewController is queried for its state, which builds a dictionary of key-value pairs based on the keys and values stored by each OptionViewController.
  7. This dictionary is fed to the ALifeController in question, to which protocol has been added the method initWithConfiguration:(NSDictionary *)configuration. The ALifeController creates a new instance of its model initialized as specified.
  8. A new ALifeWindowController is created, which manages StatisticsViews as described before. The ALifeController is queried for a view, which is then added to the ALifeWindowController's window.
  9. That's it! (Whew.)

Next time, exporting configuration options to a standalone file, and reading them back in when they're double-clicked.

Leave a comment