Creating New Datagrid

From LinuxMCE
Revision as of 00:25, 10 March 2011 by Uplink (Talk | contribs) (Remove installation instructions for Designer. These should be in the Designer page.)

Jump to: navigation, search

How do I create a new games plugin that generates a datagrid showing games on the screen?

Here is how I would do it:

  • Add a device template for the 'Games Plugin'. Use Climate Plugin as the template; it's the simplest of the plugins.
  • Do an apt-get install pluto-dcegen, and run: /usr/pluto/bin/DCEGen -d [device template] from the bin directory where your sources are (cd /home/sources/trunk/src/bin for example).
  • In Games_Plugin.h add an ! after the //<-dceag-decl-b-> line so that block of auto-gen'd code won't get overriden, and co-derive the class from , public DataGridGeneratorPlugIn like climate plugin.
  • Add the member:
class Datagrid_Plugin *m_pDatagrid_Plugin;

and a function for your data grid:

class DataGridTable *ClimateScenariosGrid(string GridID,string Parms,void *ExtraData,int *iPK_Variable,string *sValue_To_Assign,class Message *pMessage);
  • Add the code that initializes the datagrid engine like in climate plugin:
m_pDatagrid_Plugin=( Datagrid_Plugin * ) m_pRouter->FindPluginByTemplate(DEVICETEMPLATE_Datagrid_Plugin_CONST);
if( !m_pDatagrid_Plugin )
{
	LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"Cannot find sister plugins to climate plugin");
	return false;
}

m_pDatagrid_Plugin->RegisterDatagridGenerator(
	new DataGridGeneratorCallBack(this,(DCEDataGridGeneratorFn)(&Climate_Plugin::ClimateScenariosGrid))
	,DATAGRID_Climate_Scenarios_CONST,PK_DeviceTemplate_get());
  • Add a record in the pluto_main.DataGrid table for your new datagrid, and edit pluto_main/Define_DataGrid.h to add your new record, and change the RegisterDataGrid to use your function for the datagrid and your DATAGRID_X_CONST.
  • In Designer add a new DesignObj for the screen that will display your datagrid. Use one of the other screens as a template. To see what screens are being used, edit /etc/pluto.conf, comment out the LogLevels line, do:
/usr/pluto/bin/MessageSend dcerouter 0 -1000 7 11

to force all devices to recheck the log levels and start logging verbosely. Watch the log:

tail -f /var/log/pluto/20_LaunchOrbiter.log | grep Goto_DesignObj

Then as you change screens in Orbiter you can see what designobj's are being used. Note that Designer is nasty, unfriendly, and finicky. Sorry, this really needs work, but has been neglected since it's an in-house tool.

  • When you add the new design obj of type datagrid, add your new data grid id.
  • Add to the pluto_main.Screen table a record for this new screen and set the 'autoinclude' field to 1 for now so that screen will be generated even though nothing calls it. Then add to Screen_DesignObj a record associating this screen with your new DesignObj.
  • In the admin site, add an instance of your game plugin under DCERouter (next to the other plugins).
  • Go into the admin site and under Advanced, Configuration, Scenarios, add a scenario with a command going to "the local orbiter" "Goto Screen" with our new screen as the parameter for PK_Screen.

Now, after you reload the router and regen the Orbiter's UI, then when the user navigates to your screen by choosing the scenario you created, it will call that data grid generator function, and you can populate the grid with data like in Climate_Plugin::ClimateScenariosGrid and it will appear.