void CSDLStateHandler::Think( const int& iElapsedTime )
{
	while ( iDelayedPop > 0 && m_vpLayers.size() > 0 )
	{
		PopLayer();
		--iDelayedPop;
	}
	iDelayedPop = 0;

	while ( m_vpPopLayers.size() > 0 ) {
		for ( unsigned int i = 0; i < m_vpLayers.size(); ++i ) {
			if ( m_vpLayers[i] == m_vpPopLayers.back() ) {
				m_vpLayers.erase( m_vpLayers.begin() + i ); // erase the i'th element
				m_vpPopLayers.pop_back();
				break;
			}
		}
	}
	
	if ( bNewLayerNextFrame ) {
		CSDLObjectQueueList* pNewLayer = m_vpLayers.back();
		m_vpLayers.pop_back();
		NewLayer( pNewLayer );
		bNewLayerNextFrame = false;
	}
	
	Validate();
	if ( m_vpLayers.size() > 0 ) {
		m_vpLayers.back()->Think( iElapsedTime );
	}
}
Example #2
0
void Context::DropAllLayers()
{
	for (std::vector<Layer*>::iterator i = m_layers.begin(); i != m_layers.end(); ++i)
		RemoveWidget(*i);
	m_layers.clear();
	NewLayer();
	m_needsLayout = true;
}
Example #3
0
Context::Context(LuaManager *lua, Graphics::Renderer *renderer, int width, int height, const std::string &lang) : Container(this),
	m_renderer(renderer),
	m_width(width),
	m_height(height),
	m_scale(std::min(float(m_height)/SCALE_CUTOFF_HEIGHT, 1.0f)),
	m_needsLayout(false),
	m_eventDispatcher(this),
	m_skin("ui/Skin.ini", renderer, GetScale()),
	m_lua(lua)
{
	lua_State *l = m_lua->GetLuaState();
	lua_newtable(l);
	m_templateStore = LuaRef(l, -1);

	SetSize(Point(m_width,m_height));
	m_visible = true;

	NewLayer();

	// XXX should do point sizes, but we need display DPI first
	// XXX TextureFont could load multiple sizes into the same object/atlas
	{
		const Text::FontDescriptor baseFontDesc(Text::FontDescriptor::Load(FileSystem::gameDataFiles, "fonts/UIFont.ini", lang));
		for (int i = FONT_SMALLEST; i <= FONT_LARGEST; i++) {
			const Text::FontDescriptor fontDesc(baseFontDesc.filename, baseFontDesc.pixelWidth*FONT_SCALE[i]*GetScale(), baseFontDesc.pixelHeight*FONT_SCALE[i]*GetScale(), baseFontDesc.outline, baseFontDesc.advanceXAdjustment);

			m_font[i] = RefCountedPtr<Text::TextureFont>(new Text::TextureFont(fontDesc, renderer));
		}
	}
	{
		const Text::FontDescriptor baseFontDesc(Text::FontDescriptor::Load(FileSystem::gameDataFiles, "fonts/UIHeadingFont.ini", lang));
		for (int i = FONT_HEADING_SMALLEST; i <= FONT_HEADING_LARGEST; i++) {
			const Text::FontDescriptor fontDesc(baseFontDesc.filename, baseFontDesc.pixelWidth*FONT_SCALE[i]*GetScale(), baseFontDesc.pixelHeight*FONT_SCALE[i]*GetScale(), baseFontDesc.outline, baseFontDesc.advanceXAdjustment);

			m_font[i] = RefCountedPtr<Text::TextureFont>(new Text::TextureFont(fontDesc, renderer));
		}
	}
	{
		const Text::FontDescriptor baseFontDesc(Text::FontDescriptor::Load(FileSystem::gameDataFiles, "fonts/UIMonoFont.ini", lang));
		for (int i = FONT_MONO_SMALLEST; i <= FONT_MONO_LARGEST; i++) {
			const Text::FontDescriptor fontDesc(baseFontDesc.filename, baseFontDesc.pixelWidth*FONT_SCALE[i]*GetScale(), baseFontDesc.pixelHeight*FONT_SCALE[i]*GetScale(), baseFontDesc.outline, baseFontDesc.advanceXAdjustment);

			m_font[i] = RefCountedPtr<Text::TextureFont>(new Text::TextureFont(fontDesc, renderer));
		}
	}

	m_scissorStack.push(std::make_pair(Point(0,0), Point(m_width,m_height)));
}
Example #4
0
Context::Context(LuaManager *lua, Graphics::Renderer *renderer, int width, int height) : Container(this),
	m_renderer(renderer),
	m_width(width),
	m_height(height),
	m_scale(std::min(float(m_height)/SCALE_CUTOFF_HEIGHT, 1.0f)),
	m_needsLayout(false),
	m_mousePointer(nullptr),
	m_mousePointerEnabled(true),
	m_eventDispatcher(this),
	m_skin("ui/Skin.ini", renderer, GetScale()),
	m_lua(lua)
{
	lua_State *l = m_lua->GetLuaState();
	lua_newtable(l);
	m_templateStore = LuaRef(l, -1);

	SetSize(Point(m_width,m_height));
	m_visible = true;

	NewLayer();

	// XXX should do point sizes, but we need display DPI first
	// XXX TextureFont could load multiple sizes into the same object/atlas

	{
	const Text::FontConfig config("UIFont");
	for (int i = FONT_SMALLEST; i <= FONT_LARGEST; i++)
		m_font[i] = RefCountedPtr<Text::TextureFont>(new Text::TextureFont(config, renderer, FONT_SCALE[i]*GetScale()));
	}

	{
	const Text::FontConfig config("UIHeadingFont");
	for (int i = FONT_HEADING_SMALLEST; i <= FONT_HEADING_LARGEST; i++)
		m_font[i] = RefCountedPtr<Text::TextureFont>(new Text::TextureFont(config, renderer, FONT_SCALE[i]*GetScale()));
	}

	{
	const Text::FontConfig config("UIMonoFont");
	for (int i = FONT_MONO_SMALLEST; i <= FONT_MONO_LARGEST; i++)
		m_font[i] = RefCountedPtr<Text::TextureFont>(new Text::TextureFont(config, renderer, FONT_SCALE[i]*GetScale()));
	}

	m_scissorStack.push(std::make_pair(Point(0,0), Point(m_width,m_height)));
}