Пример #1
0
void CWaterPoolEditor::OnRenamePool() 
{
	CChoosePoolID cpi(true);
	cpi.PoolID = getCurrentPoolID();
	cpi.Name   = getCurrentPool().getName();
	if (cpi.DoModal() == IDOK)
	{
		getCurrentPool().setName(cpi.Name);
		fillPoolList();		
	}	
}
Пример #2
0
void CWaterPoolEditor::updateWaveControls()
{
	const NL3D::CWaterHeightMap &whm  = getCurrentPool();
	m_AutomaticWavesGeneration = whm.areWavesEnabled();
	m_BordersOnly  = whm.getBorderWaves();
	UpdateData(FALSE);
}
Пример #3
0
void Ref::release()
{
    CCASSERT(_referenceCount > 0, "reference count should be greater than 0");
    --_referenceCount;

#if CC_ENABLE_SCRIPT_BINDING && CC_ENABLE_GC_FOR_NATIVE_OBJECTS
    if (_scriptOwned && _rooted && _referenceCount==/*_referenceCountAtRootTime*/ 1)
    {
        auto scriptMgr = ScriptEngineManager::getInstance()->getScriptEngine();
        if (scriptMgr && scriptMgr->getScriptType() == kScriptTypeJavascript)
        {
            scriptMgr->unrootObject(this);
        }
    }
#endif // CC_ENABLE_SCRIPT_BINDING

    if (_referenceCount == 0)
    {
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
        auto poolManager = PoolManager::getInstance();
        if (!poolManager->getCurrentPool()->isClearing() && poolManager->isObjectInPools(this))
        {
            // Trigger an assert if the reference count is 0 but the Ref is still in autorelease pool.
            // This happens when 'autorelease/release' were not used in pairs with 'new/retain'.
            //
            // Wrong usage (1):
            //
            // auto obj = Node::create();   // Ref = 1, but it's an autorelease Ref which means it was in the autorelease pool.
            // obj->autorelease();   // Wrong: If you wish to invoke autorelease several times, you should retain `obj` first.
            //
            // Wrong usage (2):
            //
            // auto obj = Node::create();
            // obj->release();   // Wrong: obj is an autorelease Ref, it will be released when clearing current pool.
            //
            // Correct usage (1):
            //
            // auto obj = Node::create();
            //                     |-   new Node();     // `new` is the pair of the `autorelease` of next line
            //                     |-   autorelease();  // The pair of `new Node`.
            //
            // obj->retain();
            // obj->autorelease();  // This `autorelease` is the pair of `retain` of previous line.
            //
            // Correct usage (2):
            //
            // auto obj = Node::create();
            // obj->retain();
            // obj->release();   // This `release` is the pair of `retain` of previous line.
            CCASSERT(false, "The reference shouldn't be 0 because it is still in autorelease pool.");
        }
#endif

#if CC_REF_LEAK_DETECTION
        untrackRef(this);
#endif
        delete this;
    }
}
Пример #4
0
//===================================================================
void CWaterPoolEditor::OnSelchangeMapSize() 
{
	UpdateData();
	static const uint size[] = { 16, 32, 64, 128, 256, 512 };
	const uint tabSize = sizeof(size) / sizeof(uint);
	nlassert(m_MapSize < tabSize);
	getCurrentPool().setSize(size[m_MapSize]);		
}
Пример #5
0
void CWaterPoolEditor::updateWaveParams()
{
	bool enabled = getCurrentPool().areWavesEnabled();	
	_ImpulsionStrenghtDlg->EnableWindow(enabled);
	_WavePeriodDlg->EnableWindow(enabled);
	_WaveImpulsionRadiusDlg->EnableWindow(enabled);
	GetDlgItem(IDC_BORDERS_ONLY)->EnableWindow(enabled);
}
Пример #6
0
//===================================================================
void CWaterPoolEditor::updateWrappers()
{		
	NL3D::CWaterHeightMap *whm  = &getCurrentPool();
	_DampingWrapper.Whm			= whm;
	_FilterWeightWrapper.Whm    = whm;
	_WaterUnitSizeWrapper.Whm   = whm;
	_ImpulsionStrenghtWrapper.Whm   = whm;
	_WavePeriodWrapper.Whm = whm;
	_WaveImpulsionRadiusWrapper.Whm = whm;	
	_PropagationTimeWrapper.Whm = whm;	

}
Пример #7
0
void Ref::release()
{
    CCASSERT(_referenceCount > 0, "reference count should greater than 0");
    --_referenceCount;

    if (_referenceCount == 0)
    {
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
        auto poolManager = PoolManager::getInstance();
        if (!poolManager->getCurrentPool()->isClearing() && poolManager->isObjectInPools(this))
        {
            // Trigger an assert if the reference count is 0 but the Ref is still in autorelease pool.
            // This happens when 'autorelease/release' were not used in pairs with 'new/retain'.
            //
            // Wrong usage (1):
            //
            // auto obj = Node::create();   // Ref = 1, but it's an autorelease Ref which means it was in the autorelease pool.
            // obj->autorelease();   // Wrong: If you wish to invoke autorelease several times, you should retain `obj` first.
            //
            // Wrong usage (2):
            //
            // auto obj = Node::create();
            // obj->release();   // Wrong: obj is an autorelease Ref, it will be released when clearing current pool.
            //
            // Correct usage (1):
            //
            // auto obj = Node::create();
            //                     |-   new Node();     // `new` is the pair of the `autorelease` of next line
            //                     |-   autorelease();  // The pair of `new Node`.
            //
            // obj->retain();
            // obj->autorelease();  // This `autorelease` is the pair of `retain` of previous line.
            //
            // Correct usage (2):
            //
            // auto obj = Node::create();
            // obj->retain();
            // obj->release();   // This `release` is the pair of `retain` of previous line.
            CCASSERT(false, "The reference shouldn't be 0 because it is still in autorelease pool.");
        }
#endif

#if CC_USE_MEM_LEAK_DETECTION
        untrackRef(this);
#endif
        delete this;
    }
}
Пример #8
0
//===================================================================
void CWaterPoolEditor::updateMapSizeCtrl()
{	
	switch(getCurrentPool().getSize())
	{
		case 16: m_MapSize = 0; break;
		case 32: m_MapSize = 1; break;
		case 64: m_MapSize = 2; break;
		case 128: m_MapSize = 3; break;
		case 256: m_MapSize = 4; break;
		case 512: m_MapSize = 5; break;
		default:
			nlassert(0);
		break;
	}
	UpdateData(FALSE);
}
Пример #9
0
void CWaterPoolEditor::OnBordersOnly() 
{
	UpdateData();;
	NL3D::CWaterHeightMap &whm = getCurrentPool();
	whm.setWaves(whm.getWaveIntensity(), whm.getWavePeriod(), whm.getWaveImpulsionRadius(), m_BordersOnly ? true : false /* VC++ Warning */); 
}
Пример #10
0
void CWaterPoolEditor::OnAutomaticWavesGeneration() 
{
	UpdateData();
	getCurrentPool().enableWaves(m_AutomaticWavesGeneration ? true : false /* VC++ warning */); 
	updateWaveParams();	
}
Пример #11
0
Cache::Cache() : _pool(getCurrentPool()) { }