sandbox is now a sandbox again; add a Test container, move

the sound test into a separate screen and add a font test
This commit is contained in:
Glenn Maynard
2003-01-09 04:45:49 +00:00
parent 3f3032e89d
commit 5c2f183669
12 changed files with 452 additions and 197 deletions
+2 -2
View File
@@ -177,7 +177,6 @@ void ScreenManager::Input( const DeviceInput& DeviceI, const InputEventType type
#include "ScreenMapControllers.h"
#include "ScreenMusicScroll.h"
#include "ScreenPlayerOptions.h"
#include "ScreenSandbox.h"
#include "ScreenSelectCourse.h"
#include "ScreenSelectDifficulty.h"
#include "ScreenSelectGame.h"
@@ -187,6 +186,7 @@ void ScreenManager::Input( const DeviceInput& DeviceI, const InputEventType type
#include "ScreenSelectStyle.h"
#include "ScreenSongOptions.h"
#include "ScreenStage.h"
#include "ScreenTest.h"
#include "ScreenTitleMenu.h"
#include "ScreenEz2SelectMusic.h"
#include "ScreenWarning.h"
@@ -223,7 +223,6 @@ Screen* ScreenManager::MakeNewScreen( CString sClassName )
else if( 0==stricmp(sClassName, "ScreenInputOptions") ) ret = new ScreenInputOptions;
else if( 0==stricmp(sClassName, "ScreenMusicScroll") ) ret = new ScreenMusicScroll;
else if( 0==stricmp(sClassName, "ScreenPlayerOptions") ) ret = new ScreenPlayerOptions;
else if( 0==stricmp(sClassName, "ScreenSandbox") ) ret = new ScreenSandbox;
else if( 0==stricmp(sClassName, "ScreenSelectCourse") ) ret = new ScreenSelectCourse;
else if( 0==stricmp(sClassName, "ScreenSelectDifficulty") ) ret = new ScreenSelectDifficulty;
else if( 0==stricmp(sClassName, "ScreenSelectGame") ) ret = new ScreenSelectGame;
@@ -233,6 +232,7 @@ Screen* ScreenManager::MakeNewScreen( CString sClassName )
else if( 0==stricmp(sClassName, "ScreenSelectStyle") ) ret = new ScreenSelectStyle;
else if( 0==stricmp(sClassName, "ScreenSongOptions") ) ret = new ScreenSongOptions;
else if( 0==stricmp(sClassName, "ScreenStage") ) ret = new ScreenStage;
else if( 0==stricmp(sClassName, "ScreenTest") ) ret = new ScreenTest;
else if( 0==stricmp(sClassName, "ScreenTitleMenu") ) ret = new ScreenTitleMenu;
else if( 0==stricmp(sClassName, "ScreenEz2SelectMusic") ) ret = new ScreenEz2SelectMusic;
else if( 0==stricmp(sClassName, "ScreenWarning") ) ret = new ScreenWarning;
+14 -172
View File
@@ -3,7 +3,10 @@
-----------------------------------------------------------------------------
File: ScreenSandbox.h
Desc: Area for testing.
Desc: Area for testing. Throw whatever you're working on in here. If you
don't want stuff in here to be wiped out by the next guy who works on something,
make a separate screen and add a hook into ScreenTest; this one's just a
scratchpad.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
@@ -13,194 +16,33 @@
*/
#include "stdafx.h"
#include "ScreenSandbox.h"
#include "RageDisplay.h"
#include <math.h>
#include "SDL.h"
#include "SDL_opengl.h"
#include "ScreenSandbox.h"
#include "ScreenManager.h"
#include "RageSoundManager.h"
#include "GameConstantsAndTypes.h"
#include "PrefsManager.h"
#include "Quad.h"
#include "ThemeManager.h"
ScreenSandbox::ScreenSandbox()
{
SOUNDMAN->music->StopPlaying();
// m_quad.StretchTo( RectI(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) );
// m_quad.SetDiffuse( RageColor(1,1,1,1) );
{
m_quad.StretchTo( RectI(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) );
m_quad.SetDiffuse( RageColor(1,1,1,1) );
// this->AddChild( &m_quad );
// m_sprite.Load( "C:\\stepmania\\stepmania\\RandomMovies\\cm301[1].avi" );
// m_sprite.SetXY( CENTER_X, CENTER_Y );
// this->AddChild( &m_sprite );
// obj.SetXY(CENTER_X, CENTER_Y);
// this->AddChild(&obj);
this->AddChild(&HEEEEEEEEELP);
HEEEEEEEEELP.SetXY(450, 400);
HEEEEEEEEELP.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
HEEEEEEEEELP.SetZoom(.5);
HEEEEEEEEELP.SetText(
"p Play\n"
"s Stop\n"
"l Set looping\n"
"a Set autostop\n"
"c Set continue");
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);
s[3].txt.SetXY(450, 250);
s[4].txt.SetXY(150, 400);
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");
s[3].s.Load("Themes/default/Sounds/gameplay oni die.mp3");
s[4].s.Load("Themes/default/Sounds/gameplay toasty.mp3");
//s[0].s.SetStartSeconds(45);
//s[0].s.SetPositionSeconds();
// s[4].s.SetLengthSeconds(1);
s[0].s.SetPlaybackRate(1.20f);
//s[0].s.SetStopMode(RageSound::M_LOOP);
//s[0].s.Play();
selected = 0;
obj.SetXY(CENTER_X, CENTER_Y);
// obj.SetZoom(50);
this->AddChild(&obj);
}
void ScreenSandbox::UpdateText(int n)
void ScreenSandbox::HandleScreenMessage( const ScreenMessage SM )
{
CString fn = s[n].s.GetLoadedFilePath();
unsigned x = fn.find_last_of("/\\");
if(x != fn.npos) fn.erase(0, x+1);
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());
}
s[n].txt.SetText(ssprintf(
"%i: %s\n"
"%s\n"
"%s\n"
"(%s) of %.3f\n"
"%s\n"
"%s",
n+1, fn.GetString(),
s[n].s.IsPlaying()? "Playing":"Stopped",
s[n].s.GetStopMode() == RageSound::M_STOP?
"Stop when finished":
s[n].s.GetStopMode() == RageSound::M_CONTINUE?
"Continue until stopped":
"Loop",
pos.size()? pos.GetString(): "none playing",
s[n].s.GetLengthSeconds(),
s[n].s.IsStreaming()? "Streaming":"Preloaded",
selected == n? "^^^^^^":""
));
}
void ScreenSandbox::Update(float f)
{
for(int i = 0; i < nsounds; ++i)
UpdateText(i);
}
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)
{
case DEVICE_KEYBOARD:
switch( DeviceI.button )
{
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.SetStopMode(RageSound::M_LOOP);
break;
case 'a':
s[selected].s.SetStopMode(RageSound::M_STOP);
break;
case 'c':
s[selected].s.SetStopMode(RageSound::M_CONTINUE);
break;
/* case SDLK_LEFT:
obj.SetX(obj.GetX() - 10);
break;
case SDLK_RIGHT:
obj.SetX(obj.GetX() + 10);
break;
case SDLK_UP:
obj.SetY(obj.GetY() - 10);
break;
case SDLK_DOWN:
obj.SetY(obj.GetY() + 10);
break;
*/
case SDLK_t:
{
SDL_Event *event;
event = (SDL_Event *) malloc(sizeof(event));
event->type = SDL_QUIT;
SDL_PushEvent(event);
}
case SDLK_ESCAPE:
{
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
}
}
}
}
void ScreenSandbox::HandleScreenMessage( const ScreenMessage SM )
void ScreenSandbox::Update( float fDeltaTime )
{
switch( SM )
{
case SM_DoneClosingWipingLeft:
break;
case SM_DoneClosingWipingRight:
break;
case SM_DoneOpeningWipingLeft:
break;
case SM_DoneOpeningWipingRight:
break;
}
Screen::Update(fDeltaTime);
}
+2 -20
View File
@@ -12,14 +12,8 @@
*/
#include "Screen.h"
#include "Sprite.h"
#include "BitmapText.h"
#include "Quad.h"
#include "MenuElements.h"
#include "RageSound.h"
#include "Sample3dObject.h"
const int nsounds = 5;
#include "Quad.h"
class ScreenSandbox : public Screen
{
@@ -30,20 +24,8 @@ public:
virtual void HandleScreenMessage( const ScreenMessage SM );
void Update(float f);
void UpdateText(int n);
struct Sound {
RageSound s;
BitmapText txt;
};
Sound s[nsounds];
BitmapText HEEEEEEEEELP;
int selected;
Quad m_quad;
Sprite m_sprite;
Sample3dObject obj;
Quad m_quad;
};
+74
View File
@@ -0,0 +1,74 @@
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: ScreenTest.h
Desc: Area for testing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
Glenn Maynard (OpenGL Code)
Lance Gilbert (OpenGL/Usability Modifications)
-----------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "ScreenTest.h"
#include "ScreenSandbox.h"
#include "ScreenTestSound.h"
#include "ScreenTestFonts.h"
#include "ScreenManager.h"
ScreenTest::~ScreenTest()
{
delete current;
}
void ScreenTest::SetScreen(int num)
{
cur_screen = num;
delete current;
if(num > 2) num = 0;
if(num == 0)
current=new ScreenSandbox;
else if(num == 1)
current=new ScreenTestSound;
else if(num == 2)
current=new ScreenTestFonts;
}
ScreenTest::ScreenTest()
{
current = NULL;
cur_screen = -1;
SOUNDMAN->music->StopPlaying();
SetScreen(0);
}
void ScreenTest::Update(float f) { current->Update(f); }
void ScreenTest::HandleScreenMessage( const ScreenMessage SM ) { current->HandleScreenMessage(SM); }
void ScreenTest::Draw() { current->Draw(); }
void ScreenTest::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
if(DeviceI.device == DEVICE_KEYBOARD)
{
if(DeviceI.button >= SDLK_F9 && DeviceI.button <= SDLK_F12)
{
if( type != IET_FIRST_PRESS ) return;
SetScreen(DeviceI.button - SDLK_F9);
return;
}
if(DeviceI.button == SDLK_ESCAPE)
{
if( type != IET_FIRST_PRESS ) return;
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
return;
}
}
current->Input( DeviceI, type, GameI, MenuI, StyleI );
}
+35
View File
@@ -0,0 +1,35 @@
#ifndef ScreenTest_H
#define ScreenTest_H
/*
-----------------------------------------------------------------------------
Class: ScreenTest
Desc: Area for testing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
Glenn Maynard
-----------------------------------------------------------------------------
*/
#include "Screen.h"
class ScreenTest : public Screen
{
public:
ScreenTest();
~ScreenTest();
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleScreenMessage( const ScreenMessage SM );
Screen *current;
int cur_screen;
void SetScreen(int num);
void Update(float f);
void Draw();
};
#endif
+55
View File
@@ -0,0 +1,55 @@
#include "stdafx.h"
#include "ScreenTestFonts.h"
static const float LineWidth = 400;
static const float LineHeight = 50;
ScreenTestFonts::ScreenTestFonts()
{
Hline.SetXY(CENTER_X, CENTER_Y);
Hline.SetZoomX(LineWidth);
Hline.SetDiffuse( RageColor(1, 1, 1, 1) );
this->AddChild(&Hline);
Vline.SetXY(CENTER_X, CENTER_Y);
Vline.SetZoomY(LineHeight);
Vline.SetDiffuse( RageColor(0, 1, 0, .8f) );
this->AddChild(&Vline);
txt.SetXY( CENTER_X, CENTER_Y );
txt.LoadFromFont( "Themes/default/Fonts/header1" );
txt.SetText( "Foo" );
this->AddChild(&txt);
}
void ScreenTestFonts::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
if( type != IET_FIRST_PRESS )
return;
switch( DeviceI.button )
{
case '[': txt.SetVertAlign(align_bottom); break;
case '\\': txt.SetVertAlign(align_middle); break;
case ']': txt.SetVertAlign(align_top); break;
case ',': txt.SetHorizAlign(align_left); break;
case '.': txt.SetHorizAlign(align_center); break;
case '/': txt.SetHorizAlign(align_right); break;
case '1': txt.SetText("Waaai"); break;
/* These two kanji are currently two different sizes (20 and 32 pix),
* and they should be vertically centered with the other text: */
case '2': txt.SetText("WAAI &kakumei1;"); break;
case '3': txt.SetText("WAAI &oni;"); break;
case '4': txt.SetText("WAAI\nWAAI"); break;
case '5': txt.SetText("WAAI &oni;\nWAAI"); break;
case 'q': txt.LoadFromFont( "Themes/default/Fonts/header1" ); break;
case 'w': txt.LoadFromFont( "Themes/default/Fonts/header2" ); break;
case 'e': txt.LoadFromFont( "Themes/default/Fonts/Normal" ); break;
case 'r': txt.LoadFromFont( "Themes/default/Fonts/titlemenu" ); break;
}
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef SCREEN_TEST_FONTS_H
#define SCREEN_TEST_FONTS_H
#include "Screen.h"
#include "BitmapText.h"
#include "Quad.h"
class ScreenTestFonts: public Screen
{
public:
ScreenTestFonts();
BitmapText txt;
Quad Vline, Hline;
void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
};
#endif
+165
View File
@@ -0,0 +1,165 @@
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: ScreenTestSound.h
Desc: Area for testing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
Glenn Maynard (OpenGL Code)
Lance Gilbert (OpenGL/Usability Modifications)
-----------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "ScreenTestSound.h"
#include "RageDisplay.h"
#include "SDL.h"
#include "ScreenManager.h"
#include "RageSoundManager.h"
#include "ThemeManager.h"
ScreenTestSound::ScreenTestSound()
{
this->AddChild(&HEEEEEEEEELP);
HEEEEEEEEELP.SetXY(450, 400);
HEEEEEEEEELP.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
HEEEEEEEEELP.SetZoom(.5);
HEEEEEEEEELP.SetText(
"p Play\n"
"s Stop\n"
"l Set looping\n"
"a Set autostop\n"
"c Set continue");
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);
s[3].txt.SetXY(450, 250);
s[4].txt.SetXY(150, 400);
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");
s[3].s.Load("Themes/default/Sounds/gameplay oni die.mp3");
s[4].s.Load("Themes/default/Sounds/gameplay toasty.mp3");
//s[0].s.SetStartSeconds(45);
//s[0].s.SetPositionSeconds();
// s[4].s.SetLengthSeconds(1);
s[0].s.SetPlaybackRate(1.20f);
//s[0].s.SetStopMode(RageSound::M_LOOP);
//s[0].s.Play();
selected = 0;
for(int i = 0; i < nsounds; ++i)
UpdateText(i);
}
void ScreenTestSound::UpdateText(int n)
{
CString fn = s[n].s.GetLoadedFilePath();
unsigned x = fn.find_last_of("/\\");
if(x != fn.npos) fn.erase(0, x+1);
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());
}
s[n].txt.SetText(ssprintf(
"%i: %s\n"
"%s\n"
"%s\n"
"(%s) of %.3f\n"
"%s\n"
"%s",
n+1, fn.GetString(),
s[n].s.IsPlaying()? "Playing":"Stopped",
s[n].s.GetStopMode() == RageSound::M_STOP?
"Stop when finished":
s[n].s.GetStopMode() == RageSound::M_CONTINUE?
"Continue until stopped":
"Loop",
pos.size()? pos.GetString(): "none playing",
s[n].s.GetLengthSeconds(),
s[n].s.IsStreaming()? "Streaming":"Preloaded",
selected == n? "^^^^^^":""
));
}
void ScreenTestSound::Update(float f)
{
// for(int i = 0; i < nsounds; ++i)
// UpdateText(i);
}
void ScreenTestSound::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)
{
case DEVICE_KEYBOARD:
switch( DeviceI.button )
{
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.SetStopMode(RageSound::M_LOOP);
break;
case 'a':
s[selected].s.SetStopMode(RageSound::M_STOP);
break;
case 'c':
s[selected].s.SetStopMode(RageSound::M_CONTINUE);
break;
/* case SDLK_LEFT:
obj.SetX(obj.GetX() - 10);
break;
case SDLK_RIGHT:
obj.SetX(obj.GetX() + 10);
break;
case SDLK_UP:
obj.SetY(obj.GetY() - 10);
break;
case SDLK_DOWN:
obj.SetY(obj.GetY() + 10);
break;
*/
}
}
}
void ScreenTestSound::HandleScreenMessage( const ScreenMessage SM )
{
}
+42
View File
@@ -0,0 +1,42 @@
#ifndef SCREENTESTSOUND_H
#define SCREENTESTSOUND_H
/*
-----------------------------------------------------------------------------
Class: ScreenSandbox
Desc: Area for testing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "Screen.h"
#include "BitmapText.h"
#include "RageSound.h"
const int nsounds = 5;
class ScreenTestSound : public Screen
{
public:
ScreenTestSound();
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleScreenMessage( const ScreenMessage SM );
void Update(float f);
void UpdateText(int n);
struct Sound {
RageSound s;
BitmapText txt;
};
Sound s[nsounds];
BitmapText HEEEEEEEEELP;
int selected;
};
#endif
+1 -1
View File
@@ -297,7 +297,7 @@ void ScreenTitleMenu::HandleScreenMessage( const ScreenMessage SM )
break;
#ifdef _DEBUG
case CHOICE_SANDBOX:
SCREENMAN->SetNewScreen( "ScreenSandbox" );
SCREENMAN->SetNewScreen( "ScreenTest" );
break;
#endif
case CHOICE_EDIT:
+26 -2
View File
@@ -60,7 +60,7 @@ IntDir=.\../Release6
TargetDir=\temp\stepmania
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -95,7 +95,7 @@ IntDir=.\../Debug6
TargetDir=\temp\stepmania
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -1533,6 +1533,30 @@ SOURCE=.\ScreenStage.h
# End Source File
# Begin Source File
SOURCE=.\ScreenTest.cpp
# End Source File
# Begin Source File
SOURCE=.\ScreenTest.h
# End Source File
# Begin Source File
SOURCE=.\ScreenTestFonts.cpp
# End Source File
# Begin Source File
SOURCE=.\ScreenTestFonts.h
# End Source File
# Begin Source File
SOURCE=.\ScreenTestSound.cpp
# End Source File
# Begin Source File
SOURCE=.\ScreenTestSound.h
# End Source File
# Begin Source File
SOURCE=.\ScreenTextEntry.cpp
# End Source File
# Begin Source File
+18
View File
@@ -360,6 +360,24 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
<File
RelativePath="ScreenStage.h">
</File>
<File
RelativePath="ScreenTest.cpp">
</File>
<File
RelativePath="ScreenTest.h">
</File>
<File
RelativePath="ScreenTestFonts.cpp">
</File>
<File
RelativePath="ScreenTestFonts.h">
</File>
<File
RelativePath="ScreenTestSound.cpp">
</File>
<File
RelativePath="ScreenTestSound.h">
</File>
<File
RelativePath="ScreenTextEntry.cpp">
</File>