====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
plugin_sdk:simple_sample [2014/12/16 10:44]
playclaw created
plugin_sdk:simple_sample [2015/08/20 13:18] (current)
playclaw
Line 1: Line 1:
 +====== Simple plugin ======
 +
 +
 All defines and exports from PlayClaw are provided in supplied file //​plugins_shared.h//​ All defines and exports from PlayClaw are provided in supplied file //​plugins_shared.h//​
 <sxh cpp; title: plugins_shared.h>​ <sxh cpp; title: plugins_shared.h>​
Line 14: Line 17:
  // store unique plugin id (we will need it for some functions)  // store unique plugin id (we will need it for some functions)
  m_dwPluginID = dwPluginID;​   m_dwPluginID = dwPluginID;​
- 
- // here you can set default values for common or your own unique variables 
- PC_SetPluginVar(dwPluginID,​ OVR_VAR_SIZE_X,​ 64); 
- PC_SetPluginVar(dwPluginID,​ OVR_VAR_SIZE_Y,​ 64); 
- PC_SetPluginVar(dwPluginID,​ "​my_variable",​ 100500); 
  
  // additional init  // additional init
Line 36: Line 34:
  
 Also you need to statically link to playclaw export library (provided with SDK sources). Also you need to statically link to playclaw export library (provided with SDK sources).
 +
 +If your plugin has its own variables, you need to export two methods:
 +<sxh cpp; title: plugin sample code>
 +// here you can set default values for common or your own unique variables
 +PLUGIN_EXPORT void PluginSetDefaultVars()
 +{
 + PC_SetPluginVar(dwPluginID,​ OVR_VAR_SIZE_X,​ 64);
 + PC_SetPluginVar(dwPluginID,​ OVR_VAR_SIZE_Y,​ 64);
 + PC_SetPluginVar(dwPluginID,​ "​my_variable",​ 100500);
 +}
 +
 +// Update variables (after profile loading for example)
 +PLUGIN_EXPORT void PluginUpdateVars()
 +{
 + my_var = PC_GetPluginVarInt(m_dwPluginID,​ "​my_variable"​);​
 +}
 +</​sxh>​
 +PlayClaw calls PluginSetDefaultVars before profile loading to set defaults and then, after profile loading it calls PluginUpdateVars to inform plugin that it can "​cache"​ variables in its own memory (for fast processing, etc). Also this PluginUpdateVars method can be called after any variables change.
  
 If you need to delete/​close something on plugin shutdown, use this export: If you need to delete/​close something on plugin shutdown, use this export:
Line 107: Line 123:
  
  
-If you do not like GDI+ or our helper class, then you can create your own renderer. Only two [[playclaw_imports|imports from PlayClaw]] are important for this.+If you do not like GDI+ or our helper class, then you can create your own renderer. Only two [[plugin_sdk:​imports:​start|imports from PlayClaw]] are important for this.