本文整理汇总了C++中CharString函数的典型用法代码示例。如果您正苦于以下问题:C++ CharString函数的具体用法?C++ CharString怎么用?C++ CharString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CharString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: target
void VerbApplyEnhancement::onExecute()
{
NounShip * pShip = WidgetCast<NounShip>( target() );
if ( context()->isServer() && validate(pShip) && validate(m_pCargo) )
{
NounEnhancement::Ref pEnhancement = m_pCargo->enhancement();
if ( pEnhancement && pEnhancement->parent() == NULL && pEnhancement->canUse( pShip ) )
{
// this will attach the contained enhancement to the ship...
if ( pEnhancement->use( pShip ) )
{
// detach the cargo item now..
pShip->detachNode( m_pCargo );
pShip->privateChat( CharString().format( "<color;ffffff>Enhancement: Using <color;%6.6x>%s</color> on %s.",
pEnhancement->color().RGB(),pEnhancement->getName(), pShip->name() ) );
LOG_STATUS( "VerbApplyEnhancement", "[ENHANCEMENT]:Apply:%u:%s:%s",
pShip->userId(), pEnhancement->getName(),pShip->name() );
// save off storage with this "active" ship
context()->user()->saveStorage(pShip);
}
else
{
pShip->privateChat( CharString().format( "<color;ffffff>Enhancement: Failed to use enhancement <color;%6.6x>%s</color>.",
pEnhancement->color().RGB(), pEnhancement->getName() ) );
}
}
}
}
示例2: TRACE
void GameDocument::onShipCaptured( Noun * pCapper )
{
TRACE( "GameDocument::onShipCaptured" );
setGameState( GS_DEATH );
m_bShipLost = true;
// inform our script
CharString sSelf = ship()->key().string();
CharString sCapper = pCapper != NULL ? pCapper->key().string() : "";
context()->scriptCall( CharString().format("onCaptured( '%s''%s' )", sSelf, sCapper ) );
// reset the camera time
s_fCamera = 0.0f;
WindowObserve * pWindow = WidgetCast<WindowObserve>( InterfaceContext::findNode( "ObserveWindow" ) );
if ( pWindow != NULL )
{
pWindow->setCameraMode( WindowObserve::CHASE );
pWindow->setTargetMode( WindowObserve::LOCKED );
pWindow->setTarget( ship() );
}
WindowText * pMessage = WidgetCast<WindowText>( InterfaceContext::findNode( "TextMessage" ) );
if ( pMessage != NULL )
{
if ( pCapper != NULL )
pMessage->setText( CharString().format("Ship captured by %s...", pCapper->name()) );
else
pMessage->setText( "Ship captured..." );
}
}
示例3: calculateModifier
CharString GadgetBeamWeapon::useTip( Noun * pTarget, bool shift ) const
{
if ( shift )
return "Toggle Point Defense.";
// usage information
CharString tip;
float fEnergyMod = calculateModifier( MT_BEAM_ENERGY );
float fChargeScale = damageRatioInv() * fEnergyMod;
tip += CharString().format("\nRecharge Time: <X;100>%.1fs", energyCost() / ( ( energyCharge() * fChargeScale ) * TICKS_PER_SECOND ) );
tip += CharString().format("\nEnergy Cost:<X;100>%.1f", energyCost() / 1000.0f );
float fLength = length() * calculateModifier( MT_BEAM_RANGE );
tip += CharString().format("\nMax Range:<X;100>%.1fgu", fLength );
// direct damage
float fDamageMod = calculateModifier( MT_BEAM_DAMAGE );
float fDamage = damage() * fDamageMod;
if ( damageRandom() > 0 )
{
float fMaxDamage = fDamage + (damageRandom() * fDamageMod);
tip += CharString().format( "\nDamage:<X;100>%.0f-%.0f", fDamage * duration(), fMaxDamage * duration() );
}
else
tip += CharString().format( "\nDamage:<X;100>%.1f", fDamage * duration() );
return tip;
}
示例4: damageRatioInv
CharString GadgetDrive::useTip( Noun * pTarget, bool shift ) const
{
CharString tip;
// usage information
int generate = 0;
if ( active() )
{
generate = damageRatioInv() * this->energy();
// reduce energy based on velocity
NounShip * pShip = WidgetCast<NounShip>( parent() );
if ( pShip != NULL )
{
if ( energyFalloff() > 0 && pShip->maxVelocity() > 0.0f && pShip->velocity() > pShip->baseVelocity() )
{
float scale = ( pShip->velocity() - pShip->baseVelocity() ) / pShip->velocityRange();
generate -= ( energyFalloff() * scale) ;
}
}
}
tip += CharString().format("\nEnergy p/s:<X;100>%.1f", ( generate * TICKS_PER_SECOND ) / 1000.0f );
tip += CharString().format("\nEnergy Stored:<X;100>%.0f", maxEnergy() / 1000.0f );
return tip;
}
示例5: ASSERT
bool ButtonCargo::onCursorMove( const RectInt & window, const PointInt & position, const PointInt & delta )
{
if ( WindowButton::onCursorMove( window, position, delta ) )
{
GameDocument * pDoc = (GameDocument *)document();
ASSERT( pDoc );
NounShip * pShip = pDoc->ship();
if (! pShip )
return false;
Noun * pCargo = m_Cargo;
if (! pCargo )
return false;
pDoc->setLeftHint( CharString().format( "TARGET %s", pCargo->name() ) );
Noun * pTarget = pDoc->target();
if ( WidgetCast<CargoEnhancement>( pCargo )
&& VerbApplyEnhancement::canApply( (CargoEnhancement *)pCargo, pShip ) )
pDoc->setRightHint( CharString().format( "USE %s", pCargo->name() ) );
else if ( pTarget != NULL && pShip->canUnload( pTarget, pCargo ) )
pDoc->setRightHint( CharString().format( "UNLOAD %s ONTO %s", pCargo->name(), pTarget->name() ) );
else
pDoc->setRightHint( "" );
return true;
}
return false;
}
示例6: ERR_FAIL_COND_V
Error PaymentService::purchase(Variant p_params) {
Dictionary params = p_params;
ERR_FAIL_COND_V((!params.has("product_id")) && (!params.has("product_sku")), ERR_INVALID_PARAMETER);
char* id = NULL;
char* sku = NULL;
CharString p_id = params.has("product_id")?String(params["product_id"]).ascii():CharString();
CharString p_sku = params.has("product_sku")?String(params["product_sku"]).ascii():CharString();
unsigned int request_id;
chdir(launch_dir_ptr);
int ret = paymentservice_purchase_request(params.has("product_sku") ? NULL : p_id.get_data(),
params.has("product_sku") ? p_sku.get_data() : NULL,
NULL, NULL, NULL, NULL, get_window_group_id(), &request_id);
chdir("app/native");
if (ret != BPS_SUCCESS) {
int eret = errno;
printf("purchase error %i, %x, %i, %x\n", ret, ret, eret, eret);
ERR_FAIL_V((Error)eret);
return (Error)eret;
};
return OK;
};
示例7: CharString
CharString NounShip::status() const
{
CharString sTargetInfo;
// team & ship type..
sTargetInfo += CharString().format("%s - %s\n", teamName(), nounContext()->name() );
// hull %
sTargetInfo += CharString().format("Hull: %d%%\n", int( damageRatioInv() * 100) );
int armor = 0, maxArmor = 0;
int shield = 0, maxShield = 0;
for(int i=0;i<childCount();i++)
{
BaseNode * pChild = child(i);
if ( WidgetCast<GadgetShield>( pChild ) )
{
shield += ((GadgetShield *)pChild)->charge();
maxShield += ((GadgetShield *)pChild)->maxCharge();
}
else if ( WidgetCast<GadgetArmor>( pChild ) )
{
armor += ((GadgetArmor *)pChild)->armor();
maxArmor += ((GadgetArmor *)pChild)->maxArmor();
}
}
if ( maxShield > 0 )
sTargetInfo += CharString().format("Shield: %d%%\n", (shield * 100) / maxShield);
if ( maxArmor > 0 )
sTargetInfo += CharString().format("Armor: %d%%\n", (armor * 100) / maxArmor );
return sTargetInfo;
}
示例8: lock
bool ProcessServer::loadProcessList()
{
AutoLock lock( &m_Lock );
m_ProcessList.release();
Settings pf( "ProcessList", m_Context.processFile );
m_NextProcessId = pf.get( "NextProcessId", m_NextProcessId );
int nProcessCount = pf.get( "ProcessCount", (dword)0 );
for(int i=0;i<nProcessCount;i++)
{
Process process;
process.processId = pf.get( CharString().format("ProcessId%d", i), i + 1 );
process.name = pf.get( CharString().format("ProcessName%d", i), "" );
process.executable = pf.get( CharString().format("ProcessExe%d", i), "" );
process.arguments = pf.get( CharString().format("ProcessArg%d", i), "" );
process.config = pf.get( CharString().format("ProcessConfig%d", i), "" );
process.log = pf.get( CharString().format("ProcessLog%d", i), "" );
process.flags = (u16)pf.get( CharString().format("ProcessFlags%d", i), 0xffff );
if ( process.flags == 0xffff )
{
process.flags = 0;
if ( pf.get( CharString().format("ProcessRunning%d", i), (dword)0 ) != 0 )
process.flags |= ProcessClient::PF_RUNNING;
if ( pf.get( CharString().format("ProcessDisabled%d", i), (dword)1 ) != 0 )
process.flags |= ProcessClient::PF_DISABLED;
}
m_ProcessList.push( process );
}
return true;
}
示例9: GetSelectObj
void EEditorManager::onComponentAction ( QAction* action )
{
QString componentTypeName = action->text();
const QString& name = GetSelectObj();
EditorEvent editorevent;
editorevent.mType = action->isChecked() ? eEditorToScene_ComponentAttach
: eEditorToScene_ComponentDettach;
editorevent.mArgs.push_back ( CharString ( name.toStdString().c_str() ) );
editorevent.mArgs.push_back ( CharString ( componentTypeName.toStdString().c_str() ) );
Notify( editorevent );
}
示例10: CharString
CharString GadgetArmor::useTip( Noun * pTarget, bool shift ) const
{
CharString tip;
// usage information
tip += CharString().format("\nCurrent HP:<X;100>%d/%d", m_Armor, maxArmor() );
float fMod = ( calculateModifier( MT_DEFENSE ) * 100 ) - 100;
if ( fMod > 0 )
tip += CharString().format("\nDamage Reduction:<X;100>%.0f%%", fMod );
fMod = calculateModifier( MT_DEFENSE_RECHARGE );
return tip;
}
示例11: config
void JukeboxDS::saveConfig()
{
Settings config( ("Jukebox"), m_JukeboxConfig );
config.put( ("listCount"), m_PlayLists.size() );
for(int i=0;i<m_PlayLists.size();i++)
{
config.put( CharString().format(("List%dName"), i), m_PlayLists[i].name );
config.put( CharString().format(("List%dFileCount"), i ), m_PlayLists[i].files.size() );
for(int j=0;j<m_PlayLists[i].files.size();j++)
config.put( CharString().format(("List%dFile%d"), i, j), m_PlayLists[i].files[j] );
}
}
示例12: setTip
void ButtonCargo::onUpdate( float t )
{
WindowButton::onUpdate( t );
if ( enabled() )
{
Noun * pCargo = m_Cargo;
if (! pCargo )
return;
if ( WidgetCast<CargoEnhancement>( pCargo ) )
{
setTip(((CargoEnhancement *)pCargo)->status());
m_HotKey = 0;
return;
}
GameDocument * pDoc = (GameDocument *)document();
ASSERT( pDoc );
NounShip * pShip = pDoc->ship();
if (! pShip )
return;
bool validAction = false;
Noun * pTarget = pDoc->target();
if ( pTarget != NULL )
{
if ( pShip->canUnload( pTarget, pCargo ) )
{
setTip( CharString().format( "Unload %s onto %s",
pCargo->name(), pTarget->name() ) );
setIconColor( WHITE );
validAction = true;
m_HotKey = 'U';
}
}
if ( !validAction )
{
if ( WidgetCast<NounUnit>( pCargo ) )
setTip( CharString().format("%s %s", pCargo->name(), ((NounUnit *)pCargo)->status() ) );
else
setTip( pCargo->name() );
setIconColor( GREY );
m_HotKey = 0;
}
}
}
示例13: release
bool JukeboxDS::initialize( const char * pFilePath, int volume )
{
release();
// build the file list
m_FilePath = Path( pFilePath ).directory();
if (! m_FilePath.endsWith(("\\")) )
m_FilePath += ("\\");
m_JukeboxConfig = m_FilePath + ("config.ini");
// load the jukebox configuration if the file exists
if ( FileDisk::fileExists( m_JukeboxConfig ) )
{
Settings config( ("Jukebox"), m_JukeboxConfig );
int listCount = config.get( ("listCount"), (dword)0 );
for(int i=0;i<listCount;i++)
{
int newList = addPlayList( config.get( CharString().format( ("List%dName"), i ), ("") ) );
int fileCount = config.get( CharString().format(("List%dFileCount"), i ), (dword)0 );
for(int j=0;j<fileCount;j++)
addTrack( newList, config.get( CharString().format(("List%dFile%d"), i, j), ("")) );
}
}
else
{
// create a default playlist with all mp3 files in the directory
addTrack( addPlayList( ("Default") ), m_FilePath + ("*.mp3") );
// save configuration
//saveConfig();
}
if ( !m_PlayLists.isValid( 0 ) )
return false;
if ( !m_PlayLists[ 0 ].files.isValid( 0 ) )
return false;
m_ActiveList = 0;
m_CurrentTrack = 0;
m_Volume = Clamp( volume, 0, 100 );
// start the thread
play();
return true;
}
示例14: LOG_STATUS
void ProcessServer::onConnect( dword client )
{
LOG_STATUS( "ProcessServer", CharString().format("Connecting client %u from %s", client, clientAddress( client )) );
AutoLock lock( &m_Lock );
m_ClientValid[ client ] = false;
}
示例15: updateTip
void WindowButton::updateTip()
{
if ( m_HotKey != 0 )
updateTip( CharString().format("%s '%s'", m_Tip, keyText( Keyboard::unmap( m_HotKey ) ) ) );
else
updateTip( m_Tip );
}