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
___Arguments
class that is unique to your experiment and contains the fields you need to pass (make thempublic
for 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
- This class has to implement
- In your controller, pass an instance of your arguments class into the
Game
class's constructor, through thedata
parameter (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___Arguments
class, e.g.Note:MyConfigArguments args = (MyConfigArguments)gs.getDataFromController();
gs
is aprotected
member of theGameConfigDetailsRunnable
class, which your Configuration class extends.