Difference between revisions of "VESSEL2::clbkSetClassCaps"

From OrbiterWiki
Jump to navigation Jump to search
(Added category.)
 
(One intermediate revision by one other user not shown)
Line 15: Line 15:
 
{
 
{
 
this->SetEnableFocus(false);
 
this->SetEnableFocus(false);
char* pLine;
+
 
while(oapiReadScenario_nextline(cfg, pLine))
+
double dfTemp = 0.0;
 +
 
 +
char pszBuffer[80];
 +
 
 +
if(oapiReadItem_float(cfg, "LifeTime", dfTemp))
 +
{
 +
fRemainingLifeTime = dfTemp;
 +
}
 +
 
 +
if(oapiReadItem_float(cfg, "MaxCamDistance", dfTemp))
 +
{
 +
fMaxCameraDistance = dfTemp;
 +
}
 +
 
 +
if(oapiReadItem_string(cfg, "Subtype", pszBuffer))
 
{
 
{
if(!strnicmp(pLine, "LifeTime", 8))
+
if(!strnicmp(pszBuffer, "flare", 5))
 
{
 
{
char* pLine2 = pLine + 8;
 
while(*pLine2 != '=' && *pLine2 != '\0')
 
{
 
pLine2++;
 
}
 
if(*pLine2 != '\0')
 
{
 
pLine2++;
 
sscanf(pLine2, "%lf", &fRemainingLifeTime);
 
}
 
 
 
}
 
}
else if(!strnicmp(pLine, "MaxCamDistance", 14))
+
else if(!strnicmp(pszBuffer, "sflare", 6))
 
{
 
{
char* pLine2 = pLine + 14;
+
subtype = MTYPE_SFLARE;
while(*pLine2 != '=' && *pLine2 != '\0')
+
}
{
+
}
pLine2++;
 
}
 
if(*pLine2 != '\0')
 
{
 
pLine2++;
 
sscanf(pLine2, "%lf", &fMaxCameraDistance);
 
}
 
  
}
+
switch(subtype)
 +
{
 +
case MTYPE_SFLARE:
 +
CreateAsSFlare();
 +
break;
 
}
 
}
 
}
 
}
Line 54: Line 54:
 
*[[Vessel module sequence diagram]]
 
*[[Vessel module sequence diagram]]
 
*[[VESSEL2]]
 
*[[VESSEL2]]
 +
*[[oapiReadItem_x]]
  
 
{{VESSEL2}}
 
{{VESSEL2}}
 +
[[Category: Articles]]
 
[[Category:OrbiterSDK|VESSEL2::clbkSetClassCaps]]
 
[[Category:OrbiterSDK|VESSEL2::clbkSetClassCaps]]
 
[[Category:VESSEL2|clbkSetClassCaps]]
 
[[Category:VESSEL2|clbkSetClassCaps]]
 
[[Category:Callback functions]]
 
[[Category:Callback functions]]

Latest revision as of 12:08, 16 October 2022

Description[edit]

Callback function used for creating the basic vessel parameters. Each setting in this callback overrides the settings of the configuration file. Use this function for creating the physical properties of a vessel.

Syntax[edit]

virtual void clbkSetClassCaps(FILEHANDLE cfg);

cfg
File handle for reading custom parameters out of the configuration file. This file handle can be used in the same way as in ovcSetClassCaps, ovcLoadStateEx, ovcLoadState, clbkLoadStateEx

Example code[edit]

void MAYFLY::clbkSetClassCaps(FILEHANDLE cfg)
{
	this->SetEnableFocus(false);

	double dfTemp = 0.0;

	char pszBuffer[80];

	if(oapiReadItem_float(cfg, "LifeTime", dfTemp))
	{
		fRemainingLifeTime = dfTemp;
	}

	if(oapiReadItem_float(cfg, "MaxCamDistance", dfTemp))
	{
		fMaxCameraDistance = dfTemp;
	}

	if(oapiReadItem_string(cfg, "Subtype", pszBuffer))
	{
		if(!strnicmp(pszBuffer, "flare", 5))
		{
		}
		else if(!strnicmp(pszBuffer, "sflare", 6))
		{
			subtype = MTYPE_SFLARE;
		}
	}

	switch(subtype)
	{
	case MTYPE_SFLARE:
		CreateAsSFlare();
		break;
	}
}

See also[edit]

Callback functions in VESSEL2

edit

clbkADCtrlMode - clbkAnimate - clbkConsumeBufferedKey - clbkConsumeDirectKey - clbkDockEvent - clbkDrawHUD - clbkHUDMode - clbkLoadGenericCockpit - clbkLoadPanel - clbkLoadStateEx - clbkLoadVC - clbkMFDMode - clbkNavMode - clbkPanelMouseEvent - clbkPanelRedrawEvent - clbkPostCreation - clbkPostStep - clbkPreStep - clbkRCSMode - clbkSaveState - clbkSetClassCaps - clbkSetStateEx - clbkVCMouseEvent - clbkVCRedrawEvent - clbkVisualCreated - clbkVisualDestroyed