本文整理汇总了C++中CCodeChainCtx::SetScreen方法的典型用法代码示例。如果您正苦于以下问题:C++ CCodeChainCtx::SetScreen方法的具体用法?C++ CCodeChainCtx::SetScreen怎么用?C++ CCodeChainCtx::SetScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCodeChainCtx
的用法示例。
在下文中一共展示了CCodeChainCtx::SetScreen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvalBool
bool IDockScreenDisplay::EvalBool (const CString &sCode, bool *retbResult, CString *retsError)
// EvalBool
//
// Evaluates the given string
{
CCodeChainCtx Ctx;
Ctx.SetScreen(m_pDockScreen);
Ctx.SaveAndDefineSourceVar(m_pLocation);
Ctx.SaveAndDefineDataVar(m_pData);
char *pPos = sCode.GetPointer();
ICCItem *pExp = Ctx.Link(sCode, 1, NULL);
ICCItem *pResult = Ctx.Run(pExp); // LATER:Event
Ctx.Discard(pExp);
if (pResult->IsError())
{
*retsError = pResult->GetStringValue();
Ctx.Discard(pResult);
return false;
}
*retbResult = !pResult->IsNil();
Ctx.Discard(pResult);
return true;
}
示例2: if
CSpaceObject *IDockScreenDisplay::EvalListSource (const CString &sString, CString *retsError)
// EvalListSource
//
// Returns the object from which we should display items
{
char *pPos = sString.GetPointer();
// See if we need to evaluate
if (*pPos == '=')
{
CCodeChainCtx Ctx;
Ctx.SetScreen(this);
Ctx.SaveAndDefineSourceVar(m_pLocation);
Ctx.SaveAndDefineDataVar(m_pData);
ICCItem *pExp = Ctx.Link(sString, 1, NULL);
ICCItem *pResult = Ctx.Run(pExp); // LATER:Event
Ctx.Discard(pExp);
if (pResult->IsError())
{
*retsError = pResult->GetStringValue();
Ctx.Discard(pResult);
return NULL;
}
// Convert to an object pointer
CSpaceObject *pSource;
if (strEquals(pResult->GetStringValue(), DATA_FROM_PLAYER))
pSource = m_pPlayer->GetShip();
else if (strEquals(pResult->GetStringValue(), DATA_FROM_STATION)
|| strEquals(pResult->GetStringValue(), DATA_FROM_SOURCE))
pSource = m_pLocation;
else
pSource = Ctx.AsSpaceObject(pResult);
Ctx.Discard(pResult);
return pSource;
}
// Otherwise, compare to constants
else if (strEquals(sString, DATA_FROM_PLAYER))
return m_pPlayer->GetShip();
else
return m_pLocation;
}
示例3: EvalString
bool IDockScreenDisplay::EvalString (const CString &sString, bool bPlain, ECodeChainEvents iEvent, CString *retsResult)
// EvalString
//
// Evaluates the given string.
{
CCodeChainCtx Ctx;
Ctx.SetEvent(iEvent);
Ctx.SetScreen(m_pDockScreen);
Ctx.SaveAndDefineSourceVar(m_pLocation);
Ctx.SaveAndDefineDataVar(m_pData);
return Ctx.RunEvalString(sString, bPlain, retsResult);
}
示例4: OnInitList
ALERROR CDockScreenCustomList::OnInitList (SInitCtx &Ctx, CString *retsError)
// OnInitList
//
// Initialize list
{
// Get the list element
CXMLElement *pListData = Ctx.pDesc->GetContentElementByTag(LIST_TAG);
if (pListData == NULL)
return ERR_FAIL;
// See if we define a custom row height
CString sRowHeight;
if (pListData->FindAttribute(ROW_HEIGHT_ATTRIB, &sRowHeight))
{
CString sResult;
if (!EvalString(sRowHeight, false, eventNone, &sResult))
{
*retsError = sResult;
return ERR_FAIL;
}
int cyRow = strToInt(sResult, -1);
if (cyRow > 0)
m_pItemListControl->SetRowHeight(cyRow);
}
// Get the list to show
CCodeChain &CC = g_pUniverse->GetCC();
ICCItem *pExp = CC.Link(pListData->GetContentText(0), 0, NULL);
// Evaluate the function
CCodeChainCtx CCCtx;
CCCtx.SetScreen(m_pDockScreen);
CCCtx.SaveAndDefineSourceVar(m_pLocation);
CCCtx.SaveAndDefineDataVar(m_pData);
ICCItem *pResult = CCCtx.Run(pExp); // LATER:Event
CCCtx.Discard(pExp);
if (pResult->IsError())
{
*retsError = pResult->GetStringValue();
return ERR_FAIL;
}
// Set this expression as the list
m_pItemListControl->SetList(CC, pResult);
CCCtx.Discard(pResult);
// Position the cursor on the next relevant item
SelectNextItem();
// Give the screen a chance to start at a different item (other
// than the first)
CString sInitialItemFunc = pListData->GetAttribute(INITIAL_ITEM_ATTRIB);
if (!sInitialItemFunc.IsBlank())
{
bool bMore = IsCurrentItemValid();
while (bMore)
{
bool bResult;
if (!EvalBool(sInitialItemFunc, &bResult, retsError))
return ERR_FAIL;
if (bResult)
break;
bMore = SelectNextItem();
}
}
return NOERROR;
}