Ejemplo n.º 1
0
void UIObject::Parse_UIObj_Script(UIObject* cur_root,std::istream &is, std::string &line) {
	while (Tim::String::get_line(is, line, true, true)) {
		if (line == "#create_end") {
			Parse_UIScript(is, line);//tell UIOBject to end parsing!!
			if(!get_parent()&&cur_root){
				cur_root->push_child(this);
			}
			break;
		} else if (line == "Parent:") {
			Tim::String::get_line(is, line, true, true);
			UIObject* parent = cur_root->get_child(line);
			if (parent) {
				parent->push_child(this);
			} else {
				std::cerr << "can't find UI's Parent:" << line << std::endl;
			}
		} else if (line == "Name:") {
			Tim::String::get_line(is, line, true, true);
			set_name(line);
		} else if (line == "Position:") {
			glm::vec2 tpos;
			is >> tpos.x;
			is >> tpos.y;
			set_relative_pos(tpos);
		}else if (line == "Set_receiver:") {
Ejemplo n.º 2
0
bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) {
    UIObject *obj = (UIObject *)param1;

    switch (obj->_type) {
    case UI_BUTTON:
        if (scumm_stricmp(obj->getName(), "prev") == 0) {
            _scrollOffset--;
        } else if (scumm_stricmp(obj->getName(), "next") == 0) {
            _scrollOffset++;
        } else if (scumm_stricmp(obj->getName(), "response") == 0) {
            if (_waitingScript) {
                _waitingScript->_stack->pushInt(_responses[param2]->getID());
            }
            handleResponse(_responses[param2]);
            _waitingScript = nullptr;
            _gameRef->_state = GAME_RUNNING;
            ((AdGame *)_gameRef)->_stateEx = GAME_NORMAL;
            _ready = true;
            invalidateButtons();
            clearResponses();
        } else {
            return BaseObject::listen(param1, param2);
        }
        break;
    default:
        error("AdResponseBox::Listen - Unhandled enum");
    }

    return STATUS_OK;
}
Ejemplo n.º 3
0
void UIScroller::Refresh(const float &fDeltaTime)
{
	vector<UIObject *>::iterator iter = m_vContents.begin();
	while (iter != m_vContents.end())
	{
		UIObject *pObject = *iter;
		if (pObject)
		{
			pObject->Refresh(fDeltaTime);
		}

		iter++;
	}	
}
Ejemplo n.º 4
0
void UIScroller::RemoveAllUIObjects()
{
	vector<UIObject *>::iterator iter = m_vContents.begin();
	while (iter != m_vContents.end())
	{
		UIObject *pObject = *iter;
		if (pObject)
		{
			pObject->Release();
		}

		iter++;
	}

	m_vContents.clear();
}
Ejemplo n.º 5
0
void UIDiscreteSliderComponent::HighlightCells( unsigned int stopIndex )
{
	for ( unsigned int cellIndex = 0; cellIndex < Cells.GetSize(); ++cellIndex )
	{
		UIObject * cell = Cells.At( cellIndex );
		
		if ( cellIndex <= stopIndex )
		{
			cell->SetImage( 0, SURFACE_TEXTURE_DIFFUSE, DiscreteSlider.CellOnTexture );
			cell->SetColor( DiscreteSlider.CellOnColor );
		}
		else
		{
			cell->SetImage( 0, SURFACE_TEXTURE_DIFFUSE, DiscreteSlider.CellOffTexture );
			cell->SetColor( DiscreteSlider.CellOffColor );
		}
	}
}
Ejemplo n.º 6
0
bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) {
	UIObject *obj = (UIObject *)param1;

	switch (obj->_type) {
	case UI_BUTTON:
		if (scumm_stricmp(obj->getName(), "close") == 0) {
			_visible = false;
		} else if (scumm_stricmp(obj->getName(), "prev") == 0) {
			_scrollOffset -= _scrollBy;
			_scrollOffset = MAX<int32>(_scrollOffset, 0);
		} else if (scumm_stricmp(obj->getName(), "next") == 0) {
			_scrollOffset += _scrollBy;
		} else {
			return BaseObject::listen(param1, param2);
		}
		break;
	default:
		error("AdInventoryBox::Listen - Unhandled enum");
		break;
	}

	return STATUS_OK;
}
Ejemplo n.º 7
0
void GameSession::LoadHUD(GameObject* player, SystemUIObjectQueue queue){
	//initialize HUD info for the player. Should only be called once
	SceneManager* sceneMan = SceneManager::GetSceneManager();
	RenderManager* renderMan = RenderManager::getRenderManager();
	//SystemUIObjectQueue queue;
	UIObjectFactory HUDFactory;

	renderMan->setBackground("Space-Muscle-Beach__0011_Sky.png");

	std::vector<UIObject*> UIObjs;

	//add the birdseed reference to player logic
	UIObject* birdseedMeter = HUDFactory.Spawn(BIRDSEED_BAR, 30, 30);
	UIObjs.push_back(birdseedMeter);
	queue.AddObject(birdseedMeter);
	UIObject* birdseedShell = HUDFactory.Spawn(BIRDSEED_SHELL, 30, 30);
	UIObjs.push_back(birdseedShell);
	queue.AddObject(birdseedShell);
	PlayerLogicComponent* playerLogic = dynamic_cast<PlayerLogicComponent*>(player->GetComponent(COMPONENT_LOGIC));
	PlayerUIComponent* playerUI = dynamic_cast<PlayerUIComponent*>(player->GetComponent(COMPONENT_UI));
	playerUI->birdseedHUD = dynamic_cast<UIRenderComponent*>(birdseedMeter->GetComponent(COMPONENT_RENDER))->objRef;
	playerUI->defaultRect = playerUI->birdseedHUD->renderRect;

	//add a timer to top of screen
	UIObject* countdownTimer = HUDFactory.Spawn(TIMER, SCREEN_WIDTH - 200, 30);
	UIObjs.push_back(countdownTimer);
	queue.AddObject(countdownTimer);
	playerUI->timerHUD = dynamic_cast<UIRenderComponent*>(countdownTimer->GetComponent(COMPONENT_RENDER))->objRef;

	PlayerRenderComponent* playerRender = dynamic_cast<PlayerRenderComponent*>(player->GetComponent(COMPONENT_RENDER));

	//add ui components to show player kills
	
	std::vector<std::pair<SDLRenderObject*, clock_t>> killHUD;
	for (int i = 0; i < 5; i++){
		UIObject* currKillHUD = HUDFactory.Spawn(KILL_NOTIFICATION,SCREEN_WIDTH-250,200+i*30);
		SDLRenderObject* currKillObj = dynamic_cast<UIRenderComponent*>(currKillHUD->GetComponent(COMPONENT_RENDER))->objRef;
		killHUD.push_back(std::pair<SDLRenderObject*, clock_t>(currKillObj, clock()));
		UIObjs.push_back(currKillHUD);
	}
	playerUI->killHUD = killHUD;
	playerUI->UIObjs = UIObjs;
}
Ejemplo n.º 8
0
void UIScroller::Render()
{ //render inside 1x1x1 cube...
	static int dwCircleTexture = gTextureManager()->GetTextureByFileName("shield.tga");

	if (m_bRenderWithBlending)
	{
		glDisable(GL_DEPTH_TEST);
		glEnable(GL_TEXTURE_2D);
		glEnable(GL_BLEND);
		glDisable(GL_LIGHTING);

		glBlendFunc(GL_SRC_ALPHA, GL_ONE);
		glNormal3f(0.0f, 0.0f, 1.0f); //normal always towards the camera
	}

	float			fScaleX			= m_vDimensions.x / (float)m_dwMaxDisplayable;
	//float			fScaleY			= m_vDimensions.y;
	float			fScaleY			= fScaleX;	//for now, always scaled to the X dimension...

	if (fScaleX < fScaleY) {
		fScaleY = fScaleX;
	}

	float			fCurrentX		= (float)m_dwMaxDisplayable / -2.0f * fScaleX + fScaleX / 2.0f;
	UIObject		*pObject		= 0;

	glPushMatrix();
//	glScalef(fScaleX, fScaleY, 1.0f);
	glTranslatef(fCurrentX, 0.0f, 0.0f);

	int dwNumRendered = 0;

	int i = m_dwMinDisplayed;//m_vContents.size() - m_dwMaxDisplayable;

	while (m_dwSelected < i)
	{
		--i;
	}
	while (m_dwSelected >= i + m_dwMaxDisplayable)
	{
		++i;
	}

	m_dwMinDisplayed = i;

	for (; i < (int)m_vContents.size() && dwNumRendered < m_dwMaxDisplayable; ++i)
	{
		glPushMatrix();
		glScalef(fScaleX, fScaleY, 0.0f);
		pObject = m_vContents.at(i);
		
		if (pObject)
		{
			pObject->Render();
			dwNumRendered++;

			if (i == m_dwSelected)
			{
				glColor3f(0.2f, 1.0f, 0.2f);
				glBindTexture(GL_TEXTURE_2D, dwCircleTexture);
				glCallList(Effect::m_dwTexturedQuadDisplayList);
			}

			glPopMatrix();
			glTranslatef(fScaleX, 0.0f, 0.0f);
		}
		else
		{
			glPopMatrix();
		}
	}

	glPopMatrix();

	if (m_bRenderWithBlending)
	{
		glDisable(GL_TEXTURE_2D);
		glDisable(GL_BLEND);
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_LIGHTING);
	}
}