Passing arguments to the configuration class
To avoid needing multiple copies of the same configuration class, it is sometimes necessary to pass arguments to the configuration class. This is currently a little bit unintuitive, but nonetheless very simple to implement.
Here's a list of what you need to do:
Create a small
___Argumentsclass that is unique to your experiment and contains the fields you need to pass (make thempublicfor simplicity).This class has to implement
Serializable.The class must be contained in a namespace that is
import'ed in the fileedu.harvard.eecs.airg.coloredtrails.server.CtrlCommands. Otherwise, the application will crash when trying to deserialize the class.
I recommend usingedu.harvard.eecs.airg.coloredtrails.shared.types
In your controller, pass an instance of your arguments class into the
Gameclass's constructor, through thedataparameter (currently the last parameter).In your configuration class's constructor (or other initialization method), retrieve the arguments by calling
gs.getDataFromController()and casting the result to your___Argumentsclass, e.g.MyConfigArguments args = (MyConfigArguments)gs.getDataFromController();Note:
gsis aprotectedmember of theGameConfigDetailsRunnableclass, which your Configuration class extends.