Files
itgmania212121/stepmania/src/Screen.cpp
T

114 lines
2.9 KiB
C++
Raw Normal View History

2002-05-20 08:59:37 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
Class: Screen
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "Screen.h"
2002-06-14 22:25:22 +00:00
#include "GameManager.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
2002-05-20 08:59:37 +00:00
Screen::Screen()
{
2002-09-04 00:17:51 +00:00
m_FirstUpdate = true;
2002-05-20 08:59:37 +00:00
}
Screen::~Screen()
{
}
void Screen::AddChild( Actor* pActor )
{
// add only if the actor is on screen
2002-09-07 10:15:27 +00:00
// float fX = pActor->GetX();
// float fY = pActor->GetY();
// if( SCREEN_LEFT>=fX && fX<=SCREEN_RIGHT && SCREEN_TOP>=fY && fY<=SCREEN_BOTTOM )
ActorFrame::AddChild( pActor );
}
2002-05-20 08:59:37 +00:00
void Screen::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
// update the times of queued ScreenMessages and send if timer has expired
// The order you remove messages in must be very careful! Sending a message can
// potentially clear all m_QueuedMessages, and set a new state!
for( int i=0; i<m_QueuedMessages.GetSize(); i++ )
{
2002-09-06 00:32:19 +00:00
/* Er, wait. Shouldn't we subtract first? This will make messages
* get delayed an extra frame. -glenn */
2002-05-20 08:59:37 +00:00
if( m_QueuedMessages[i].fDelayRemaining <= 0.0f ) // send this sucker!
{
this->HandleScreenMessage( m_QueuedMessages[i].SM );
m_QueuedMessages.RemoveAt( i );
i--;
}
else
{
m_QueuedMessages[i].fDelayRemaining -= fDeltaTime;
}
}
}
void Screen::MenuBack( PlayerNumber pn, const InputEventType type )
2002-08-22 03:35:33 +00:00
{
if(!PREFSMAN->m_bDelayedEscape || type==IET_SLOW_REPEAT || type==IET_FAST_REPEAT)
MenuBack(pn);
2002-08-22 03:35:33 +00:00
}
2002-05-20 08:59:37 +00:00
void Screen::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
/* Don't send release messages with the default handler. */
if(type == IET_RELEASE) return; // don't care
2002-08-22 03:35:33 +00:00
/* Don't make the user hold the back button if they're pressing escape. */
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == DIK_ESCAPE )
{
this->MenuBack( MenuI.player );
return;
}
2002-05-20 08:59:37 +00:00
// default input handler used by most menus
if( !MenuI.IsValid() )
return;
2002-07-23 01:41:40 +00:00
if( !GAMESTATE->IsPlayerEnabled(MenuI.player) )
2002-06-14 22:25:22 +00:00
return;
2002-05-20 08:59:37 +00:00
switch( MenuI.button )
{
2002-05-27 18:36:01 +00:00
case MENU_BUTTON_UP: this->MenuUp( MenuI.player, type ); return;
case MENU_BUTTON_DOWN: this->MenuDown( MenuI.player, type ); return;
case MENU_BUTTON_LEFT: this->MenuLeft( MenuI.player, type ); return;
case MENU_BUTTON_RIGHT: this->MenuRight( MenuI.player, type ); return;
case MENU_BUTTON_BACK: this->MenuBack( MenuI.player, type ); return;
case MENU_BUTTON_START: this->MenuStart( MenuI.player, type ); return;
2002-05-20 08:59:37 +00:00
}
}
void Screen::SendScreenMessage( ScreenMessage SM, float fDelay )
{
ASSERT( fDelay >= 0.0 );
2002-05-20 08:59:37 +00:00
QueuedScreenMessage QSM;
QSM.SM = SM;
QSM.fDelayRemaining = fDelay;
m_QueuedMessages.Add( QSM );
2002-09-04 00:17:51 +00:00
}
bool Screen::FirstUpdate()
{
bool ret = m_FirstUpdate;
m_FirstUpdate = false;
return ret;
}