示例#1
0
bool ETHRenderEntity::DrawHalo(const float maxHeight, const float minHeight, const bool rotateHalo, const Vector2 &zAxisDirection)
{
	GS2D_UNUSED_ARGUMENT(minHeight);
	GS2D_UNUSED_ARGUMENT(maxHeight);

	if (!GetHalo() || !HasLightSource() || IsHidden())
		return false;

	m_pHalo->SetOrigin(Sprite::EO_CENTER);
	const ETHLight* light = m_properties.light.get();

	const Vector3 v3EntityPos = GetPosition();

	// will remain as 1.0 for a while
	m_provider->GetVideo()->SetSpriteDepth(1.0f/*ETHGlobal::ComputeDepth(m_data.entity.light.pos.z+v3EntityPos.z+ETH_HALO_DEPTH_SHIFT, maxHeight, minHeight)*/);

	// if it has a particle system in the first slot, adjust the light
	// brightness according to the number of active particles
	float brightness = 1.0f;
	const ETHParticleManagerPtr paticleManager = GetParticleManager(0);
	if (paticleManager)
	{
		brightness = static_cast<float>(paticleManager->GetNumActiveParticles())/static_cast<float>(paticleManager->GetNumParticles());
	}

	Vector3 v3HaloPos = light->pos + v3EntityPos;

	Color dwColor = ConvertToDW(light->color * light->haloBrightness * brightness);
	Vector2 v2Size(light->haloSize, light->haloSize);

	m_pHalo->DrawShaped(
		ETHGlobal::ToScreenPos(v3HaloPos, zAxisDirection) + ComputeParallaxOffset(),
		v2Size * m_properties.scale,
		dwColor, dwColor, dwColor, dwColor,
		(rotateHalo) ? ComputeHaloAngle() : 0.0f);
	return true;
}
示例#2
0
BOOL CfEventSetting::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	//
	//          Nest Splitter ->*
	// ------------------------ * -----------------------
	// |                       |*                        |
	// |                       |*                        |
	// | CvEventSettingLeft    |* CvEventSettingRight    |
	// |                       |*                        |
	// ------------------------ *------------------------ 
	// *************************************************** <-- Main Splitter
	//
	// List of Event category View (CvEventSettingBottom)
	//

	ASSERT (m_pEventSettingDoc);
	if (!m_pEventSettingDoc)
	{
		TRACE0 ("Main document is NULL while creating CfEventSetting\n");
		return FALSE;
	}
	CCreateContext context1, context2, context3;
	CRuntimeClass* pView1 = RUNTIME_CLASS(CvEventSettingLeft);
	CRuntimeClass* pView2 = RUNTIME_CLASS(CvEventSettingRight);
	CRuntimeClass* pView3 = RUNTIME_CLASS(CvEventSettingBottom);
	
	context1.m_pNewViewClass = pView1;
	context1.m_pCurrentDoc   = m_pEventSettingDoc;
	context2.m_pNewViewClass = pView2;
	context2.m_pCurrentDoc   = context1.m_pCurrentDoc;
	context3.m_pNewViewClass = pView3;
	context3.m_pCurrentDoc   = context1.m_pCurrentDoc;
	CRect r;
	GetClientRect (r);
	CSize v1Size ((int)(r.Width()/2), (int)(r.Height()*0.6));
	CSize v2Size ((int)(r.Width()/2), (int)(r.Height()*0.6));
	CSize v3Size (r.Width(), (int)(r.Height()*0.4));
	//
	// Create a main splitter of 2 rows and 1 column.
	//
	if (!m_MainSplitterWnd.CreateStatic (this, 2, 1))
	{
		TRACE0 ("CfEventSetting::OnCreateClient: Failed to create Splitter\n");
		return FALSE;
	}
	//
	// Create a nested splitter which has 1 row and 2 columns.
	// It is child of the second pane of the main splitter.
	BOOL b = m_NestSplitterWnd.CreateStatic (
		&m_MainSplitterWnd, // Parent is the main splitter.
		1,                  // 1 row.
		2,                  // 2 columns.
		WS_CHILD|WS_VISIBLE|WS_BORDER,  m_MainSplitterWnd.IdFromRowCol (0, 0));
	if (!b)
	{
		TRACE0 ("CfEventSetting::OnCreateClient: Failed to create Nested Splitter\n");
		return FALSE;
	}
	//
	// Add the first splitter pane of a nested splitter - the view (CvEventSettingLeft) in row 0 column 0
	// of the main splitter.
	//
	if (!m_NestSplitterWnd.CreateView (0, 0, pView1, v1Size, &context1))
	{
		TRACE0 ("CfEventSetting::OnCreateClient: Failed to create first pane\n");
		return FALSE;
	}
	//
	// Add the first splitter pane of the Nested Splitter -
	// the View (CvEventSettingLeft) in Row 0 col 1
	if (!m_NestSplitterWnd.CreateView (0, 1, pView2, v2Size, &context2))
	{
		TRACE0 ("CfEventSetting::OnCreateClient: Failed to create second pane\n");
		return FALSE;
	}
	//
	// Add the second splitter pane of the main Splitter - 
	// the View (CvEventSettingBottom) in  row 1 column 0
	if (!m_MainSplitterWnd.CreateView (1, 0, pView3, v3Size, &context3))
	{
		TRACE0 ("CfEventSetting::OnCreateClient: Failed to create first pane\n");
		return FALSE;
	}


	m_MainSplitterWnd.SetRowInfo    (0, v1Size.cy, 10);
	m_MainSplitterWnd.SetRowInfo    (1, v3Size.cy, 10);
	m_MainSplitterWnd.RecalcLayout();
	m_NestSplitterWnd.RecalcLayout();
	m_bAllViewCreated = TRUE;
	SetActiveView ((CView*)m_NestSplitterWnd.GetPane(0, 0));
	return TRUE;

	return TRUE;
}
示例#3
0
bool ETHScene::GenerateLightmaps(const int id)
{
	if (!m_provider->IsRichLightingEnabled())
	{
		return false;
	}

	// save current global scale and temporarily set it to 1
	const ETHGlobalScaleManagerPtr& scaleManager = m_provider->GetGlobalScaleManager();
	const float globalScale = scaleManager->GetScale();
	scaleManager->SetScaleFactor(1.0f);

	const ETHSpriteEntity *pRender = (id >= 0) ? m_buckets.SeekEntity(id) : 0;
	const Vector2 v2Bucket = (pRender) ? ETHBucketManager::GetBucket(pRender->GetPositionXY(), GetBucketSize()) : Vector2(0,0);

	for (ETHBucketMap::iterator bucketIter = m_buckets.GetFirstBucket(); bucketIter != m_buckets.GetLastBucket(); ++bucketIter)
	{
		// if we're lighting only one entity and it is not in this bucket, skip it.
		// I know we could have used the find method to go directly to that bucket
		// but this function os not that critical to make the effort worth it.
		if (id >= 0) 
			if (v2Bucket != bucketIter->first)
				continue;

		// iterate over all entities in this bucket
		ETHEntityList& entityList = bucketIter->second;
		ETHEntityList::const_iterator iEnd = entityList.end();
		for (ETHEntityList::iterator iter = entityList.begin(); iter != iEnd; ++iter)
		{
			ETHRenderEntity* entity = (*iter);
			// if nID is valid, let's try to generate the lightmap for this one and only entity
			if (id >= 0)
				if (id != entity->GetID())
					continue;

			Vector2 v2Size(1,1);
			Vector2 v2AbsoluteOrigin(0,0);
			if (entity->GetSprite())
			{
				v2Size = entity->GetCurrentSize();
				v2AbsoluteOrigin = entity->ComputeAbsoluteOrigin(v2Size);
			}

			// Place the current entity at the top-left corner to align
			// it to the render target
			const Vector3 oldPos = entity->GetPosition();
			const Vector3 newPos = Vector3(v2AbsoluteOrigin.x, v2AbsoluteOrigin.y, 0);

			std::list<ETHLight> lights;

			// fill the light list
			for (ETHBucketMap::iterator lbucketIter = m_buckets.GetFirstBucket(); lbucketIter != m_buckets.GetLastBucket(); ++lbucketIter)
			{
				ETHEntityList& lEntityList = lbucketIter->second;
				ETHEntityList::const_iterator liEnd = lEntityList.end();
				for (ETHEntityList::iterator liter = lEntityList.begin(); liter != liEnd; ++liter)
				{
					ETHRenderEntity* lightEntity = (*liter);
					if (lightEntity->IsStatic() && lightEntity->HasLightSource())
					{
						lights.push_back(
							ETHEntityRenderingManager::BuildChildLight(
								*(lightEntity->GetLight()),
								newPos - oldPos + lightEntity->GetPosition(),
								lightEntity->GetScale()));
					}
				}
			}

			if (lights.size() > 0)
			{
				ETHLightmapGen((*iter), m_provider->GetShaderManager(), lights.begin(), lights.end(),
					m_buckets, oldPos, newPos, m_minSceneHeight, m_maxSceneHeight, m_sceneProps);
			}
			else
			{
				entity->ReleaseLightmap();
			}

			entity->SetOrphanPosition(oldPos);
			lights.clear();
		}
	}
	#if defined(_DEBUG) || defined(DEBUG)
	ETH_STREAM_DECL(ss) << GS_L("Lightmaps created... ");
	m_provider->Log(ss.str(), Platform::FileLogger::INFO);
	#endif

	// go back to the previous global scale
	scaleManager->SetScaleFactor(globalScale);
	return true;
}
示例#4
0
int GSGUI_INT_INPUT::PlaceInput(Vector2 v2Pos)
{
	int r = 0;

	m_video->SetZBuffer(false);
	m_video->SetZWrite(false);

	Vector2 v2Size(m_width, m_size), v2TextAdd(m_size/4.0f, 0.0f);
	m_mouseOver = MouseOver(v2Pos, v2Size);
	Color top, bottom, text;

	if (m_active)
	{
		top = m_style.active_top;
		bottom = m_style.active_bottom;
		text = m_style.active_text;
		if (!m_mouseOver)
		{
			if (m_input->GetLeftClickState() == GSKS_HIT ||
				m_input->GetRightClickState() == GSKS_HIT)
				m_active = false;
		}
		if (m_input->GetKeyState(GSK_ENTER) == GSKS_HIT)
			m_active = false;
	}
	else
	{
		if (m_mouseOver)
		{
			if (m_input->GetLeftClickState() == GSKS_HIT)
				m_active = true;
			top = m_style.focused_top;
			bottom = m_style.focused_bottom;
			text = m_style.active_text;
		}
		else
		{
			top = m_style.inactive_top;
			bottom = m_style.inactive_bottom;
			text = m_style.inactive_text;
		}
		if (m_strInput.GetString() == GS_L(""))
			m_strInput.SetString(GS_L("0"));
	}

	m_video->DrawRectangle(v2Pos, Vector2(m_width, m_size),
							top, top,
							bottom, bottom);

	str_type::stringstream ss;
	ss << m_strInput.GetString();
	if (ss.str().length() > 0) //-V807
	{
		GS2D_SSCANF(ss.str().c_str(), GS_L("%i"), &r);
		if (m_active && m_input->GetWheelState() != 0.0f)
		{
			r += (int)m_input->GetWheelState()*m_scrollAdd;
			ss.str(GS_L(""));
			ss << r;
			m_strInput.SetString(ss.str());
		}

		GS2D_SSCANF(ss.str().c_str(), GS_L("%i"), &r);
		if (m_clamp)
		{
			if (r > m_max)
			{
				r = m_max;
				ss.str(GS_L(""));
				ss << r;
			} else
			if (r < m_min)
			{
				r = m_min;
				ss.str(GS_L(""));
				ss << r;
			}
			m_strInput.SetString(ss.str());
		}
	}
	if (m_active)
	{
		m_strInput.PlaceInput(v2Pos+v2TextAdd, GS_L("Verdana14_shadow.fnt"), m_nMaxChars, m_size, text, m_video, m_input);
	}
	else
	{
		m_strInput.Place(v2Pos+v2TextAdd, GS_L("Verdana14_shadow.fnt"), m_size, text, m_video);
	}

	if (m_active || m_mouseOver)
		DrawOutline(v2Pos, v2Size);

	return r;
}
示例#5
0
str_type::string GSGUI_STRING_LINE_INPUT::PlaceInput(Vector2 v2Pos)
{
	m_video->SetZBuffer(false);
	m_video->SetZWrite(false);

	Vector2 v2Size(m_width, m_size), v2TextAdd(m_size/4.0f, 0.0f);
	m_mouseOver = MouseOver(v2Pos, v2Size);
	Color top, bottom, text;

	// const Vector2i scissor = m_video->GetTextRect();
	// m_video->SetTextRect(Vector2i(int(GetWidth()-v2TextAdd.x), int(GetSize()-v2TextAdd.y)));

	if (m_active)
	{
		top = m_style.active_top;
		bottom = m_style.active_bottom;
		text = m_style.active_text;
		if (!m_mouseOver)
		{
			if (m_input->GetLeftClickState() == GSKS_HIT ||
				m_input->GetRightClickState() == GSKS_HIT)
				m_active = false;
		}
		if (m_input->GetKeyState(GSK_ENTER) == GSKS_HIT)
			m_active = false;
	}
	else
	{
		if (m_mouseOver)
		{
			if (m_input->GetLeftClickState() == GSKS_HIT)
				m_active = true;
			top = m_style.focused_top;
			bottom = m_style.focused_bottom;
			text = m_style.active_text;
		}
		else
		{
			top = m_style.inactive_top;
			bottom = m_style.inactive_bottom;
			text = m_style.inactive_text;
		}
		if (m_strInput.GetString() == GS_L(""))
			m_strInput.SetString(GS_L("0"));
	}

	m_video->DrawRectangle(v2Pos, Vector2(m_width, m_size),
							top, top,
							bottom, bottom);

	str_type::stringstream ss;
	ss << m_strInput.GetString();

	if (m_active)
	{
		m_strInput.PlaceInput(v2Pos+v2TextAdd, GS_L("Verdana14_shadow.fnt"), m_nMaxChars, m_size, text, m_video, m_input);
	}
	else
	{
		m_strInput.Place(v2Pos+v2TextAdd, GS_L("Verdana14_shadow.fnt"), m_size, text, m_video);
	}
	if (m_active || m_mouseOver)
		DrawOutline(v2Pos, v2Size);

	// m_video->SetTextRect(scissor);

	return m_strInput.GetString();
}
示例#6
0
float GSGUI_FLOAT_INPUT::PlaceInput(Vector2 v2Pos)
{
	m_lastValue = 0;

	m_video->SetZBuffer(false);
	m_video->SetZWrite(false);

	Vector2 v2Size(m_width, m_size), v2TextAdd(m_size/4.0f, 0.0f);
	m_mouseOver = MouseOver(v2Pos+Vector2(m_width, 0.0f), v2Size);
	Color top, bottom, text;

	m_video->DrawBitmapText(
		v2Pos + v2TextAdd, m_text.c_str(), 
		GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE
	);

	if (m_active)
	{
		top = m_style.active_top;
		bottom = m_style.active_bottom;
		text = m_style.active_text;
		if (!m_mouseOver)
		{
			if (m_input->GetLeftClickState() == GSKS_HIT ||
				m_input->GetRightClickState() == GSKS_HIT)
				m_active = false;
		}
		if (m_input->GetKeyState(GSK_ENTER) == GSKS_HIT)
			m_active = false;
	}
	else
	{
		if (m_mouseOver)
		{
			if (m_input->GetLeftClickState() == GSKS_HIT)
				m_active = true;
			top = m_style.focused_top;
			bottom = m_style.focused_bottom;
			text = m_style.active_text;
		}
		else
		{
			top = m_style.inactive_top;
			bottom = m_style.inactive_bottom;
			text = m_style.inactive_text;
		}
		if (m_strInput.GetString() == GS_L(""))
			m_strInput.SetString(GS_L("0.0"));
	}

	m_video->DrawRectangle(v2Pos+Vector2(m_width, 0.0f), Vector2(m_width, m_size),
							top, top, bottom, bottom);

	str_type::stringstream ss;
	ss.str(m_strInput.GetString());

	// if there are no chars, go back to the min value
	//const unsigned int nLen = ss.str().length(); //-V807

	if (m_strInput.GetString().length() > 0)
	{
		GS2D_SSCANF(ss.str().c_str(), GS_L("%f"), &m_lastValue);

		if (m_active && m_input->GetWheelState() != 0.0f)
		{
			m_lastValue += m_input->GetWheelState()*m_scrollAdd;
			ss.str(GS_L(""));
			ss << m_lastValue;
			m_strInput.SetString(ss.str());
		}

		GS2D_SSCANF(ss.str().c_str(), GS_L("%f"), &m_lastValue);
		if (m_clamp)
		{
			if (m_lastValue > m_max)
			{
				m_lastValue = m_max;
				ss.str(GS_L(""));
				ss << m_lastValue;
			} else
			if (m_lastValue < m_min)
			{
				m_lastValue = m_min;
				ss.str(GS_L(""));
				ss << m_lastValue;
			}
			m_strInput.SetString(ss.str());
		}
	}

	if (m_active)
	{
		m_strInput.PlaceInput(v2Pos+v2TextAdd+Vector2(m_width, 0.0f), GS_L("Verdana14_shadow.fnt"), m_nMaxChars, m_size, text, m_video, m_input);
	}
	else
	{
		m_strInput.Place(v2Pos+v2TextAdd+Vector2(m_width, 0.0f), GS_L("Verdana14_shadow.fnt"), m_size, text, m_video);
	}

	if (m_active || m_mouseOver)
		DrawOutline(v2Pos, v2Size+Vector2(m_width, 0.0f));

	return m_lastValue;
}
示例#7
0
bool ETHScene::GenerateLightmaps(const int id)
{
	const ETHSpriteEntity *pRender = (id >= 0) ? m_buckets.SeekEntity(id) : 0;
	const Vector2 v2Bucket = (pRender) ? ETHGlobal::GetBucket(pRender->GetPositionXY(), GetBucketSize()) : Vector2(0,0);

	for (ETHBucketMap::iterator bucketIter = m_buckets.GetFirstBucket(); bucketIter != m_buckets.GetLastBucket(); bucketIter++)
	{
		// if we're lighting only one entity and it is not in this bucket, skip it.
		// I know we could have used the find method to go directly to that bucket
		// but this function os not that critical to make the effort worth it.
		if (id >= 0)
			if (v2Bucket != bucketIter->first)
				continue;

		// iterate over all entities in this bucket
		ETHEntityList::const_iterator iEnd = bucketIter->second.end();
		for (ETHEntityList::iterator iter = bucketIter->second.begin(); iter != iEnd; iter++)
		{
			// if nID is valid, let's try to generate the lightmap for this one and only entity
			if (id >= 0)
				if (id != (*iter)->GetID())
					continue;

			Vector2 v2Size(1,1);
			Vector2 v2Origin(0,0);
			if ((*iter)->GetSprite())
			{
				v2Size = (*iter)->GetCurrentSize();
				v2Origin = (*iter)->ComputeOrigin(v2Size);
			}

			// Place the current entity at the top-left corner to align
			// it to the render target
			const Vector3 oldPos = (*iter)->GetPosition();
			const Vector3 newPos = Vector3(v2Origin.x, v2Origin.y, 0);

			// fill the light list
			for (ETHBucketMap::iterator lbucketIter = m_buckets.GetFirstBucket(); lbucketIter != m_buckets.GetLastBucket(); lbucketIter++)
			{
				ETHEntityList::const_iterator liEnd = lbucketIter->second.end();
				for (ETHEntityList::iterator liter = lbucketIter->second.begin(); liter != liEnd; liter++)
				{
					if ((*liter)->IsStatic() && (*liter)->HasLightSource())
					{
						AddLight(*((*liter)->GetLight()), newPos-oldPos+(*liter)->GetPosition());
					}
				}
			}

			ETHLightmapGen((*iter), m_provider->GetShaderManager(), m_lights.begin(), m_lights.end(),
							m_buckets, oldPos, newPos, m_minSceneHeight, m_maxSceneHeight, m_sceneProps);

			(*iter)->SetOrphanPosition(oldPos);
			m_lights.clear();
		}
	}
	#ifdef _DEBUG
	ETH_STREAM_DECL(ss) << GS_L("Lightmaps created... ");
	m_provider->Log(ss.str(), Platform::FileLogger::INFO);
	#endif
	return true;
}