Files
itgmania212121/stepmania/src/ScreenSandbox.cpp
T

200 lines
4.4 KiB
C++
Raw Normal View History

2002-05-20 08:59:37 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: ScreenSandbox.h
Desc: Area for testing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-11-19 22:55:51 +00:00
Chris Danford
Glenn Maynard (OpenGL Code)
Lance Gilbert (OpenGL/Usability Modifications)
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
2002-11-19 22:55:51 +00:00
#include "stdafx.h"
2002-05-20 08:59:37 +00:00
2002-11-19 22:55:51 +00:00
#include "ScreenSandbox.h"
#include "RageDisplay.h"
#include <math.h>
#include "SDL.h"
#include "SDL_opengl.h"
2002-05-20 08:59:37 +00:00
#include "ScreenSandbox.h"
#include "ScreenManager.h"
#include "RageMusic.h"
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-05-20 08:59:37 +00:00
#include "Quad.h"
#include "ThemeManager.h"
2002-05-20 08:59:37 +00:00
ScreenSandbox::ScreenSandbox()
{
2002-12-22 08:13:33 +00:00
MUSIC->Stop();
2002-12-18 06:54:28 +00:00
// m_quad.StretchTo( RectI(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) );
// m_quad.SetDiffuse( RageColor(1,1,1,1) );
// this->AddChild( &m_quad );
2002-12-18 06:54:28 +00:00
// m_sprite.Load( "C:\\stepmania\\stepmania\\RandomMovies\\cm301[1].avi" );
// m_sprite.SetXY( CENTER_X, CENTER_Y );
// this->AddChild( &m_sprite );
2002-12-18 06:54:28 +00:00
// obj.SetXY(CENTER_X, CENTER_Y);
// this->AddChild(&obj);
this->AddChild(&HEEEEEEEEELP);
2002-12-22 08:13:33 +00:00
2002-12-18 06:54:28 +00:00
HEEEEEEEEELP.SetXY(450, 400);
HEEEEEEEEELP.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
HEEEEEEEEELP.SetZoom(.5);
HEEEEEEEEELP.SetText(
"p Play\n"
"s Stop\n"
"l Toggle looping\n"
2002-12-22 08:13:33 +00:00
"a Toggle autostop\n");
2002-12-18 06:54:28 +00:00
for(int i = 0; i < nsounds; ++i)
{
this->AddChild(&s[i].txt);
s[i].txt.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
s[i].txt.SetZoom(.5);
}
s[0].txt.SetXY(150, 100);
s[1].txt.SetXY(450, 100);
s[2].txt.SetXY(150, 250);
2002-12-22 08:13:33 +00:00
// s[3].txt.SetXY(450, 250);
// s[4].txt.SetXY(150, 400);
2002-12-18 06:54:28 +00:00
s[0].s.Load("Themes/default/Sounds/_common menu music.ogg");
s[1].s.Load("Themes/default/Sounds/music scroll music.ogg");
s[2].s.Load("Themes/default/Sounds/evaluation extra stage.mp3");
2002-12-22 08:13:33 +00:00
// s[3].s.Load("Themes/default/Sounds/gameplay oni die.mp3");
// s[4].s.Load("Themes/default/Sounds/gameplay toasty.mp3");
/*s[0].s.SetPositionSeconds(3);
s[0].s.SetStartSeconds(3);
s[0].s.SetLengthSeconds(1);
s[0].s.SetAutoStop(false);
s[0].s.Play();
*/
2002-12-18 06:54:28 +00:00
selected = 0;
}
void ScreenSandbox::UpdateText(int n)
{
CString fn = s[n].s.GetLoadedFilePath();
unsigned x = fn.find_last_of("/\\");
if(x != fn.npos) fn.erase(0, x+1);
2002-12-22 08:13:33 +00:00
vector<RageSound *> snds;
SOUNDMAN->GetCopies(s[n].s, snds);
CString pos;
for(unsigned p = 0; p < snds.size(); ++p)
{
if(p) pos += ", ";
pos += ssprintf("%.3f", snds[p]->GetPositionSeconds());
}
2002-12-18 06:54:28 +00:00
s[n].txt.SetText(ssprintf(
"%i: %s\n"
"%s\n"
"%s\n"
"%s\n"
2002-12-22 08:13:33 +00:00
"(%s) of %.3f\n"
2002-12-18 06:54:28 +00:00
"%s\n"
"%s",
n+1, fn.GetString(),
s[n].s.IsPlaying()? "Playing":"Stopped",
s[n].s.GetLooping()? "Looping": "Not looping",
s[n].s.GetAutoStop()? "Stop when finished": "Continue until stopped",
2002-12-22 08:13:33 +00:00
pos.size()? pos.GetString(): "none playing",
s[n].s.GetLengthSeconds(),
2002-12-18 06:54:28 +00:00
s[n].s.IsStreaming()? "Streaming":"Preloaded",
selected == n? "^^^^^^":""
));
}
void ScreenSandbox::Update(float f)
{
for(int i = 0; i < nsounds; ++i)
UpdateText(i);
2002-05-20 08:59:37 +00:00
}
void ScreenSandbox::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
if( type != IET_FIRST_PRESS )
return; // ignore
switch( DeviceI.device)
2002-05-20 08:59:37 +00:00
{
case DEVICE_KEYBOARD:
switch( DeviceI.button )
2002-05-20 08:59:37 +00:00
{
2002-12-18 06:54:28 +00:00
case '1':
case '2':
case '3':
case '4':
case '5': selected = DeviceI.button - '0'-1; break;
case 'p':
s[selected].s.Play();
break;
case 's':
s[selected].s.Stop();
break;
case 'l':
s[selected].s.SetLooping(!s[selected].s.GetLooping());
break;
case 'a':
s[selected].s.SetAutoStop(!s[selected].s.GetAutoStop());
break;
/* case SDLK_LEFT:
2002-11-19 23:57:10 +00:00
obj.SetX(obj.GetX() - 10);
break;
case SDLK_RIGHT:
2002-11-19 23:57:10 +00:00
obj.SetX(obj.GetX() + 10);
break;
case SDLK_UP:
2002-11-19 23:57:10 +00:00
obj.SetY(obj.GetY() - 10);
2002-05-20 08:59:37 +00:00
break;
case SDLK_DOWN:
2002-11-19 23:57:10 +00:00
obj.SetY(obj.GetY() + 10);
2002-11-19 22:55:51 +00:00
break;
2002-12-18 06:54:28 +00:00
*/
case SDLK_t:
2002-11-19 22:55:51 +00:00
{
SDL_Event *event;
event = (SDL_Event *) malloc(sizeof(event));
event->type = SDL_QUIT;
SDL_PushEvent(event);
}
case SDLK_ESCAPE:
2002-11-19 22:55:51 +00:00
{
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
}
2002-05-20 08:59:37 +00:00
}
2002-11-19 22:55:51 +00:00
2002-05-20 08:59:37 +00:00
}
}
void ScreenSandbox::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_DoneClosingWipingLeft:
break;
case SM_DoneClosingWipingRight:
break;
case SM_DoneOpeningWipingLeft:
break;
case SM_DoneOpeningWipingRight:
break;
}
2002-11-16 20:21:00 +00:00
}