From 317c352a9b967b7833db52df98e7113c8e69b202 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 23 Jul 2002 01:41:40 +0000 Subject: [PATCH] Various bug fixes. See changelog. --- stepmania/src/ActorFrame.cpp | 9 +- stepmania/src/ActorFrame.h | 7 +- stepmania/src/AnnouncerManager.cpp | 136 ++++---- stepmania/src/AnnouncerManager.h | 22 +- stepmania/src/ArrowEffects.cpp | 17 +- stepmania/src/BPMDisplay.cpp | 8 +- stepmania/src/Background.cpp | 4 +- stepmania/src/Banner.cpp | 2 +- stepmania/src/BannerWithFrame.cpp | 6 +- stepmania/src/Combo.cpp | 11 +- stepmania/src/Combo.h | 15 +- stepmania/src/Course.cpp | 75 +++- stepmania/src/Course.h | 12 +- stepmania/src/CourseContentsFrame.cpp | 180 +++++++--- stepmania/src/CourseContentsFrame.h | 37 +- stepmania/src/CroppedSprite.cpp | 2 +- stepmania/src/DifficultyIcon.cpp | 2 +- stepmania/src/DifficultyIcon.h | 2 +- stepmania/src/FocusingSprite.cpp | 2 +- stepmania/src/FootMeter.cpp | 2 +- stepmania/src/FootMeter.h | 2 +- stepmania/src/GameConstantsAndTypes.h | 17 +- stepmania/src/GameDef.cpp | 35 +- stepmania/src/GameDef.h | 9 +- stepmania/src/GameManager.cpp | 112 +++--- stepmania/src/GameManager.h | 35 +- stepmania/src/GameState.cpp | 154 ++++++++ stepmania/src/GameState.h | 81 +++++ stepmania/src/GhostArrow.cpp | 2 +- stepmania/src/GhostArrowBright.cpp | 2 +- stepmania/src/GhostArrowRow.cpp | 13 +- stepmania/src/GradeDisplay.cpp | 2 +- stepmania/src/GradeDisplay.h | 2 +- stepmania/src/GrayArrow.cpp | 2 +- stepmania/src/GrayArrowRow.cpp | 8 +- stepmania/src/GrooveRadar.cpp | 8 +- stepmania/src/HoldGhostArrow.cpp | 2 +- stepmania/src/HoldJudgement.cpp | 4 +- stepmania/src/HoldJudgement.h | 2 +- stepmania/src/IniFile.cpp | 214 ++++++------ stepmania/src/IniFile.h | 61 ++-- stepmania/src/InputMapper.cpp | 55 ++- stepmania/src/InputMapper.h | 9 - stepmania/src/Judgement.cpp | 13 +- stepmania/src/Judgement.h | 2 +- stepmania/src/LifeMeter.h | 15 +- stepmania/src/LifeMeterBar.cpp | 167 ++++++--- stepmania/src/LifeMeterBar.h | 18 +- stepmania/src/LifeMeterBattery.cpp | 176 ++++++++++ stepmania/src/LifeMeterBattery.h | 53 +++ stepmania/src/MenuElements.cpp | 45 +-- stepmania/src/MenuElements.h | 3 +- stepmania/src/MenuTimer.cpp | 6 +- stepmania/src/MsdFile.cpp | 125 +++++++ stepmania/src/MsdFile.h | 36 ++ stepmania/src/MusicStatusDisplay.h | 2 +- stepmania/src/MusicWheel.cpp | 55 +-- stepmania/src/MusicWheel.h | 4 +- stepmania/src/NoteData.cpp | 2 +- stepmania/src/NoteField.cpp | 16 +- stepmania/src/NoteField.h | 2 +- stepmania/src/Notes.cpp | 28 +- stepmania/src/Notes.h | 12 +- stepmania/src/Player.cpp | 99 +++--- stepmania/src/Player.h | 18 +- stepmania/src/PrefsManager.cpp | 141 +++----- stepmania/src/PrefsManager.h | 57 +-- stepmania/src/RageDisplay.cpp | 23 +- stepmania/src/RageDisplay.h | 2 +- stepmania/src/RageLog.cpp | 2 - stepmania/src/RageUtil.cpp | 150 +++++++- stepmania/src/RageUtil.h | 51 ++- stepmania/src/RandomSample.cpp | 3 + stepmania/src/ScoreDisplay.cpp | 18 + stepmania/src/ScoreDisplay.h | 33 ++ stepmania/src/ScoreDisplayNormal.cpp | 159 +++++++++ stepmania/src/ScoreDisplayNormal.h | 43 +++ stepmania/src/ScoreDisplayOni.cpp | 152 ++++++++ stepmania/src/ScoreDisplayOni.h | 42 +++ stepmania/src/Screen.cpp | 3 +- stepmania/src/ScreenAppearanceOptions.cpp | 57 ++- stepmania/src/ScreenCaution.cpp | 6 +- stepmania/src/ScreenEdit.cpp | 34 +- stepmania/src/ScreenEditMenu.cpp | 50 +-- stepmania/src/ScreenEvaluation.cpp | 356 ++++++++++--------- stepmania/src/ScreenEvaluation.h | 4 +- stepmania/src/ScreenEz2SelectPlayer.cpp | 29 +- stepmania/src/ScreenEz2SelectStyle.cpp | 43 +-- stepmania/src/ScreenGameOver.cpp | 14 +- stepmania/src/ScreenGameOver.h | 2 + stepmania/src/ScreenGameplay.cpp | 408 +++++++++++++--------- stepmania/src/ScreenGameplay.h | 15 +- stepmania/src/ScreenLoading.cpp | 32 ++ stepmania/src/ScreenLoading.h | 29 ++ stepmania/src/ScreenManager.cpp | 2 +- stepmania/src/ScreenMusicScroll.cpp | 22 +- stepmania/src/ScreenOptions.cpp | 18 +- stepmania/src/ScreenPlayerOptions.cpp | 39 ++- stepmania/src/ScreenPrompt.cpp | 12 +- stepmania/src/ScreenSandbox.cpp | 24 +- stepmania/src/ScreenSandbox.h | 4 +- stepmania/src/ScreenSelectCourse.cpp | 21 +- stepmania/src/ScreenSelectDifficulty.cpp | 43 ++- stepmania/src/ScreenSelectGame.cpp | 84 +---- stepmania/src/ScreenSelectGroup.cpp | 50 ++- stepmania/src/ScreenSelectMusic.cpp | 71 ++-- stepmania/src/ScreenSelectStyle.cpp | 23 +- stepmania/src/ScreenSongOptions.cpp | 41 ++- stepmania/src/ScreenStage.cpp | 26 +- stepmania/src/ScreenTitleMenu.cpp | 43 ++- stepmania/src/ScrollBar.cpp | 16 +- stepmania/src/Song.cpp | 173 ++++----- stepmania/src/SongManager.cpp | 98 ++---- stepmania/src/SongManager.h | 24 +- stepmania/src/Sprite.cpp | 13 +- stepmania/src/StdAfx.h | 1 + stepmania/src/StepMania.cpp | 238 ++++++++----- stepmania/src/StepMania.dsp | 64 +++- stepmania/src/StepMania.vcproj | 38 +- stepmania/src/TextBanner.cpp | 8 +- stepmania/src/ThemeManager.cpp | 133 +++---- stepmania/src/ThemeManager.h | 49 +-- stepmania/src/TipDisplay.cpp | 64 +--- stepmania/src/TipDisplay.h | 6 +- stepmania/src/Transition.cpp | 2 +- stepmania/src/TransitionBackWipe.cpp | 2 +- stepmania/src/TransitionFadeWipe.cpp | 2 +- stepmania/src/TransitionKeepAlive.cpp | 2 +- stepmania/src/TransitionStarWipe.cpp | 2 +- 129 files changed, 3745 insertions(+), 1950 deletions(-) create mode 100644 stepmania/src/GameState.cpp create mode 100644 stepmania/src/GameState.h create mode 100644 stepmania/src/LifeMeterBattery.cpp create mode 100644 stepmania/src/LifeMeterBattery.h create mode 100644 stepmania/src/MsdFile.cpp create mode 100644 stepmania/src/MsdFile.h create mode 100644 stepmania/src/ScoreDisplay.cpp create mode 100644 stepmania/src/ScoreDisplay.h create mode 100644 stepmania/src/ScoreDisplayNormal.cpp create mode 100644 stepmania/src/ScoreDisplayNormal.h create mode 100644 stepmania/src/ScoreDisplayOni.cpp create mode 100644 stepmania/src/ScoreDisplayOni.h create mode 100644 stepmania/src/ScreenLoading.cpp create mode 100644 stepmania/src/ScreenLoading.h diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 996a0907e9..bae03f7f75 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -1,18 +1,21 @@ #include "stdafx.h" // testing updates /* ----------------------------------------------------------------------------- - File: ActorFrame.h + Class: ActorFrame - Desc: Base class for all objects that appear on the screen. + Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ #include "ActorFrame.h" -void ActorFrame::AddActor( Actor* pActor) +void ActorFrame::AddSubActor( Actor* pActor) { + ASSERT( pActor ); + ASSERT( (void*)pActor != (void*)0xC0000005 ); m_SubActors.Add( pActor ); } diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index c310834c5a..ac01b73181 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -1,11 +1,12 @@ #pragma once /* ----------------------------------------------------------------------------- - File: ActorFrame.h + Class: ActorFrame - Desc: Base class for all objects that appear on the screen. + Desc: A container for other actors. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ @@ -23,7 +24,7 @@ protected: public: - void AddActor( Actor* pActor); + void AddSubActor( Actor* pActor); virtual void Update( float fDeltaTime ); virtual void DrawPrimitives(); diff --git a/stepmania/src/AnnouncerManager.cpp b/stepmania/src/AnnouncerManager.cpp index 677fcc96d1..62fc3a1c13 100644 --- a/stepmania/src/AnnouncerManager.cpp +++ b/stepmania/src/AnnouncerManager.cpp @@ -11,7 +11,6 @@ */ #include "AnnouncerManager.h" -#include "PrefsManager.h" #include "RageLog.h" @@ -28,10 +27,8 @@ AnnouncerManager::AnnouncerManager() CStringArray arrayAnnouncerNames; GetAnnouncerNames( arrayAnnouncerNames ); -// for( int i=0; im_sAnnouncer ); + for( int i=0; iWriteLine("AnnouncerManager::SwitchAnnouncer()"); - if( sAnnouncerName == "" ) - { - m_sCurAnnouncerName = ""; - return; - } - + return true; CStringArray asAnnouncerNames; GetAnnouncerNames( asAnnouncerNames ); for( int i=0; iWriteLine("Announcer '" + sAnnouncerName + "' does not exist."); - -announcer_exists: - - m_sCurAnnouncerName = sAnnouncerName; - CString sAnnouncerDir = GetAnnouncerDirFromName( m_sCurAnnouncerName ); - if( !DoesFileExist( sAnnouncerDir ) ) - throw RageException( "Error loading the announcer in diretory '%s'.", m_sCurAnnouncerName ); - - LOG->WriteLine("Announcer successfully switched to '" + sAnnouncerName + "'."); + if( 0==stricmp(sAnnouncerName, asAnnouncerNames[i]) ) + return true; + return false; } void AnnouncerManager::AssertAnnouncerIsComplete( CString sAnnouncerName ) @@ -83,8 +61,8 @@ void AnnouncerManager::AssertAnnouncerIsComplete( CString sAnnouncerName ) for( int i=0; iGetCurrentStyleDef()->m_iColsPerPlayer-1)/2.0f; - float fPixelOffsetFromCenter = fColOffsetFromCenter * ARROW_SIZE; + float fPixelOffsetFromCenter = GAMESTATE->GetCurrentStyleDef()->m_ColumnInfo[PLAYER_1][iColNum].fXOffset; // BUG OR FEATURE??? THIS IS WHERE THE REAL COLUMN PLACEMENT HAPPENS!!! // GAMEMANAGER SITS AROUND ON ITS ASS DOING NOTHING @@ -44,22 +44,27 @@ float ArrowGetXPos( const PlayerOptions& po, int iColNum, float fYOffset, float // can possibly change my arrow placements, Ez2dancer column setups will be here until // somebody makes some other system. In the meantime, if it works, i'm using it. - if ( GAMEMAN->m_CurGame == GAME_EZ2 ) + // Chris: + // It's working now, so I'm commenting out your placement code below. + + /* + if ( GAMESTATE->m_CurGame == GAME_EZ2 ) { fPixelOffsetFromCenter = fColOffsetFromCenter * ARROW_SIZE / 1.3f; - if ( GAMEMAN->m_CurStyle == STYLE_EZ2_REAL || GAMEMAN->m_CurStyle == STYLE_EZ2_REAL_VERSUS ) // real gets MEGA squashed + if ( GAEMSTATE->m_CurStyle == STYLE_EZ2_REAL || GAEMSTATE->m_CurStyle == STYLE_EZ2_REAL_VERSUS ) // real gets MEGA squashed { fPixelOffsetFromCenter = fColOffsetFromCenter * ARROW_SIZE / 1.6f; } - else if ( GAMEMAN->m_CurStyle == STYLE_EZ2_DOUBLE && GAMEMAN->m_sMasterPlayerNumber == PLAYER_1) + else if ( GAEMSTATE->m_CurStyle == STYLE_EZ2_DOUBLE && GAEMSTATE->m_sMasterPlayerNumber == PLAYER_1) { fPixelOffsetFromCenter = (fColOffsetFromCenter + 2.9f) * ARROW_SIZE / 1.3f; } - else if ( GAMEMAN->m_CurStyle == STYLE_EZ2_DOUBLE && GAMEMAN->m_sMasterPlayerNumber == PLAYER_2) + else if ( GAEMSTATE->m_CurStyle == STYLE_EZ2_DOUBLE && GAEMSTATE->m_sMasterPlayerNumber == PLAYER_2) { fPixelOffsetFromCenter = (fColOffsetFromCenter - 3.1f) * ARROW_SIZE / 1.3f; } } + */ switch( po.m_EffectType ) { diff --git a/stepmania/src/BPMDisplay.cpp b/stepmania/src/BPMDisplay.cpp index f41121f282..a406a2c877 100644 --- a/stepmania/src/BPMDisplay.cpp +++ b/stepmania/src/BPMDisplay.cpp @@ -12,7 +12,7 @@ #include "BPMDisplay.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" @@ -44,9 +44,9 @@ BPMDisplay::BPMDisplay() m_textLabel.SetDiffuseColorTopEdge( D3DXCOLOR(1,1,0,1) ); // yellow m_textLabel.SetDiffuseColorBottomEdge( D3DXCOLOR(1,0.5f,0,1) ); // orange - //this->AddActor( &m_rectFrame ); - this->AddActor( &m_textBPM ); - this->AddActor( &m_textLabel ); + //this->AddSubActor( &m_rectFrame ); + this->AddSubActor( &m_textBPM ); + this->AddSubActor( &m_textLabel ); } diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 45a8ba5bbb..c0b57e8fa5 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -12,7 +12,7 @@ #include "Background.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "PrefsManager.h" #include "RageBitmapTexture.h" @@ -300,7 +300,7 @@ void Background::DrawPrimitives() bool Background::DangerVisible() { - return m_bInDanger && (TIMER->GetTimeSinceStart() - (int)TIMER->GetTimeSinceStart()) > 0.5f; + return m_bInDanger && (TIMER->GetTimeSinceStart() - (int)TIMER->GetTimeSinceStart()) < 0.5f; } diff --git a/stepmania/src/Banner.cpp b/stepmania/src/Banner.cpp index 2a1444b626..d019962a58 100644 --- a/stepmania/src/Banner.cpp +++ b/stepmania/src/Banner.cpp @@ -12,7 +12,7 @@ #include "RageUtil.h" #include "Banner.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "SongManager.h" #include "RageBitmapTexture.h" diff --git a/stepmania/src/BannerWithFrame.cpp b/stepmania/src/BannerWithFrame.cpp index 6d4d8577f9..2ac8ac5dbd 100644 --- a/stepmania/src/BannerWithFrame.cpp +++ b/stepmania/src/BannerWithFrame.cpp @@ -13,7 +13,7 @@ #include "BannerWithFrame.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" @@ -23,8 +23,8 @@ BannerWithFrame::BannerWithFrame() m_sprBannerFrame.Load( THEME->GetPathTo(GRAPHIC_EVALUATION_BANNER_FRAME) ); m_Banner.SetCroppedSize( m_sprBannerFrame.GetUnzoomedWidth()-6, m_sprBannerFrame.GetUnzoomedHeight()-6 ); - this->AddActor( &m_Banner ); - this->AddActor( &m_sprBannerFrame ); + this->AddSubActor( &m_Banner ); + this->AddSubActor( &m_sprBannerFrame ); } void BannerWithFrame::LoadFromSong( Song* pSong ) diff --git a/stepmania/src/Combo.cpp b/stepmania/src/Combo.cpp index 9f8f17b7c2..85c379abe2 100644 --- a/stepmania/src/Combo.cpp +++ b/stepmania/src/Combo.cpp @@ -1,16 +1,17 @@ #include "stdafx.h" /* ----------------------------------------------------------------------------- - File: Combo.h + Class: Combo - Desc: A graphic displayed in the Combo during Dancing. + Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ #include "Combo.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenManager.h" #include "ScreenGameplay.h" @@ -35,8 +36,8 @@ Combo::Combo() m_sprCombo.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible - this->AddActor( &m_textComboNumber ); - this->AddActor( &m_sprCombo ); + this->AddSubActor( &m_textComboNumber ); + this->AddSubActor( &m_sprCombo ); } diff --git a/stepmania/src/Combo.h b/stepmania/src/Combo.h index db16dc9fcc..3a47723bae 100644 --- a/stepmania/src/Combo.h +++ b/stepmania/src/Combo.h @@ -1,21 +1,18 @@ +#pragma once /* ----------------------------------------------------------------------------- - File: Combo.h + Class: Combo - Desc: A graphic displayed in the Combo during Dancing. + Desc: Text that displays the size of the current combo. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ - -#ifndef _Combo_H_ -#define _Combo_H_ - - #include "ActorFrame.h" #include "Sprite.h" -#include "ScoreDisplayRolling.h" +#include "BitmapText.h" @@ -38,5 +35,3 @@ protected: Sprite m_sprCombo; BitmapText m_textComboNumber; }; - -#endif \ No newline at end of file diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 444e6d9ad8..ea8cbf98e8 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -11,8 +11,11 @@ */ #include "Course.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "Song.h" +#include "GameManager.h" +#include "SongManager.h" +#include "GameState.h" void Course::LoadFromCRSFile( CString sPath, CArray &apSongs ) @@ -88,13 +91,77 @@ void Course::LoadFromCRSFile( CString sPath, CArray &apSongs ) if( pSong == NULL ) // we didn't find the Song continue; // skip this song - - DifficultyClass dc = Notes::DifficultyClassFromDescriptionAndMeter( sNotesDescription, 6 ); - AddStage( pSong, dc ); + AddStage( pSong, sNotesDescription ); } else LOG->WriteLine( "Unexpected value named '%s'", sValueName ); } } + + +void Course::CreateFromGroupAndDifficultyClass( CString sGroupName, DifficultyClass dc, CArray &apSongsInGroup ) +{ + CString sShortGroupName = SONGMAN->ShortenGroupName( sGroupName ); + + m_sName = sShortGroupName + " "; + switch( dc ) + { + case CLASS_EASY: m_sName += "Easy"; break; + case CLASS_MEDIUM: m_sName += "Medium"; break; + case CLASS_HARD: m_sName += "Hard"; break; + } + + for( int s=0; sm_apNotes.GetSize(); i++ ) + { + Notes* pNotes = pSong->m_apNotes[i]; + if( 0==stricmp(pNotes->m_sDescription, sDescription) && + pNotes->m_NotesType == GAMESTATE->GetCurrentStyleDef()->m_NotesType ) + return pNotes; + } + + + // Didn't find a matching description. Try to match the DifficultyClass instead. + DifficultyClass dc = Notes::DifficultyClassFromDescriptionAndMeter( sDescription, 5 ); + + for( i=0; im_apNotes.GetSize(); i++ ) + { + Notes* pNotes = pSong->m_apNotes[i]; + if( pNotes->m_DifficultyClass == dc ) + return pNotes; + } + + + return NULL; +} + + +void Course::GetSongAndNotesForCurrentStyle( CArray& apSongsOut, CArray apNotesOut[NUM_PLAYERS] ) +{ + for( int i=0; i &apSongs ); - void AddStage( Song* pSong, DifficultyClass dc ) + void LoadFromCRSFile( CString sPath, CArray &apSongs ); + void CreateFromGroupAndDifficultyClass( CString sGroupName, DifficultyClass dc, CArray &apSongsInGroup ); + + void AddStage( Song* pSong, CString sDescription ) { ASSERT( m_iStages <= MAX_COURSE_STAGES ); m_apSongs[m_iStages] = pSong; - m_aDifficultyClasses[m_iStages] = dc; + m_asDescriptions[m_iStages] = sDescription; m_iStages++; } + void GetSongAndNotesForCurrentStyle( CArray& apSongsOut, CArray apNotesOut[NUM_PLAYERS] ); }; diff --git a/stepmania/src/CourseContentsFrame.cpp b/stepmania/src/CourseContentsFrame.cpp index 6e4d6053c3..1a8741d279 100644 --- a/stepmania/src/CourseContentsFrame.cpp +++ b/stepmania/src/CourseContentsFrame.cpp @@ -13,74 +13,156 @@ #include "CourseContentsFrame.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" #include "PrefsManager.h" #include "Course.h" +#include "SongManager.h" + + +const float TEXT_BANNER_X = 0; +const float TEXT_BANNER_Y = 0; + +const float NUMBER_X = -118; +const float NUMBER_Y = 0; + +const float FOOT_X = 102; +const float FOOT_Y = 8; + +const float DIFFICULTY_X = FOOT_X+18; +const float DIFFICULTY_Y = FOOT_Y; + +const float CONTENTS_BAR_WIDTH = 270; +const float CONTENTS_BAR_HEIGHT = 44; + + +CourseContentDisplay::CourseContentDisplay() +{ + m_sprFrame.Load( THEME->GetPathTo(GRAPHIC_SELECT_COURSE_CONTENT_BAR) ); + this->AddSubActor( &m_sprFrame ); + + m_textNumber.Load( THEME->GetPathTo(FONT_HEADER2) ); + m_textNumber.SetXY( NUMBER_X, NUMBER_Y ); + m_textNumber.TurnShadowOff(); + this->AddSubActor( &m_textNumber ); + + m_TextBanner.SetXY( TEXT_BANNER_X, TEXT_BANNER_Y ); + this->AddSubActor( &m_TextBanner ); + + m_textFoot.Load( THEME->GetPathTo(FONT_METER) ); + m_textFoot.SetXY( FOOT_X, FOOT_Y ); + m_textFoot.TurnShadowOff(); + this->AddSubActor( &m_textFoot ); + + m_textDifficultyNumber.Load( THEME->GetPathTo(FONT_NORMAL) ); + m_textDifficultyNumber.SetXY( DIFFICULTY_X, DIFFICULTY_Y ); + m_textDifficultyNumber.SetZoom( 0.8f ); + m_textDifficultyNumber.TurnShadowOff(); + this->AddSubActor( &m_textDifficultyNumber ); +} + +void CourseContentDisplay::Load( int iNum, Song* pSong, Notes* pNotes ) +{ + m_textNumber.SetText( ssprintf("%d", iNum) ); + + D3DXCOLOR colorGroup = SONGMAN->GetGroupColor( pSong->m_sGroupName ); + D3DXCOLOR colorDifficulty = DifficultyClassToColor( pNotes->m_DifficultyClass ); + + m_TextBanner.LoadFromSong( pSong ); + m_TextBanner.SetDiffuseColor( colorGroup ); + + m_textFoot.SetText( "1" ); + m_textFoot.SetDiffuseColor( colorDifficulty ); + + m_textDifficultyNumber.SetText( ssprintf("%d", pNotes->m_iMeter) ); + m_textDifficultyNumber.SetDiffuseColor( colorDifficulty ); +} -const float NAME_X = -100; -const float METER_X = +50; -const float GAP_Y = 34; -const float START_Y = 0 - MAX_COURSE_CONTENTS/2*GAP_Y; CourseContentsFrame::CourseContentsFrame() { - for( int i=0; iGetPathTo(FONT_TEXT_BANNER) ); - m_textContents[i].SetHorizAlign( Actor::align_left ); - m_textContents[i].SetXY( NAME_X, START_Y + GAP_Y*i ); - m_textContents[i].SetText( "" ); - m_textContents[i].SetZoom( 0.7f ); - this->AddActor( &m_textContents[i] ); + m_iNumContents = 0; + m_quad.SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); // invisible, since we want to write only to the Zbuffer - m_Meters[i].SetXY( METER_X, START_Y + GAP_Y*i + 10 ); - this->AddActor( &m_Meters[i] ); - } -} - -void CourseContentsFrame::Update( float fDeltaTime ) -{ - ActorFrame::Update( fDeltaTime ); + m_fTimeUntilScroll = 0; + m_fItemAtTopOfList = 0; } void CourseContentsFrame::SetFromCourse( Course* pCourse ) { ASSERT( pCourse != NULL ); - int i; + m_fTimeUntilScroll = 3; + m_fItemAtTopOfList = 0; - // turn all lines "off" - for( i=0; im_iStages, MAX_TOTAL_CONTENTS); i++ ) { - m_textContents[i].SetText( "" ); - m_Meters[i].SetFromNotes( NULL ); - } - - for( i=0; im_iStages, MAX_COURSE_CONTENTS); i++ ) - { - m_textContents[i].SetText( pCourse->m_apSongs[i]->GetFullTitle() ); - m_textContents[i].SetDiffuseColor( DifficultyClassToColor(pCourse->m_aDifficultyClasses[i]) ); - - m_Meters[i].SetFromNotes( NULL ); - Song* pSong = pCourse->m_apSongs[i]; - for( int j=0; jm_apNotes.GetSize(); j++ ) - { - Notes* pNotes = pSong->m_apNotes[j]; - if( pSong->m_apNotes[j]->m_DifficultyClass == pCourse->m_aDifficultyClasses[i] ) - { - m_Meters[i].SetFromNotes( pNotes ); - break; - } - } + Notes* pNotes = pCourse->GetNotesForStage(i); - } + if( pNotes == NULL ) + continue; // skip - if( pCourse->m_iStages >= MAX_COURSE_CONTENTS ) - { - m_textContents[MAX_COURSE_CONTENTS-1].SetText( ssprintf("%d more...", pCourse->m_iStages-(MAX_COURSE_CONTENTS-1)) ); - m_Meters[MAX_COURSE_CONTENTS-1].SetFromNotes( NULL ); + printf( "Adding song '%s'\n", pSong->m_sMainTitle ); + m_CourseContentDisplays[m_iNumContents].Load( m_iNumContents+1, pSong, pNotes ); + + m_iNumContents ++; } + printf( "m_iNumContents is %d\n", m_iNumContents ); +} + +void CourseContentsFrame::Update( float fDeltaTime ) +{ + if( m_fTimeUntilScroll > 0 && m_iNumContents > MAX_VISIBLE_CONTENTS) + m_fTimeUntilScroll -= fDeltaTime; + if( m_fTimeUntilScroll <= 0 ) + m_fItemAtTopOfList += fDeltaTime; + if( m_fItemAtTopOfList > m_iNumContents ) + m_fItemAtTopOfList -= m_iNumContents; + + for( int i=0; iGetDevice(); + pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE ); + pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE ); + + + // write to z buffer so that top and bottom are clipped + m_quad.SetZ( -1 ); + + CRect rectBarSize(-(int)CONTENTS_BAR_WIDTH/2, -(int)CONTENTS_BAR_HEIGHT/2, (int)CONTENTS_BAR_WIDTH/2, (int)CONTENTS_BAR_HEIGHT/2); + m_quad.StretchTo( rectBarSize ); + + m_quad.SetY( (-(MAX_VISIBLE_CONTENTS-1)/2 - 1) * CONTENTS_BAR_HEIGHT ); + m_quad.Draw(); + + m_quad.SetY( ((MAX_VISIBLE_CONTENTS-1)/2 + 1) * CONTENTS_BAR_HEIGHT ); + m_quad.Draw(); + + + int iItemToDraw = (int)m_fItemAtTopOfList; + float fY = (iItemToDraw-m_fItemAtTopOfList-(MAX_VISIBLE_CONTENTS-1)/2) * CONTENTS_BAR_HEIGHT; + + for( int i=0; i= m_iNumContents ) + iItemToDraw -= m_iNumContents; + fY += CONTENTS_BAR_HEIGHT; + } + + + // turn off Z buffer + pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE ); + pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE ); } diff --git a/stepmania/src/CourseContentsFrame.h b/stepmania/src/CourseContentsFrame.h index ddb7519d8d..95c6d20993 100644 --- a/stepmania/src/CourseContentsFrame.h +++ b/stepmania/src/CourseContentsFrame.h @@ -12,22 +12,51 @@ #include "FootMeter.h" #include "BitmapText.h" +#include "TextBanner.h" #include "ActorFrame.h" +#include "Sprite.h" +#include "Quad.h" class Course; +class Song; +struct Notes; + + +const int MAX_VISIBLE_CONTENTS = 5; +const int MAX_TOTAL_CONTENTS = 56; + + +class CourseContentDisplay : public ActorFrame +{ +public: + CourseContentDisplay(); + + void Load( int iNum, Song* pSong, Notes* pNotes ); + + Sprite m_sprFrame; + BitmapText m_textNumber; + TextBanner m_TextBanner; + BitmapText m_textFoot; + BitmapText m_textDifficultyNumber; +}; -const int MAX_COURSE_CONTENTS = 8; class CourseContentsFrame : public ActorFrame { public: CourseContentsFrame(); - void Update( float fDeltaTime ); + virtual void Update( float fDeltaTime ); + virtual void DrawPrimitives(); void SetFromCourse( Course* pCourse ); protected: - BitmapText m_textContents[MAX_COURSE_CONTENTS]; - FootMeter m_Meters[MAX_COURSE_CONTENTS]; + Quad m_quad; + + int m_iNumContents; + CourseContentDisplay m_CourseContentDisplays[MAX_TOTAL_CONTENTS]; + + float m_fTimeUntilScroll; + float m_fItemAtTopOfList; // between 0 and m_iNumContents }; diff --git a/stepmania/src/CroppedSprite.cpp b/stepmania/src/CroppedSprite.cpp index c530741f2b..4395d85511 100644 --- a/stepmania/src/CroppedSprite.cpp +++ b/stepmania/src/CroppedSprite.cpp @@ -12,7 +12,7 @@ #include "RageUtil.h" #include "CroppedSprite.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageBitmapTexture.h" diff --git a/stepmania/src/DifficultyIcon.cpp b/stepmania/src/DifficultyIcon.cpp index bbe96c65fa..fed15e4517 100644 --- a/stepmania/src/DifficultyIcon.cpp +++ b/stepmania/src/DifficultyIcon.cpp @@ -12,7 +12,7 @@ #include "DifficultyIcon.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" diff --git a/stepmania/src/DifficultyIcon.h b/stepmania/src/DifficultyIcon.h index 2cd3ebdaed..c5e4f37a9e 100644 --- a/stepmania/src/DifficultyIcon.h +++ b/stepmania/src/DifficultyIcon.h @@ -14,7 +14,7 @@ #include "Sprite.h" #include "Song.h" #include "BitmapText.h" -#include "ThemeManager.h" +#include "PrefsManager.h" class DifficultyIcon : public Sprite diff --git a/stepmania/src/FocusingSprite.cpp b/stepmania/src/FocusingSprite.cpp index 8f3b292b55..de557bd6d0 100644 --- a/stepmania/src/FocusingSprite.cpp +++ b/stepmania/src/FocusingSprite.cpp @@ -24,7 +24,7 @@ FocusingSprite::FocusingSprite() { for( int i=0; i<3; i++ ) { - this->AddActor( &m_sprites[i] ); + this->AddSubActor( &m_sprites[i] ); } m_fPercentBlurred = 1.0f; diff --git a/stepmania/src/FootMeter.cpp b/stepmania/src/FootMeter.cpp index 7c45c5c7d1..0a97afd402 100644 --- a/stepmania/src/FootMeter.cpp +++ b/stepmania/src/FootMeter.cpp @@ -13,7 +13,7 @@ #include "FootMeter.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" diff --git a/stepmania/src/FootMeter.h b/stepmania/src/FootMeter.h index c952578ce0..e40a8fb268 100644 --- a/stepmania/src/FootMeter.h +++ b/stepmania/src/FootMeter.h @@ -13,7 +13,7 @@ #include "Sprite.h" #include "Song.h" #include "BitmapText.h" -#include "ThemeManager.h" +#include "PrefsManager.h" class FootMeter : public BitmapText diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index 5da958f1e0..50782c9e25 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -353,6 +353,19 @@ inline Game StyleToGame( Style s ) } } +/* + + Chris: + + Very cool system :-) + + However, the NotesType is a property of the StyleDef, so we can look it up there. + Get the the NotesType for a style with: + GAMESTATE->GetCurrentStyleDef()->m_NotesType - or - + GAMEMAN->GetStyleDefForStyle(style)->m_NotesType + I'll add a new method to GAMEMAN called GetStyleThatPlaysNotesType(): + Style s = GAMEMAN->GetStyleThatPlaysNotesType( nt ); + //////////////////////////////// // NotesType/Style conversions //////////////////////////////// @@ -496,7 +509,7 @@ print "\t\tdefault:\treturn NOTES_TYPE_INVALID; <- End of Perl file */ - +/* // // NotesTypeToStyle(nt): Converts nt to a Style // @@ -549,7 +562,7 @@ inline NotesType StyleToNotesType ( Style s ) } } - +*/ /////////////////////////// // Options stuff diff --git a/stepmania/src/GameDef.cpp b/stepmania/src/GameDef.cpp index 512609c2b1..3a01d216fa 100644 --- a/stepmania/src/GameDef.cpp +++ b/stepmania/src/GameDef.cpp @@ -18,7 +18,7 @@ #include "StyleDef.h" -CString GameDef::ElementToGraphicSuffix( const GameButtonGraphic gbg ) +CString GameDef::ElementToGraphicSuffix( const SkinElement gbg ) { CString sAssetPath; // fill this in below @@ -38,10 +38,9 @@ CString GameDef::ElementToGraphicSuffix( const GameButtonGraphic gbg ) return sAssetPath; } -CString GameDef::GetPathToGraphic( const CString sSkinName, const int iInstrumentButton, const GameButtonGraphic gbg ) +CString GameDef::GetPathToGraphic( const CString sSkinName, const CString sButtonName, const SkinElement gbg ) { const CString sSkinDir = ssprintf("Skins\\%s\\%s\\", m_szName, sSkinName); - const CString sButtonName = m_szButtonNames[ iInstrumentButton ]; const CString sGraphicSuffix = ElementToGraphicSuffix( gbg ); CStringArray arrayPossibleFileNames; // fill this with the possible files @@ -58,10 +57,9 @@ CString GameDef::GetPathToGraphic( const CString sSkinName, const int iInstrumen return ""; } -void GameDef::GetTweenColors( const CString sSkinName, const int iInstrumentButton, CArray &arrayTweenColors ) +void GameDef::GetTweenColors( const CString sSkinName, const CString sButtonName, CArray &arrayTweenColors ) { const CString sSkinDir = ssprintf("Skins\\%s\\%s\\", m_szName, sSkinName); - const CString sButtonName = m_szButtonNames[ iInstrumentButton ]; const CString sColorsFilePath = sSkinDir + sButtonName + ".colors"; @@ -115,16 +113,19 @@ void GameDef::AssertSkinsAreComplete() GetSkinNames( asSkinNames ); for( int i=0; i &arrayTweenColors ); - CString ElementToGraphicSuffix( const GameButtonGraphic gbg ); + CString GetPathToGraphic( const CString sSkinName, const CString sButtonName, const SkinElement gbg ); + void GetTweenColors( const CString sSkinName, const CString sButtonName, CArray &arrayTweenColors ); + CString ElementToGraphicSuffix( const SkinElement gbg ); inline MenuInput GameInputToMenuInput( const GameInput GameI ) diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index 9aaad9b434..e03d97961f 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -12,10 +12,13 @@ #include "GameManager.h" #include "PrefsManager.h" +#include "GameConstantsAndTypes.h" +#include "GameState.h" GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program + InstrumentButton DANCE_BUTTON_LEFT = (InstrumentButton)0; InstrumentButton DANCE_BUTTON_RIGHT = (InstrumentButton)1; InstrumentButton DANCE_BUTTON_UP = (InstrumentButton)2; @@ -584,34 +587,28 @@ StyleDef g_StyleDefs[NUM_STYLES] = GameManager::GameManager() { - m_CurGame = GAME_DANCE; - m_CurStyle = STYLE_NONE; - - CStringArray asSkinNames; - GetSkinNames( asSkinNames ); - m_sCurrentSkin = PREFSMAN->m_sNoteSkin; - for( int i=0; iGetSkinNames( AddTo ); + GAMESTATE->GetCurrentGameDef()->GetSkinNames( AddTo ); } -bool GameManager::IsPlayerEnabled( PlayerNumber pn ) +bool GameManager::DoesNoteSkinExist( CString sSkinName ) { - if( m_CurStyle == STYLE_NONE ) // if no style set (we're in TitleMenu, ConfigInstruments or something) - return true; // allow input from both sides - - return ( pn == m_sMasterPlayerNumber ) || - ( GetCurrentStyleDef()->m_StyleType == StyleDef::TWO_PLAYERS_USE_TWO_SIDES ); -}; - -CString GameManager::GetPathToGraphic( const PlayerNumber p, const int col, const GameButtonGraphic gbg ) -{ - StyleInput si( p, col ); - GameInput gi = GetCurrentStyleDef()->StyleInputToGameInput( si ); - InstrumentButton b = gi.button; - return GetCurrentGameDef()->GetPathToGraphic( m_sCurrentSkin, b, gbg ); + CStringArray asSkinNames; + GetNoteSkinNames( asSkinNames ); + for( int i=0; i &aTweenColorsAddTo ) +void GameManager::SwitchNoteSkin( CString sNewNoteSkin ) { - StyleInput StyleI( p, col ); - GameInput GameI = GetCurrentStyleDef()->StyleInputToGameInput( StyleI ); - GetCurrentGameDef()->GetTweenColors( m_sCurrentSkin, GameI.button, aTweenColorsAddTo ); + if( sNewNoteSkin == "" || !DoesNoteSkinExist(sNewNoteSkin) ) + { + CStringArray as; + GetNoteSkinNames( as ); + m_sCurNoteSkin = as[0]; + } + else + m_sCurNoteSkin = sNewNoteSkin; +} + +CString GameManager::GetPathTo( Game g, CString sSkinName, CString sButtonName, const SkinElement gbg ) +{ + return GetGameDefForGame(g)->GetPathToGraphic( sSkinName, sButtonName, gbg ); +} + +void GameManager::GetTweenColors( Game g, CString sSkinName, CString sButtonName, CArray &aTweenColorsAddTo ) +{ + GetGameDefForGame(g)->GetTweenColors( sSkinName, sButtonName, aTweenColorsAddTo ); +} + +CString GameManager::GetPathTo( const int col, const SkinElement gbg ) // looks in GAMESTATE for the current Style +{ + StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); + GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); + + StyleInput SI( PLAYER_1, col ); + GameInput GI = pStyleDef->StyleInputToGameInput( SI ); + CString sButtonName = pGameDef->m_szButtonNames[GI.button]; + return pGameDef->GetPathToGraphic( m_sCurNoteSkin, sButtonName, gbg ); +} + +void GameManager::GetTweenColors( const int col, CArray &aTweenColorsAddTo ) // looks in GAMESTATE for the current Style +{ + ASSERT( m_sCurNoteSkin != "" ); // if this == NULL, SwitchGame() was never called + + StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); + GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); + + StyleInput SI( PLAYER_1, col ); + GameInput GI = pStyleDef->StyleInputToGameInput( SI ); + CString sButtonName = pGameDef->m_szButtonNames[GI.button]; + pGameDef->GetTweenColors( m_sCurNoteSkin, sButtonName, aTweenColorsAddTo ); } diff --git a/stepmania/src/GameManager.h b/stepmania/src/GameManager.h index 0f095972dc..b1d31750ae 100644 --- a/stepmania/src/GameManager.h +++ b/stepmania/src/GameManager.h @@ -14,28 +14,35 @@ #include "StyleDef.h" -const int MAX_GAME_DEFS = 10; - - class GameManager { public: GameManager(); - Game m_CurGame; - Style m_CurStyle; - NotesType m_CurNotesType; // only used in Edit - CString m_sCurrentSkin; - PlayerNumber m_sMasterPlayerNumber; + GameDef* GetGameDefForGame( Game g ); + StyleDef* GetStyleDefForStyle( Style s ); - GameDef* GetCurrentGameDef(); - StyleDef* GetCurrentStyleDef(); + Style GetStyleThatPlaysNotesType( NotesType nt ); void GetGameNames( CStringArray &AddTo ); - void GetSkinNames( CStringArray &AddTo ); - bool IsPlayerEnabled( PlayerNumber PlayerNo ); - CString GetPathToGraphic( const PlayerNumber p, const int col, const GameButtonGraphic gbg ); - void GetTweenColors( const PlayerNumber p, const int col, CArray &aTweenColorsAddTo ); + bool DoesGameExist( CString sGameName ); + void SwitchGame( Game newGame ); + + void GetNoteSkinNames( CStringArray &AddTo ); // looks up current Game in GAMESTATE + bool DoesNoteSkinExist( CString sSkinName ); // looks up current Game in GAMESTATE + void SwitchNoteSkin( CString sNewNoteSkin ); // looks up current Game in GAMESTATE + CString GetCurNoteSkin() { return m_sCurNoteSkin; }; + + CString GetPathTo( const int col, const SkinElement gbg ); // looks in GAMESTATE for the current Style + void GetTweenColors( const int col, CArray &aTweenColorsAddTo ); // looks in GAMESTATE for the current Style + +protected: + + CString GetPathTo( Game g, CString sSkinName, CString sButtonName, const SkinElement gbg ); + void GetTweenColors( Game g, CString sSkinName, CString sButtonName, CArray &aTweenColorsAddTo ); + + CString m_sCurNoteSkin; + }; extern GameManager* GAMEMAN; // global and accessable from anywhere in our program diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp new file mode 100644 index 0000000000..ad8d90e6bc --- /dev/null +++ b/stepmania/src/GameState.cpp @@ -0,0 +1,154 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: GameState + + Desc: See Header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "GameState.h" +#include "IniFile.h" +#include "GameManager.h" +#include "PrefsManager.h" +#include "InputMapper.h" + + +GameState* GAMESTATE = NULL; // global and accessable from anywhere in our program + + +GameState::GameState() +{ + m_sLoadingMessage = "Initializing hardware..."; + Reset(); +} + +GameState::~GameState() +{ +} + +void GameState::Reset() +{ + int p; + + m_pCurSong = NULL; + for( p=0; p= 0 && newGame < NUM_GAMES ); + + m_CurGame = newGame; +} + +int GameState::GetStageIndex() +{ + return m_iCurrentStageIndex; +} + +bool GameState::IsFinalStage() +{ + if( PREFSMAN->m_bEventMode ) + return false; + return m_iCurrentStageIndex == PREFSMAN->m_iNumArcadeStages-1; +} + +bool GameState::IsExtraStage() +{ + if( PREFSMAN->m_bEventMode ) + return false; + return m_iCurrentStageIndex == PREFSMAN->m_iNumArcadeStages; +} + +bool GameState::IsExtraStage2() +{ + if( PREFSMAN->m_bEventMode ) + return false; + return m_iCurrentStageIndex == PREFSMAN->m_iNumArcadeStages+1; +} + +CString GameState::GetStageText() +{ + if( IsFinalStage() ) + return "Final"; + else if( IsExtraStage() ) + return "Extra"; + else if( IsExtraStage2() ) + return "Extra 2"; + + + int iStageNo = m_iCurrentStageIndex+1; + + CString sNumberSuffix; + if( ( (iStageNo/10) % 10 ) == 1 ) // in the teens (e.g. 19, 213) + { + sNumberSuffix = "th"; + } + else // not in the teens + { + const int iLastDigit = iStageNo%10; + switch( iLastDigit ) + { + case 1: sNumberSuffix = "st"; break; + case 2: sNumberSuffix = "nd"; break; + case 3: sNumberSuffix = "rd"; break; + default:sNumberSuffix = "th"; break; + } + } + return ssprintf( "%d%s", iStageNo, sNumberSuffix ); +} + +D3DXCOLOR GameState::GetStageColor() +{ + if( IsFinalStage() ) + return D3DXCOLOR(1,0.1f,0.1f,1); // red + else if( IsExtraStage() || IsExtraStage2() ) + return D3DXCOLOR(1,1,0.3f,1); // yellow + else + return D3DXCOLOR(0.3f,1,0.3f,1); // green +} + +GameplayStatistics& GameState::GetLatestGameplayStatistics() +{ + ASSERT( m_aGameplayStatistics.GetSize() > 0 ); + return m_aGameplayStatistics[ m_aGameplayStatistics.GetSize()-1 ]; +} + +GameDef* GameState::GetCurrentGameDef() +{ + return GAMEMAN->GetGameDefForGame( m_CurGame ); +} + +StyleDef* GameState::GetCurrentStyleDef() +{ + return GAMEMAN->GetStyleDefForStyle( m_CurStyle ); +} + +bool GameState::IsPlayerEnabled( PlayerNumber pn ) +{ + if( m_CurStyle == STYLE_NONE ) // if no style set (we're in TitleMenu, ConfigInstruments or something) + return true; // allow input from both sides + + return ( pn == m_MasterPlayerNumber ) || + ( GetCurrentStyleDef()->m_StyleType == StyleDef::TWO_PLAYERS_USE_TWO_SIDES ); +}; diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h new file mode 100644 index 0000000000..9c18b285c5 --- /dev/null +++ b/stepmania/src/GameState.h @@ -0,0 +1,81 @@ +#pragma once +/* +----------------------------------------------------------------------------- + Class: GameState + + Desc: Holds game data that is not saved between sessions. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "GameConstantsAndTypes.h" +#include "GameplayStatistics.h" + + +class Song; +struct Notes; +class Course; +class GameDef; +class StyleDef; + + +class GameState +{ +public: + GameState(); + ~GameState(); + void Reset(); + + Song* m_pCurSong; + Notes* m_pCurNotes[NUM_PLAYERS]; + Course* m_pCurCourse; + int m_iCoursePossibleDancePoints; + + // Info used during gameplay + // Let lots of classes access the music beat here so we don't have to pass it around everywhere + float m_fMusicSeconds; + float m_fMusicBeat; + float m_fCurBPS; + bool m_bFreeze; + + CArray m_aGameplayStatistics; // for passing from Dancing to Results + GameplayStatistics& GetLatestGameplayStatistics(); + +protected: + Game m_CurGame; +public: + Game GetCurGame() { return m_CurGame; }; + void SwitchGame( Game newGame ); + Style m_CurStyle; + PlayerNumber m_MasterPlayerNumber; + + GameDef* GetCurrentGameDef(); + StyleDef* GetCurrentStyleDef(); + + bool IsPlayerEnabled( PlayerNumber pn ); + //bool IsPlayerEnabled( int p ) { return IsPlayerEnabled( (PlayerNumber)p ); }; // for those too lasy to cast all those p's to a PlayerNumber + + + CString m_sLoadingMessage; + CString m_sPreferredGroup; + DifficultyClass m_PreferredDifficultyClass[NUM_PLAYERS]; + SongSortOrder m_SongSortOrder; // used by MusicWheel + PlayMode m_PlayMode; + int m_iCurrentStageIndex; // starts at 0, and is incremented with each Stage Clear + + int GetStageIndex(); + bool IsFinalStage(); + bool IsExtraStage(); + bool IsExtraStage2(); + CString GetStageText(); + D3DXCOLOR GetStageColor(); + + + PlayerOptions m_PlayerOptions[NUM_PLAYERS]; + SongOptions m_SongOptions; +}; + + +extern GameState* GAMESTATE; // global and accessable from anywhere in our program diff --git a/stepmania/src/GhostArrow.cpp b/stepmania/src/GhostArrow.cpp index 72b2e6de21..789b29fc0c 100644 --- a/stepmania/src/GhostArrow.cpp +++ b/stepmania/src/GhostArrow.cpp @@ -5,7 +5,7 @@ ////////////////////////////////////////////////////////////////////// #include "GhostArrow.h" -#include "ThemeManager.h" +#include "PrefsManager.h" const float GRAY_ARROW_TWEEN_TIME = 0.5f; diff --git a/stepmania/src/GhostArrowBright.cpp b/stepmania/src/GhostArrowBright.cpp index e1c256f01a..cc218f3344 100644 --- a/stepmania/src/GhostArrowBright.cpp +++ b/stepmania/src/GhostArrowBright.cpp @@ -5,7 +5,7 @@ ////////////////////////////////////////////////////////////////////// #include "GhostArrowBright.h" -#include "ThemeManager.h" +#include "PrefsManager.h" const float GRAY_ARROW_TWEEN_TIME = 0.5f; diff --git a/stepmania/src/GhostArrowRow.cpp b/stepmania/src/GhostArrowRow.cpp index 8411006a48..e03f47d3b3 100644 --- a/stepmania/src/GhostArrowRow.cpp +++ b/stepmania/src/GhostArrowRow.cpp @@ -12,11 +12,12 @@ #include "GhostArrowRow.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ColorNote.h" #include "ArrowEffects.h" #include "GameManager.h" - +#include "GameState.h" +#include "PrefsManager.h" GhostArrowRow::GhostArrowRow() @@ -28,16 +29,16 @@ void GhostArrowRow::Load( PlayerNumber pn, StyleDef* pStyleDef, PlayerOptions po { m_PlayerOptions = po; - GameDef* pGameDef = GAMEMAN->GetCurrentGameDef(); + GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); m_iNumCols = pStyleDef->m_iColsPerPlayer; // init arrows for( int c=0; cGetPathToGraphic(pn, c, GRAPHIC_TAP_EXPLOSION_DIM) ); - m_GhostArrowRowBright[c].Load( GAMEMAN->GetPathToGraphic(pn, c, GRAPHIC_TAP_EXPLOSION_BRIGHT) ); - m_HoldGhostArrowRow[c].Load( GAMEMAN->GetPathToGraphic(pn, c, GRAPHIC_HOLD_EXPLOSION) ); + m_GhostArrowRow[c].Load( GAMEMAN->GetPathTo(c, GRAPHIC_TAP_EXPLOSION_DIM) ); + m_GhostArrowRowBright[c].Load( GAMEMAN->GetPathTo(c, GRAPHIC_TAP_EXPLOSION_BRIGHT) ); + m_HoldGhostArrowRow[c].Load( GAMEMAN->GetPathTo(c, GRAPHIC_HOLD_EXPLOSION) ); m_GhostArrowRow[c].SetX( pStyleDef->m_ColumnInfo[pn][c].fXOffset ); m_GhostArrowRowBright[c].SetX( pStyleDef->m_ColumnInfo[pn][c].fXOffset ); diff --git a/stepmania/src/GradeDisplay.cpp b/stepmania/src/GradeDisplay.cpp index 06995a1098..96c3cb36a7 100644 --- a/stepmania/src/GradeDisplay.cpp +++ b/stepmania/src/GradeDisplay.cpp @@ -15,7 +15,7 @@ #include "GradeDisplay.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" const float SCROLL_TIME = 5.0f; diff --git a/stepmania/src/GradeDisplay.h b/stepmania/src/GradeDisplay.h index 17c3ff2ca9..d177840eab 100644 --- a/stepmania/src/GradeDisplay.h +++ b/stepmania/src/GradeDisplay.h @@ -12,7 +12,7 @@ #include "Sprite.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "Grade.h" diff --git a/stepmania/src/GrayArrow.cpp b/stepmania/src/GrayArrow.cpp index ab0b2379cf..a2dfe8b995 100644 --- a/stepmania/src/GrayArrow.cpp +++ b/stepmania/src/GrayArrow.cpp @@ -12,7 +12,7 @@ */ #include "GrayArrow.h" -#include "ThemeManager.h" +#include "PrefsManager.h" const float GRAY_ARROW_POP_UP_TIME = 0.15f; diff --git a/stepmania/src/GrayArrowRow.cpp b/stepmania/src/GrayArrowRow.cpp index 23f181c4ef..a24604ba45 100644 --- a/stepmania/src/GrayArrowRow.cpp +++ b/stepmania/src/GrayArrowRow.cpp @@ -13,10 +13,12 @@ #include "GrayArrowRow.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ColorNote.h" #include "ArrowEffects.h" #include "GameManager.h" +#include "GameState.h" +#include "PrefsManager.h" GrayArrowRow::GrayArrowRow() @@ -28,13 +30,13 @@ void GrayArrowRow::Load( PlayerNumber pn, StyleDef* pStyleDef, PlayerOptions po { m_PlayerOptions = po; - GameDef* pGameDef = GAMEMAN->GetCurrentGameDef(); + GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); m_iNumCols = pStyleDef->m_iColsPerPlayer; for( int c=0; cGetPathToGraphic(pn, c, GRAPHIC_RECEPTOR) ); + m_GrayArrow[c].Load( GAMEMAN->GetPathTo(c, GRAPHIC_RECEPTOR) ); m_GrayArrow[c].SetX( pStyleDef->m_ColumnInfo[pn][c].fXOffset ); } diff --git a/stepmania/src/GrooveRadar.cpp b/stepmania/src/GrooveRadar.cpp index a4044bf62a..c11cafad6f 100644 --- a/stepmania/src/GrooveRadar.cpp +++ b/stepmania/src/GrooveRadar.cpp @@ -13,7 +13,7 @@ #include "RageUtil.h" #include "GrooveRadar.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageBitmapTexture.h" #include "GameConstantsAndTypes.h" @@ -22,7 +22,7 @@ float RADAR_VALUE_ROTATION( int iValueIndex ) { return D3DX_PI/2 + D3DX_PI*2 / 5 GrooveRadar::GrooveRadar() { - this->AddActor( &m_GrooveRadarValueMap ); + this->AddSubActor( &m_GrooveRadarValueMap ); for( int c=0; cAddActor( &m_sprRadarLabels[c] ); + this->AddSubActor( &m_sprRadarLabels[c] ); } } @@ -88,7 +88,7 @@ void GrooveRadar::TweenOffScreen() GrooveRadar::GrooveRadarValueMap::GrooveRadarValueMap() { m_sprRadarBase.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_RADAR_BASE) ); - this->AddActor( &m_sprRadarBase ); + this->AddSubActor( &m_sprRadarBase ); for( int p=0; pGetPathTo(GRAPHIC_GAMEPLAY_JUDGEMENT) ); m_sprJudgement.StopAnimating(); m_sprJudgement.TurnShadowOn(); - this->AddActor( &m_sprJudgement ); + this->AddSubActor( &m_sprJudgement ); } void HoldJudgement::Update( float fDeltaTime ) diff --git a/stepmania/src/HoldJudgement.h b/stepmania/src/HoldJudgement.h index ef01b948ee..44ed09aaf2 100644 --- a/stepmania/src/HoldJudgement.h +++ b/stepmania/src/HoldJudgement.h @@ -17,7 +17,7 @@ #include "ActorFrame.h" #include "Song.h" #include "BitmapText.h" -#include "ThemeManager.h" +#include "PrefsManager.h" class HoldJudgement : public ActorFrame diff --git a/stepmania/src/IniFile.cpp b/stepmania/src/IniFile.cpp index 476fa1ff89..187adf9c88 100644 --- a/stepmania/src/IniFile.cpp +++ b/stepmania/src/IniFile.cpp @@ -1,14 +1,16 @@ +#include "stdafx.h" /* ----------------------------------------------------------------------------- - File: IniFile.h + Class: IniFile - Desc: Wrapper for reading and writing an .ini file. + Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Adam Clauss + Chris Danford ----------------------------------------------------------------------------- */ -#include "stdafx.h" #include "IniFile.h" @@ -45,23 +47,26 @@ void IniFile::SetPath(CString newpath) //reads ini file specified using IniFile::SetPath() //returns true if successful, false otherwise -BOOL IniFile::ReadFile() +bool IniFile::ReadFile() { CStdioFile file; - if( !file.Open(path, CFile::modeRead) ) + CFileStatus status; + if (!file.GetStatus(path,status)) + return 0; + int curkey = -1, curval = -1; + if (!file.Open(path, CFile::modeRead)) { error = "Unable to open ini file."; - return FALSE; + return 0; } - - CString line; - int curkey = -1, curval = -1; CString keyname, valuename, value; - while( file.ReadString(line) ) + CString temp; + CString line; + while (file.ReadString(line)) { - if( line != "" ) + if (line != "") { - if( line[0] == '[' && line[line.GetLength()-1] == ']' ) //if a section heading + if (line[0] == '[' && line[line.GetLength()-1] == ']') //if a section heading { keyname = line; keyname.TrimLeft('['); @@ -69,10 +74,7 @@ BOOL IniFile::ReadFile() } else //if a value { - int iIndexOfEqual = line.Find("="); - if( iIndexOfEqual == -1 ) // this is a malformed line - continue; - valuename = line.Left( iIndexOfEqual ); + valuename = line.Left(line.Find("=")); value = line.Right(line.GetLength()-valuename.GetLength()-1); SetValue(keyname,valuename,value); } @@ -85,36 +87,18 @@ BOOL IniFile::ReadFile() //writes data stored in class to ini file void IniFile::WriteFile() { - CStdioFile file; - if( !file.Open(path, CFile::modeCreate | CFile::modeWrite ) ) + FILE* fp = fopen( path, "w" ); + for (int keynum = 0; keynum <= names.GetUpperBound(); keynum++) { - error = "Unable to open ini for writing."; - return; - } - - // foreach key - for( int keynum = 0; keynum <= names.GetUpperBound(); keynum++ ) - { - CString sTemp; - sTemp.Format( "[%s]\n", names[keynum] ); - file.WriteString( sTemp ); - - CMapStringToString &map = keys[keynum]; - - // for each value_name/value pair - for( POSITION pos = map.GetStartPosition(); pos != NULL; ) + if (keys[keynum].names.GetSize() != 0) { - CString value_name; - CString value; - map.GetNextAssoc( pos, value_name, value ); - - sTemp.Format( "%s=%s\n", value_name, value ); - file.WriteString( sTemp ); + fprintf( fp, "[%s]\n", names[keynum] ); + for (int valuenum = 0; valuenum <= keys[keynum].names.GetUpperBound(); valuenum++) + fprintf( fp, "%s=%s\n", keys[keynum].names[valuenum], keys[keynum].values[valuenum] ); + fprintf( fp, "\n" ); } - file.WriteString( "\n" ); } - - file.Close(); + fclose( fp ); } //deletes all stored ini data @@ -130,68 +114,71 @@ int IniFile::GetNumKeys() return keys.GetSize(); } -//returns a pointer to the key for direct modification -CMapStringToString* IniFile::GetKeyPointer( CString keyname ) -{ - int keynum = FindKey(keyname); - if (keynum == -1) - return NULL; - else - return &keys[keynum]; -} - -//returns number of values stored for specified key, or -1 if key not found +//returns number of values stored for specified key, or -1 if key found int IniFile::GetNumValues(CString keyname) { int keynum = FindKey(keyname); if (keynum == -1) return -1; else - return keys[keynum].GetCount(); + return keys[keynum].names.GetSize(); } //gets value of [keyname] valuename = //overloaded to return CString, int, and double -bool IniFile::GetValue(CString keyname, CString valuename, CString &value_out) +bool IniFile::GetValue(CString keyname, CString valuename, CString& value) { - int keynum = FindKey(keyname);//, valuenum = FindValue(keynum,valuename); - if( keynum == -1 ) - return false; + int keynum = FindKey(keyname), valuenum = FindValue(keynum,valuename); - CMapStringToString &map = keys[keynum]; - return 1 == map.Lookup(valuename, value_out); -} - -//gets value of [keyname] valuename = -//overloaded to return CString, int, and double -bool IniFile::GetValueI(CString keyname, CString valuename, int &value_out) -{ - CString sValue; - if( !GetValue(keyname, valuename, sValue) ) + if (keynum == -1) + { + error = "Unable to locate specified key."; return false; - value_out = atoi(sValue); + } + + if (valuenum == -1) + { + error = "Unable to locate specified value."; + return false; + } + + value = keys[keynum].values[valuenum]; return true; } //gets value of [keyname] valuename = //overloaded to return CString, int, and double -bool IniFile::GetValueF(CString keyname, CString valuename, float &value_out) +bool IniFile::GetValueI(CString keyname, CString valuename, int& value) { CString sValue; - if( !GetValue(keyname, valuename, sValue) ) + bool bSuccess = GetValue(keyname,valuename,sValue); + if( !bSuccess ) return false; - value_out = (float)atof(sValue); + value = atoi(sValue); return true; } //gets value of [keyname] valuename = //overloaded to return CString, int, and double -bool IniFile::GetValueB(CString keyname, CString valuename, bool &value_out) +bool IniFile::GetValueF(CString keyname, CString valuename, float& value) { CString sValue; - if( !GetValue(keyname, valuename, sValue) ) + bool bSuccess = GetValue(keyname,valuename,sValue); + if( !bSuccess ) return false; - value_out = sValue == "1"; + value = (float)atof(sValue); + return true; +} + +//gets value of [keyname] valuename = +//overloaded to return CString, int, and double +bool IniFile::GetValueB(CString keyname, CString valuename, bool& value) +{ + CString sValue; + bool bSuccess = GetValue(keyname,valuename,sValue); + if( !bSuccess ) + return false; + value = atoi(sValue) != 0; return true; } @@ -199,34 +186,40 @@ bool IniFile::GetValueB(CString keyname, CString valuename, bool &value_out) //specify the optional paramter as false (0) if you do not want it to create //the key if it doesn't exist. Returns true if data entered, false otherwise //overloaded to accept CString, int, and double -bool IniFile::SetValue(CString keyname, CString valuename, CString value, BOOL create) +bool IniFile::SetValue(CString keyname, CString valuename, CString value, bool create) { - int keynum = FindKey(keyname); - - if( keynum == -1 ) //if key doesn't exist + int keynum = FindKey(keyname), valuenum = 0; + //find key + if (keynum == -1) //if key doesn't exist { - if( !create ) //and user does not want to create it, - return FALSE; //stop entering this key + if (!create) //and user does not want to create it, + return 0; //stop entering this key names.SetSize(names.GetSize()+1); keys.SetSize(keys.GetSize()+1); keynum = names.GetSize()-1; names[keynum] = keyname; } - // insert value - CMapStringToString &map = keys[keynum]; - CString oldvalue; - if( !map.Lookup(valuename, oldvalue) && !create ) - return FALSE; - map[valuename] = value; - return TRUE; + //find value + valuenum = FindValue(keynum,valuename); + if (valuenum == -1) + { + if (!create) + return 0; + keys[keynum].names.SetSize(keys[keynum].names.GetSize()+1); + keys[keynum].values.SetSize(keys[keynum].names.GetSize()+1); + valuenum = keys[keynum].names.GetSize()-1; + keys[keynum].names[valuenum] = valuename; + } + keys[keynum].values[valuenum] = value; + return 1; } //sets value of [keyname] valuename =. //specify the optional paramter as false (0) if you do not want it to create //the key if it doesn't exist. Returns true if data entered, false otherwise //overloaded to accept CString, int, and double -bool IniFile::SetValueI(CString keyname, CString valuename, int value, BOOL create) +bool IniFile::SetValueI(CString keyname, CString valuename, int value, bool create) { CString temp; temp.Format("%d",value); @@ -237,10 +230,10 @@ bool IniFile::SetValueI(CString keyname, CString valuename, int value, BOOL crea //specify the optional paramter as false (0) if you do not want it to create //the key if it doesn't exist. Returns true if data entered, false otherwise //overloaded to accept CString, int, and double -bool IniFile::SetValueF(CString keyname, CString valuename, double value, BOOL create) +bool IniFile::SetValueF(CString keyname, CString valuename, float value, bool create) { CString temp; - temp.Format("%f",value); + temp.Format("%e",value); return SetValue(keyname, valuename, temp, create); } @@ -248,7 +241,7 @@ bool IniFile::SetValueF(CString keyname, CString valuename, double value, BOOL c //specify the optional paramter as false (0) if you do not want it to create //the key if it doesn't exist. Returns true if data entered, false otherwise //overloaded to accept CString, int, and double -bool IniFile::SetValueB(CString keyname, CString valuename, bool value, BOOL create) +bool IniFile::SetValueB(CString keyname, CString valuename, bool value, bool create) { CString temp; temp.Format("%d",value); @@ -257,19 +250,20 @@ bool IniFile::SetValueB(CString keyname, CString valuename, bool value, BOOL cre //deletes specified value //returns true if value existed and deleted, false otherwise -BOOL IniFile::DeleteValue(CString keyname, CString valuename) +bool IniFile::DeleteValue(CString keyname, CString valuename) { - int keynum = FindKey(keyname); - if( keynum == -1 ) - return FALSE; + int keynum = FindKey(keyname), valuenum = FindValue(keynum,valuename); + if (keynum == -1 || valuenum == -1) + return 0; - CMapStringToString &map = keys[keynum]; - return map.RemoveKey( valuename ); + keys[keynum].names.RemoveAt(valuenum); + keys[keynum].values.RemoveAt(valuenum); + return 1; } //deletes specified key and all values contained within //returns true if key existed and deleted, false otherwise -BOOL IniFile::DeleteKey(CString keyname) +bool IniFile::DeleteKey(CString keyname) { int keynum = FindKey(keyname); if (keynum == -1) @@ -279,6 +273,16 @@ BOOL IniFile::DeleteKey(CString keyname) return 1; } +//deletes specified key and all values contained within +//returns true if key existed and deleted, false otherwise +IniFile::key* IniFile::GetKey(CString keyname) +{ + int keynum = FindKey(keyname); + if (keynum == -1) + return NULL; + return &keys[keynum]; +} + ///////////////////////////////////////////////////////////////////// // Private Functions ///////////////////////////////////////////////////////////////////// @@ -294,3 +298,15 @@ int IniFile::FindKey(CString keyname) return keynum; } +//returns index of specified value, in the specified key, or -1 if not found +int IniFile::FindValue(int keynum, CString valuename) +{ + if (keynum == -1) + return -1; + int valuenum = 0; + while (valuenum < keys[keynum].names.GetSize() && keys[keynum].names[valuenum] != valuename) + valuenum++; + if (valuenum == keys[keynum].names.GetSize()) + return -1; + return valuenum; +} diff --git a/stepmania/src/IniFile.h b/stepmania/src/IniFile.h index 3cfc0539c8..349c530b25 100644 --- a/stepmania/src/IniFile.h +++ b/stepmania/src/IniFile.h @@ -1,21 +1,16 @@ +#pragma once /* ----------------------------------------------------------------------------- - File: IniFile.h + Class: IniFile Desc: Wrapper for reading and writing an .ini file. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Adam Clauss + Chris Danford ----------------------------------------------------------------------------- */ - -#ifndef _INIFILE_H_ -#define _INIFILE_H_ - -#include -//#include - - class IniFile { //all private variables @@ -24,19 +19,29 @@ private: //stores pathname of ini file to read/write CString path; +public: //all keys are of this time - typedef CMapStringToString key; + struct key + { + //list of values in key + CArray values; + //corresponding list of value names + CArray names; + }; + +private: //list of keys in ini CArray keys; //corresponding list of keynames CArray names; - - + //all private functions private: + //returns index of specified value, in the specified key, or -1 if not found + int FindValue(int keynum, CString valuename); //returns index of specified key, or -1 if not found int FindKey(CString keyname); @@ -66,7 +71,7 @@ public: //reads ini file specified using IniFile::SetPath() //returns true if successful, false otherwise - BOOL ReadFile(); + bool ReadFile(); //writes data stored in class to ini file void WriteFile(); @@ -77,37 +82,33 @@ public: //returns number of keys currently in the ini int GetNumKeys(); - //returns a pointer to the key for direct modification - CMapStringToString* GetKeyPointer( CString keyname ); - //returns number of values stored for specified key - int GetNumValues( CString keyname ); + int GetNumValues(CString keyname); //gets value of [keyname] valuename = //overloaded to return CString, int, and double, //returns "", or 0 if key/value not found. Sets error member to show problem - bool GetValue(CString keyname, CString valuename, CString &value_out); - bool GetValueI(CString keyname, CString valuename, int &value_out); - bool GetValueF(CString keyname, CString valuename, float &value_out); - bool GetValueB(CString keyname, CString valuename, bool &value_out); + bool GetValue(CString key, CString valuename, CString& value); + bool GetValueI(CString key, CString valuename, int& value); + bool GetValueF(CString key, CString valuename, float& value); + bool GetValueB(CString key, CString valuename, bool& value); //sets value of [keyname] valuename =. //specify the optional paramter as false (0) if you do not want it to create //the key if it doesn't exist. Returns true if data entered, false otherwise //overloaded to accept CString, int, and double - bool SetValue(CString key, CString valuename, CString value, BOOL create = 1); - bool SetValueI(CString key, CString valuename, int value, BOOL create = 1); - bool SetValueF(CString key, CString valuename, double value, BOOL create = 1); - bool SetValueB(CString key, CString valuename, bool value, BOOL create = 1); + bool SetValue(CString key, CString valuename, CString value, bool create = 1); + bool SetValueI(CString key, CString valuename, int value, bool create = 1); + bool SetValueF(CString key, CString valuename, float value, bool create = 1); + bool SetValueB(CString key, CString valuename, bool value, bool create = 1); //deletes specified value //returns true if value existed and deleted, false otherwise - BOOL DeleteValue(CString keyname, CString valuename); + bool DeleteValue(CString keyname, CString valuename); //deletes specified key and all values contained within //returns true if key existed and deleted, false otherwise - BOOL DeleteKey(CString keyname); + bool DeleteKey(CString keyname); + + key* GetKey(CString keyname); }; - - -#endif diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index 95334b4ef1..46915d08b7 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -13,6 +13,7 @@ #include "InputMapper.h" #include "IniFile.h" #include "GameManager.h" +#include "GameState.h" InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program @@ -20,9 +21,6 @@ InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our p InputMapper::InputMapper() { - m_sCurrentGame = GAMEMAN->GetCurrentGameDef()->m_szName; - - ReadMappingsFromDisk(); } @@ -38,34 +36,33 @@ void InputMapper::ReadMappingsFromDisk() ASSERT( GAMEMAN != NULL ); IniFile ini; - ini.SetPath( m_sCurrentGame + ".ini" ); + ini.SetPath( GAMESTATE->GetCurrentGameDef()->m_szName + CString("Map.ini") ); if( !ini.ReadFile() ) { return; // load nothing //throw RageException( "could not read config file" ); } - CMapStringToString* pKey = ini.GetKeyPointer("Input"); - CString name_string, value_string; + IniFile::key* pKey = ini.GetKey( "Input" ); - if( pKey != NULL ) + if( pKey == NULL ) + return; + for( int i=0; inames.GetSize(); i++ ) { - for( POSITION pos = pKey->GetStartPosition(); pos != NULL; ) + CString name = pKey->names[i]; + CString value = pKey->values[i]; + + GameInput GameI; + GameI.fromString( name ); + + CStringArray sDeviceInputStrings; + split( value, ",", sDeviceInputStrings, false ); + + for( int i=0; iGetNextAssoc( pos, name_string, value_string ); - - GameInput GameI; - GameI.fromString(name_string); - - CStringArray sDeviceInputStrings; - split( value_string, ",", sDeviceInputStrings, false ); - - for( int i=0; iGetCurrentGameDef()->m_szName + CString("Map.ini") ); // ini.ReadFile(); // don't read the file so that we overwrite everything there @@ -235,31 +232,31 @@ DeviceInput InputMapper::MenuToDevice( MenuInput MenuI ) void InputMapper::GameToStyle( GameInput GameI, StyleInput &StyleI ) { - if( GAMEMAN->m_CurStyle == STYLE_NONE ) + if( GAMESTATE->m_CurStyle == STYLE_NONE ) { StyleI.MakeBlank(); return; } - StyleDef* pStyleDef = GAMEMAN->GetCurrentStyleDef(); + StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); StyleI = pStyleDef->GameInputToStyleInput( GameI ); } void InputMapper::GameToMenu( GameInput GameI, MenuInput &MenuI ) { - GameDef* pGameDef = GAMEMAN->GetCurrentGameDef(); + GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); MenuI = pGameDef->GameInputToMenuInput( GameI ); } void InputMapper::StyleToGame( StyleInput StyleI, GameInput &GameI ) { - StyleDef* pStyleDef = GAMEMAN->GetCurrentStyleDef(); + StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); GameI = pStyleDef->StyleInputToGameInput( StyleI ); } void InputMapper::MenuToGame( MenuInput MenuI, GameInput &GameI ) { - GameDef* pGameDef = GAMEMAN->GetCurrentGameDef(); + GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); GameI = pGameDef->MenuInputToGameInput( MenuI ); } diff --git a/stepmania/src/InputMapper.h b/stepmania/src/InputMapper.h index 576bc50dad..321fdad116 100644 --- a/stepmania/src/InputMapper.h +++ b/stepmania/src/InputMapper.h @@ -29,13 +29,6 @@ public: InputMapper(); ~InputMapper(); - void SwitchGame( CString sNewGame ) - { - SaveMappingsToDisk(); - m_sCurrentGame = sNewGame; - ReadMappingsFromDisk(); - }; - void ReadMappingsFromDisk(); void SaveMappingsToDisk(); @@ -63,8 +56,6 @@ public: protected: - CString m_sCurrentGame; - // all the DeviceInputs that map to a GameInput DeviceInput m_GItoDI[MAX_INSTRUMENTS][MAX_INSTRUMENT_BUTTONS][NUM_GAME_TO_DEVICE_SLOTS]; diff --git a/stepmania/src/Judgement.cpp b/stepmania/src/Judgement.cpp index bf1a5f8d68..f9a1346a66 100644 --- a/stepmania/src/Judgement.cpp +++ b/stepmania/src/Judgement.cpp @@ -1,19 +1,20 @@ #include "stdafx.h" /* ----------------------------------------------------------------------------- - File: Judgement.h + Class: Judgement - Desc: A graphic displayed in the Judgement during Dancing. + Desc: See header Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ #include "Judgement.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" -#include "GameManager.h" +#include "PrefsManager.h" +#include "GameState.h" const float JUDGEMENT_DISPLAY_TIME = 0.8f; @@ -24,7 +25,7 @@ Judgement::Judgement() m_sprJudgement.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_JUDGEMENT) ); m_sprJudgement.StopAnimating(); m_sprJudgement.TurnShadowOn(); - this->AddActor( &m_sprJudgement ); + this->AddSubActor( &m_sprJudgement ); } void Judgement::Update( float fDeltaTime ) @@ -59,7 +60,7 @@ void Judgement::SetJudgement( TapNoteScore score ) default: ASSERT( false ); } - if ( GAMEMAN->m_CurGame == GAME_EZ2 ) // Resize Judgement graphics for Ez2. + if ( GAMESTATE->GetCurGame() == GAME_EZ2 ) // Resize Judgement graphics for Ez2. { m_sprJudgement.SetHeight( 22.0f * 2.1f ); m_sprJudgement.SetWidth( 143.0f * 2.1f ); diff --git a/stepmania/src/Judgement.h b/stepmania/src/Judgement.h index 52fe3a73d0..8cb3c2b33d 100644 --- a/stepmania/src/Judgement.h +++ b/stepmania/src/Judgement.h @@ -17,7 +17,7 @@ #include "ActorFrame.h" #include "Song.h" #include "BitmapText.h" -#include "ThemeManager.h" +#include "PrefsManager.h" class Judgement : public ActorFrame diff --git a/stepmania/src/LifeMeter.h b/stepmania/src/LifeMeter.h index 4ef84bb6d1..a154b6ee20 100644 --- a/stepmania/src/LifeMeter.h +++ b/stepmania/src/LifeMeter.h @@ -10,9 +10,11 @@ ----------------------------------------------------------------------------- */ -#include "ActorFrame.h" #include "GameConstantsAndTypes.h" -#include "NoteData.h" +#include "ActorFrame.h" + + +class Song; class LifeMeter : public ActorFrame @@ -21,15 +23,18 @@ public: LifeMeter() { m_fSongBeat = 0; }; virtual ~LifeMeter() {}; - void SetPlayerOptions(const PlayerOptions &po) { m_po = po; } - void SetBeat( float fSongBeat ) { m_fSongBeat = fSongBeat; }; + virtual void Load( PlayerNumber p, const PlayerOptions &po ) { m_PlayerNumber = p; m_po = po; } + virtual void SetBeat( float fSongBeat ) { m_fSongBeat = fSongBeat; }; + virtual void NextSong( Song* pSong ) {}; virtual void ChangeLife( TapNoteScore score ) = 0; virtual bool IsInDanger() = 0; virtual bool IsHot() = 0; - virtual bool HasFailed() = 0; + virtual bool IsFailing() = 0; + virtual bool FailedEarlier() = 0; protected: float m_fSongBeat; + PlayerNumber m_PlayerNumber; PlayerOptions m_po; }; diff --git a/stepmania/src/LifeMeterBar.cpp b/stepmania/src/LifeMeterBar.cpp index 5c167a887b..1b3722835a 100644 --- a/stepmania/src/LifeMeterBar.cpp +++ b/stepmania/src/LifeMeterBar.cpp @@ -11,48 +11,97 @@ */ #include "LifeMeterBar.h" -#include "ThemeManager.h" -#include "GameManager.h" +#include "PrefsManager.h" -const int NUM_SECTIONS = 3; -const float SECTION_WIDTH = 1.0f/NUM_SECTIONS; +const int NUM_LIFE_STREAM_SECTIONS = 3; +const float LIFE_STREAM_SECTION_WIDTH = 1.0f/NUM_LIFE_STREAM_SECTIONS; +const float METER_WIDTH = 258; +const float METER_HEIGHT = 20; -const float DANGER_THRESHOLD = -0.3f; +const float DANGER_THRESHOLD = 0.4f; const float FAIL_THRESHOLD = 0; + + + LifeMeterBar::LifeMeterBar() { m_fLifePercentage = 0.5f; m_fTrailingLifePercentage = 0; m_fLifeVelocity = 0; - m_bHasFailed = false; + m_fHotAlpha = 0; + m_bFailedEarlier = false; + + m_frame; + + m_quadBlackBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); + m_quadBlackBackground.SetZoomX( METER_WIDTH ); + m_quadBlackBackground.SetZoomY( METER_HEIGHT ); + m_frame.AddSubActor( &m_quadBlackBackground ); + + m_sprStreamNormal.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_LIFEMETER_STREAM_NORMAL) ); + m_frame.AddSubActor( &m_sprStreamNormal ); + + m_sprStreamHot.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_LIFEMETER_STREAM_HOT) ); + m_frame.AddSubActor( &m_sprStreamHot ); + + m_sprFrame.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_LIFEMETER_BAR) ); + m_frame.AddSubActor( &m_sprFrame ); + + this->AddSubActor( &m_frame ); ResetBarVelocity(); } +void LifeMeterBar::Load( PlayerNumber p, const PlayerOptions &po ) +{ + LifeMeter::Load( p, po ); + + if( p == PLAYER_2 ) + m_frame.SetZoomX( -1 ); +} + void LifeMeterBar::ChangeLife( TapNoteScore score ) { bool bWasHot = IsHot(); float fDeltaLife; - switch( score ) + switch( m_PlayerOptions.m_DrainType ) { - case TNS_PERFECT: fDeltaLife = +0.008f; break; - case TNS_GREAT: fDeltaLife = +0.004f; break; - case TNS_GOOD: fDeltaLife = +0.000f; break; - case TNS_BOO: fDeltaLife = -0.040f; break; - case TNS_MISS: fDeltaLife = -0.080f; break; + case PlayerOptions::DRAIN_NORMAL: + switch( score ) + { + case TNS_PERFECT: fDeltaLife = +0.008f; break; + case TNS_GREAT: fDeltaLife = +0.004f; break; + case TNS_GOOD: fDeltaLife = +0.000f; break; + case TNS_BOO: fDeltaLife = -0.040f; break; + case TNS_MISS: fDeltaLife = -0.080f; break; + } + if( IsHot() && score < TNS_GOOD ) + fDeltaLife = -0.10f; // make it take a while to get back to "doing great" + break; + case PlayerOptions::DRAIN_NO_RECOVER: + switch( score ) + { + case TNS_PERFECT: fDeltaLife = +0.000f; break; + case TNS_GREAT: fDeltaLife = +0.000f; break; + case TNS_GOOD: fDeltaLife = +0.000f; break; + case TNS_BOO: fDeltaLife = -0.040f; break; + case TNS_MISS: fDeltaLife = -0.080f; break; + } + break; + case PlayerOptions::DRAIN_SUDDEN_DEATH: + fDeltaLife = -1; + break; } - if( IsHot() && score < TNS_GOOD ) - fDeltaLife = -0.10f; // make it take a while to get back to "doing great" m_fLifePercentage += fDeltaLife; - m_fLifePercentage = min( m_fLifePercentage, 1 ); + CLAMP( m_fLifePercentage, 0, 1 ); if( m_fLifePercentage < FAIL_THRESHOLD ) - m_bHasFailed = true; + m_bFailedEarlier = true; ResetBarVelocity(); } @@ -75,13 +124,20 @@ bool LifeMeterBar::IsInDanger() return m_fLifePercentage < DANGER_THRESHOLD; } -bool LifeMeterBar::HasFailed() +bool LifeMeterBar::IsFailing() { - return m_bHasFailed; + return m_fLifePercentage <= 0; +} + +bool LifeMeterBar::FailedEarlier() +{ + return m_bFailedEarlier; } void LifeMeterBar::Update( float fDeltaTime ) { + ActorFrame::Update( fDeltaTime ); + float fDelta = m_fLifePercentage - m_fTrailingLifePercentage; m_fLifeVelocity += fDelta * fDeltaTime; // accelerate m_fLifeVelocity *= 1-fDeltaTime; // dampen @@ -91,9 +147,50 @@ void LifeMeterBar::Update( float fDeltaTime ) if( fDelta * fNewDelta < 0 ) // the deltas have different signs m_fLifeVelocity /= 4; // make some drag - m_fTrailingLifePercentage = clamp( m_fTrailingLifePercentage, 0, 1 ); + CLAMP( m_fTrailingLifePercentage, 0, 1 ); + + + // set custom texture coords + CRect rectSize( + -METER_WIDTH/2, + -METER_HEIGHT/2, + -METER_WIDTH/2 + METER_WIDTH * m_fTrailingLifePercentage, + -METER_HEIGHT/2 + METER_HEIGHT ); + + float fPrecentOffset = TIMER->GetTimeSinceStart(); + fPrecentOffset -= (int)fPrecentOffset; + + FRECT frectCustomTexCoords( + 0 - fPrecentOffset, + 0, + m_fTrailingLifePercentage - fPrecentOffset, + 1 ); + + m_sprStreamNormal.StretchTo( rectSize ); + m_sprStreamNormal.SetCustomTextureRect( frectCustomTexCoords ); + m_sprStreamHot.StretchTo( rectSize ); + m_sprStreamHot.SetCustomTextureRect( frectCustomTexCoords ); + + m_fHotAlpha += IsHot() ? +fDeltaTime*2 : -fDeltaTime*2; + CLAMP( m_fHotAlpha, 0, 1 ); + m_sprStreamHot.SetDiffuseColor( D3DXCOLOR(1,1,1,m_fHotAlpha) ); } +void LifeMeterBar::DrawPrimitives() +{ + float fPercentRed = IsInDanger() ? sinf( TIMER->GetTimeSinceStart()*D3DX_PI*4 )/2+0.5f : 0; + m_quadBlackBackground.SetDiffuseColor( D3DXCOLOR(fPercentRed*0.8f,0,0,1) ); + + ActorFrame::DrawPrimitives(); +} + +/* + + Chris: + I'm making the coloring of the lifemeter a property of the theme. + That's where it belongs anyway... + + const D3DXCOLOR COLOR_EZ2NORMAL_1 = D3DXCOLOR(0.7f,0.4f,0,1); const D3DXCOLOR COLOR_EZ2NORMAL_2 = D3DXCOLOR(0.8f,0.4f,0,1); const D3DXCOLOR COLOR_EZ2NEARFULL_1 = D3DXCOLOR(0.7f,0.6f,0,1); @@ -107,11 +204,11 @@ const D3DXCOLOR COLOR_NORMAL_2 = D3DXCOLOR(0,1,0,1); const D3DXCOLOR COLOR_FULL_1 = D3DXCOLOR(1,0,0,1); const D3DXCOLOR COLOR_FULL_2 = D3DXCOLOR(1,1,0,1); -D3DXCOLOR LifeMeterBar::GetColor( float fPercentIntoSection ) +D3DXCOLOR LifeStream::GetColor( float fPercentIntoSection ) { float fPercentColor1 = fabsf( fPercentIntoSection*2 - 1 ); fPercentColor1 *= fPercentColor1 * fPercentColor1 * fPercentColor1; // make the color bunch around one side - if (GAMEMAN->m_CurGame != GAME_EZ2) + if (GAMESTATE->m_CurGame != GAME_EZ2) { if( m_fLifePercentage == 1 ) return COLOR_FULL_1 * fPercentColor1 + COLOR_FULL_2 * (1-fPercentColor1); @@ -131,9 +228,8 @@ D3DXCOLOR LifeMeterBar::GetColor( float fPercentIntoSection ) } } -void LifeMeterBar::DrawPrimitives() +void LifeStream::DrawPrimitives() { - // make the object in logical units centered at the origin LPDIRECT3DVERTEXBUFFER8 pVB = DISPLAY->GetVertexBuffer(); RAGEVERTEX* v; @@ -141,7 +237,7 @@ void LifeMeterBar::DrawPrimitives() int iNumV = 0; - float fPercentIntoSection = (TIMER->GetTimeSinceStart()/0.3f* (IsHot() ? 2 : 1) )*SECTION_WIDTH; + float fPercentIntoSection = (TIMER->GetTimeSinceStart()/0.3f* (m_bIsHot ? 2 : 1) )*LIFE_STREAM_SECTION_WIDTH; fPercentIntoSection -= (int)fPercentIntoSection; fPercentIntoSection = 1-fPercentIntoSection; fPercentIntoSection -= (int)fPercentIntoSection; @@ -167,13 +263,13 @@ void LifeMeterBar::DrawPrimitives() { const float fPercentToAdd = 0.5f-fPercentIntoSection; fPercentIntoSection += fPercentToAdd; - fX += fPercentToAdd*SECTION_WIDTH; + fX += fPercentToAdd*LIFE_STREAM_SECTION_WIDTH; } else if( fPercentIntoSection < 1.0f ) { const float fPercentToAdd = 1.0f-fPercentIntoSection; fPercentIntoSection = 0; - fX += fPercentToAdd*SECTION_WIDTH; + fX += fPercentToAdd*LIFE_STREAM_SECTION_WIDTH; } else ASSERT( false ); @@ -181,7 +277,7 @@ void LifeMeterBar::DrawPrimitives() const float fXToSubtract = fX - (m_fTrailingLifePercentage-0.5f); fX -= fXToSubtract; - fPercentIntoSection -= fXToSubtract/SECTION_WIDTH; + fPercentIntoSection -= fXToSubtract/LIFE_STREAM_SECTION_WIDTH; if( fPercentIntoSection < 0 ) fPercentIntoSection += 1; @@ -196,20 +292,6 @@ void LifeMeterBar::DrawPrimitives() v[iNumV++].color = color; v[iNumV++].color = color; - // - // draw black filler - // - v[iNumV++].p = D3DXVECTOR3( fX, -0.5f, 0 ); - v[iNumV++].p = D3DXVECTOR3( fX, 0.5f, 0 ); - v[iNumV++].p = D3DXVECTOR3( 0.5f, -0.5f, 0 ); - v[iNumV++].p = D3DXVECTOR3( 0.5f, 0.5f, 0 ); - - iNumV -= 4; - const D3DXCOLOR colorBlack = D3DXCOLOR(0,0,0,1); - v[iNumV++].color = colorBlack; - v[iNumV++].color = colorBlack; - v[iNumV++].color = colorBlack; - v[iNumV++].color = colorBlack; pVB->Unlock(); @@ -235,4 +317,5 @@ void LifeMeterBar::DrawPrimitives() pd3dDevice->SetStreamSource( 0, pVB, sizeof(RAGEVERTEX) ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, iNumV-2 ); -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/stepmania/src/LifeMeterBar.h b/stepmania/src/LifeMeterBar.h index 87b9f051d4..6bc1958dbf 100644 --- a/stepmania/src/LifeMeterBar.h +++ b/stepmania/src/LifeMeterBar.h @@ -20,20 +20,32 @@ class LifeMeterBar : public LifeMeter public: LifeMeterBar(); + virtual void Load( PlayerNumber p, const PlayerOptions &po ); + virtual void Update( float fDeltaTime ); virtual void DrawPrimitives(); virtual void ChangeLife( TapNoteScore score ); virtual bool IsInDanger(); virtual bool IsHot(); - virtual bool HasFailed(); + virtual bool IsFailing(); + virtual bool FailedEarlier(); private: - D3DXCOLOR GetColor( float fPercentIntoSection ); void ResetBarVelocity(); + ActorFrame m_frame; // hold everything and mirror this for PLAYER_2 instead of mirroring all the individual Actors + + Quad m_quadBlackBackground; + Sprite m_sprStreamNormal; + Sprite m_sprStreamHot; + Sprite m_sprFrame; + + PlayerOptions m_PlayerOptions; + float m_fLifePercentage; float m_fTrailingLifePercentage; // this approaches m_fLifePercentage float m_fLifeVelocity; // how m_fTrailingLifePercentage approaches m_fLifePercentage - bool m_bHasFailed; // set this to true when life dips below 0 + float m_fHotAlpha; + bool m_bFailedEarlier; // set this to true when life dips below 0 }; diff --git a/stepmania/src/LifeMeterBattery.cpp b/stepmania/src/LifeMeterBattery.cpp new file mode 100644 index 0000000000..26d9a60e9e --- /dev/null +++ b/stepmania/src/LifeMeterBattery.cpp @@ -0,0 +1,176 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: LifeMeterBattery + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "LifeMeterBattery.h" +#include "PrefsManager.h" +#include "GameState.h" + + +const float BATTERY_X[NUM_PLAYERS] = { -92, +92 }; + +const float NUM_X[NUM_PLAYERS] = { BATTERY_X[0], BATTERY_X[1] }; +const float NUM_Y = +2; + +const float PERCENT_X[NUM_PLAYERS] = { +28, -28 }; +const float PERCENT_Y = 0; + +const float BATTERY_BLINK_TIME = 1.2f; + + +LifeMeterBattery::LifeMeterBattery() +{ + m_iMaxLives = 3; + m_iLivesLeft = m_iMaxLives; + m_bFailedEarlier = false; + + m_fBatteryBlinkTime = 0; + + m_sprFrame.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_LIFEMETER_ONI) ); + this->AddSubActor( &m_sprFrame ); + + m_sprBattery.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_LIFEMETER_BATTERY) ); + m_sprBattery.StopAnimating(); + this->AddSubActor( &m_sprBattery ); + + m_textNumLives.Load( THEME->GetPathTo(FONT_HEADER1) ); + m_textNumLives.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // pink + m_textNumLives.SetZoom( 1.1f ); + m_textNumLives.TurnShadowOff(); + this->AddSubActor( &m_textNumLives ); + + m_textPercent.Load( THEME->GetPathTo(FONT_SCORE_NUMBERS) ); + m_textPercent.TurnShadowOff(); + m_textPercent.SetZoom( 0.7f ); + m_textPercent.SetText( "0.00" ); + this->AddSubActor( &m_textPercent ); + + m_soundGainLife.Load( THEME->GetPathTo(SOUND_GAMEPLAY_ONI_GAIN_LIFE) ); + m_soundLoseLife.Load( THEME->GetPathTo(SOUND_GAMEPLAY_ONI_LOSE_LIFE) ); + + Refresh(); +} + +void LifeMeterBattery::Load( PlayerNumber p, const PlayerOptions &po ) +{ + LifeMeter::Load( p, po ); + + m_sprFrame.SetZoomX( p==PLAYER_1 ? 1.0f : -1.0f ); + m_sprBattery.SetZoomX( p==PLAYER_1 ? 1.0f : -1.0f ); + m_sprBattery.SetX( BATTERY_X[p] ); + m_textNumLives.SetX( NUM_X[p] ); + m_textNumLives.SetY( NUM_Y ); + m_textPercent.SetX( PERCENT_X[p] ); + m_textPercent.SetY( PERCENT_Y ); + + m_textPercent.SetDiffuseColor( PlayerToColor(p) ); // light blue + +} + +void LifeMeterBattery::NextSong( Song* pSong ) +{ + if( m_bFailedEarlier ) + return; + + m_iLivesLeft++; + m_soundGainLife.Play(); + + Refresh(); +} + +void LifeMeterBattery::ChangeLife( TapNoteScore score ) +{ + if( m_bFailedEarlier ) + return; + + if( GAMESTATE->m_aGameplayStatistics.GetSize() > 0 ) + { + int iActualDancePoints = 0; + for( int i=0; im_aGameplayStatistics.GetSize(); i++ ) + iActualDancePoints += GAMESTATE->m_aGameplayStatistics[i].iActualDancePoints[m_PlayerNumber]; + int iPossibleDancePoints = GAMESTATE->m_iCoursePossibleDancePoints; + float fPercentDancePoints = iActualDancePoints / (float)iPossibleDancePoints + 0.0001f; // correct for rounding errors + m_textPercent.SetText( ssprintf("%1.2f", fPercentDancePoints) ); + } + + switch( score ) + { + case TNS_PERFECT: + case TNS_GREAT: + break; + case TNS_GOOD: + case TNS_BOO: + case TNS_MISS: + m_iLivesLeft--; + m_soundLoseLife.Play(); + Refresh(); + m_fBatteryBlinkTime = BATTERY_BLINK_TIME; + break; + } + if( m_iLivesLeft == -1 ) + m_bFailedEarlier = true; +} + +bool LifeMeterBattery::IsInDanger() +{ + return false; +} + +bool LifeMeterBattery::IsHot() +{ + return false; +} + +bool LifeMeterBattery::IsFailing() +{ + return m_bFailedEarlier; +} + +bool LifeMeterBattery::FailedEarlier() +{ + return m_bFailedEarlier; +} + +void LifeMeterBattery::Refresh() +{ + if( m_iLivesLeft <= 3 ) + { + m_textNumLives.SetText( "" ); + m_sprBattery.SetState( max(m_iLivesLeft,0) ); + } + else + { + m_textNumLives.SetText( ssprintf("x%d", m_iLivesLeft) ); + m_sprBattery.SetState( 3 ); + } +} + +void LifeMeterBattery::Update( float fDeltaTime ) +{ + if( m_iLivesLeft == -1 ) + { + m_sprBattery.SetState( 0 ); + } + else if( m_fBatteryBlinkTime > 0 ) + { + m_fBatteryBlinkTime -= fDeltaTime; + int iFrameNo = m_iLivesLeft + int(m_fBatteryBlinkTime*15)%2; + CLAMP( iFrameNo, 0, 3 ); + m_sprBattery.SetState( iFrameNo ); + + + if( m_fBatteryBlinkTime < 0 ) + { + m_fBatteryBlinkTime = 0; + m_sprBattery.SetState( max(m_iLivesLeft,0) ); + } + } +} \ No newline at end of file diff --git a/stepmania/src/LifeMeterBattery.h b/stepmania/src/LifeMeterBattery.h new file mode 100644 index 0000000000..86c3d8c75a --- /dev/null +++ b/stepmania/src/LifeMeterBattery.h @@ -0,0 +1,53 @@ +#pragma once +/* +----------------------------------------------------------------------------- + Class: LifeMeterBattery + + Desc: The battery life meter used in Oni. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + + +#include "LifeMeter.h" +#include "Sprite.h" +#include "BitmapText.h" +#include "RageSoundSample.h" + + +class LifeMeterBattery : public LifeMeter +{ +public: + LifeMeterBattery(); + + virtual void Load( PlayerNumber p, const PlayerOptions &po ); + + virtual void Update( float fDeltaTime ); + + virtual void NextSong( Song* pSong ); + virtual void ChangeLife( TapNoteScore score ); + virtual bool IsInDanger(); + virtual bool IsHot(); + virtual bool IsFailing(); + virtual bool FailedEarlier(); + + void Refresh(); + +private: + int m_iLivesLeft; + int m_iMaxLives; + bool m_bFailedEarlier; + + float m_fBatteryBlinkTime; // if > 0 battery is blinking + + Sprite m_sprFrame; + Sprite m_sprBattery; + BitmapText m_textNumLives; + BitmapText m_textPercent; + + RageSoundSample m_soundLoseLife; + RageSoundSample m_soundGainLife; +}; + diff --git a/stepmania/src/MenuElements.cpp b/stepmania/src/MenuElements.cpp index 335769e752..0b25812e3a 100644 --- a/stepmania/src/MenuElements.cpp +++ b/stepmania/src/MenuElements.cpp @@ -17,10 +17,11 @@ #include "ScreenManager.h" #include "ScreenGameplay.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" #include "RageLog.h" #include "GameManager.h" +#include "GameState.h" const float HELP_X = CENTER_X; @@ -38,28 +39,28 @@ const float CREDIT_Y[NUM_PLAYERS] = {SCREEN_BOTTOM-8, SCREEN_BOTTOM-8}; MenuElements::MenuElements() { - m_frameTopBar.AddActor( &m_sprTopEdge ); - m_frameTopBar.AddActor( &m_sprStyleIcon ); - m_frameTopBar.AddActor( &m_MenuTimer ); + m_frameTopBar.AddSubActor( &m_sprTopEdge ); + m_frameTopBar.AddSubActor( &m_sprStyleIcon ); + m_frameTopBar.AddSubActor( &m_MenuTimer ); - m_frameBottomBar.AddActor( &m_sprBottomEdge ); + m_frameBottomBar.AddSubActor( &m_sprBottomEdge ); - this->AddActor( &m_sprBG ); - this->AddActor( &m_frameTopBar ); - this->AddActor( &m_frameBottomBar ); - this->AddActor( &m_textHelp ); + this->AddSubActor( &m_sprBG ); + this->AddSubActor( &m_frameTopBar ); + this->AddSubActor( &m_frameBottomBar ); + this->AddSubActor( &m_textHelp ); for( int p=0; pAddActor( &m_textCreditInfo[p] ); + this->AddSubActor( &m_textCreditInfo[p] ); m_KeepAlive.SetZ( -2 ); m_KeepAlive.SetOpened(); - this->AddActor( &m_KeepAlive ); + this->AddSubActor( &m_KeepAlive ); m_Wipe.SetZ( -2 ); m_Wipe.SetOpened(); - this->AddActor( &m_Wipe ); + this->AddSubActor( &m_Wipe ); - this->AddActor( &m_Invisible ); + this->AddSubActor( &m_Invisible ); } void MenuElements::Load( CString sBackgroundPath, CString sTopEdgePath, CString sHelpText, bool bShowStyleIcon, bool bTimerEnabled, int iTimerSeconds ) @@ -80,10 +81,10 @@ void MenuElements::Load( CString sBackgroundPath, CString sTopEdgePath, CString m_sprStyleIcon.StopAnimating(); m_sprStyleIcon.SetXY( STYLE_ICON_LOCAL_X, STYLE_ICON_LOCAL_Y ); m_sprStyleIcon.SetZ( -1 ); - if( GAMEMAN->m_CurStyle == STYLE_NONE || !bShowStyleIcon ) + if( GAMESTATE->m_CurStyle == STYLE_NONE || !bShowStyleIcon ) m_sprStyleIcon.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); else - m_sprStyleIcon.SetState( GAMEMAN->m_CurStyle ); + m_sprStyleIcon.SetState( GAMESTATE->m_CurStyle ); m_MenuTimer.SetXY( TIMER_LOCAL_X, TIMER_LOCAL_Y ); m_MenuTimer.SetZ( -1 ); @@ -100,13 +101,13 @@ void MenuElements::Load( CString sBackgroundPath, CString sTopEdgePath, CString m_sprBottomEdge.Load( THEME->GetPathTo(GRAPHIC_MENU_BOTTOM_EDGE) ); m_sprBottomEdge.TurnShadowOff(); - m_textHelp.Load( THEME->GetPathTo(FONT_NORMAL) ); m_textHelp.SetXY( HELP_X, HELP_Y ); - m_textHelp.SetZ( -1 ); - m_textHelp.SetText( sHelpText ); +// m_textHelp.SetZ( -1 ); + CStringArray asHelpTips; + split( sHelpText, "\n", asHelpTips ); + m_textHelp.SetTips( asHelpTips ); + //m_textHelp.SetText( sHelpText ); m_textHelp.SetZoom( 0.5f ); - m_textHelp.SetEffectBlinking(); - m_textHelp.TurnShadowOff(); for( int p=0; pm_CurStyle == STYLE_NONE ) + if( GAMESTATE->m_CurStyle == STYLE_NONE ) m_textCreditInfo[p].SetText( "PRESS START" ); - else if( GAMEMAN->IsPlayerEnabled( (PlayerNumber)p ) ) + else if( GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) m_textCreditInfo[p].SetText( "" ); else // not enabled m_textCreditInfo[p].SetText( "NOT PRESENT" ); diff --git a/stepmania/src/MenuElements.h b/stepmania/src/MenuElements.h index a6a2dc2207..be2e3cf32f 100644 --- a/stepmania/src/MenuElements.h +++ b/stepmania/src/MenuElements.h @@ -21,6 +21,7 @@ #include "TransitionFadeWipe.h" #include "TransitionKeepAlive.h" #include "TransitionInvisible.h" +#include "TipDisplay.h" const float MENU_ELEMENTS_TWEEN_TIME = 0.30f; @@ -69,7 +70,7 @@ protected: // stuff in the main frame Sprite m_sprBG; - BitmapText m_textHelp; + TipDisplay m_textHelp; BitmapText m_textCreditInfo[NUM_PLAYERS]; TransitionFadeWipe m_Wipe; diff --git a/stepmania/src/MenuTimer.cpp b/stepmania/src/MenuTimer.cpp index 61acb6aa14..2df0592c8e 100644 --- a/stepmania/src/MenuTimer.cpp +++ b/stepmania/src/MenuTimer.cpp @@ -13,7 +13,7 @@ #include "MenuTimer.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenManager.h" #include "AnnouncerManager.h" @@ -28,12 +28,12 @@ MenuTimer::MenuTimer() m_textDigit1.Load( THEME->GetPathTo(FONT_TIMER_NUMBERS) ); m_textDigit1.TurnShadowOff(); m_textDigit1.SetXY( -18, 0 ); - this->AddActor( &m_textDigit1 ); + this->AddSubActor( &m_textDigit1 ); m_textDigit2.Load( THEME->GetPathTo(FONT_TIMER_NUMBERS) ); m_textDigit2.TurnShadowOff(); m_textDigit2.SetXY( +18, 0 ); - this->AddActor( &m_textDigit2 ); + this->AddSubActor( &m_textDigit2 ); m_soundBeep.Load( THEME->GetPathTo(SOUND_MENU_TIMER) ); } diff --git a/stepmania/src/MsdFile.cpp b/stepmania/src/MsdFile.cpp new file mode 100644 index 0000000000..cc3a6f82da --- /dev/null +++ b/stepmania/src/MsdFile.cpp @@ -0,0 +1,125 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: MsdFile + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "MsdFile.h" + + +MsdFile::MsdFile() +{ + m_szFileString = NULL; + int m_iNumValues = 0; +} + +MsdFile::~MsdFile() +{ + if( m_szFileString ) + delete m_szFileString; +} + +//returns true if successful, false otherwise +bool MsdFile::ReadFile( CString sNewPath ) +{ + if( m_szFileString ) + delete m_szFileString; + + // Get file size in bytes + HANDLE hFile = CreateFile( + sNewPath, // pointer to name of the file + GENERIC_READ, // access (read-write) mode + FILE_SHARE_READ|FILE_SHARE_WRITE, // share mode + NULL, // pointer to security attributes + OPEN_EXISTING, // how to create + FILE_ATTRIBUTE_NORMAL, // file attributes + NULL // handle to file with attributes to + ); + + int iBufferSize = GetFileSize( hFile, NULL ) + 1; + CloseHandle( hFile ); + + // allocate a string to hold the file + m_szFileString = new char[iBufferSize]; + + FILE* fp = fopen(sNewPath, "r"); + if( fp == NULL ) + return false; + + int iBytesRead = fread( m_szFileString, 1, iBufferSize, fp ); + + ASSERT( iBufferSize > iBytesRead ); + + m_iNumValues = 0; + + for( int i=0; iIsPlayerEnabled( (PlayerNumber)p ) ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) { m_GradeDisplay[p].SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); continue; @@ -208,8 +209,8 @@ void WheelItemDisplay::RefreshGrades() if( m_pSong ) // this is a song display { - const DifficultyClass dc = PREFSMAN->m_PreferredDifficultyClass[p]; - const Grade grade = m_pSong->GetGradeForDifficultyClass( GAMEMAN->GetCurrentStyleDef()->m_NotesType, dc ); + const DifficultyClass dc = GAMESTATE->m_PreferredDifficultyClass[p]; + const Grade grade = m_pSong->GetGradeForDifficultyClass( GAMESTATE->GetCurrentStyleDef()->m_NotesType, dc ); m_GradeDisplay[p].SetGrade( grade ); m_GradeDisplay[p].SetDiffuseColor( PlayerToColor((PlayerNumber)p) ); } @@ -301,25 +302,25 @@ MusicWheel::MusicWheel() // for debugging - if( GAMEMAN->m_CurStyle == STYLE_NONE ) - GAMEMAN->m_CurStyle = STYLE_DANCE_SINGLE; + if( GAMESTATE->m_CurStyle == STYLE_NONE ) + GAMESTATE->m_CurStyle = STYLE_DANCE_SINGLE; m_frameOverlay.SetXY( 0, 0 ); for( int p=0; pIsPlayerEnabled((PlayerNumber)p) ) + if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) ) continue; // skip m_sprHighScoreFrame[p].Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_SCORE_FRAME) ); m_sprHighScoreFrame[p].SetXY( SCORE_X, SCORE_Y[p] ); - m_frameOverlay.AddActor( &m_sprHighScoreFrame[p] ); + m_frameOverlay.AddSubActor( &m_sprHighScoreFrame[p] ); m_HighScore[p].SetXY( SCORE_X, SCORE_Y[p]*0.97f ); m_HighScore[p].SetZoom( 0.6f ); m_HighScore[p].SetDiffuseColor( PlayerToColor(p) ); - m_frameOverlay.AddActor( &m_HighScore[p] ); + m_frameOverlay.AddSubActor( &m_HighScore[p] ); } m_sprHighScoreFrame[1].SetZoomY( -1 ); // flip vertically @@ -329,17 +330,17 @@ MusicWheel::MusicWheel() m_sprSelectionOverlay.SetXY( 0, 0 ); m_sprSelectionOverlay.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); m_sprSelectionOverlay.SetEffectGlowing( 1.0f, D3DXCOLOR(1,1,1,0.4f), D3DXCOLOR(1,1,1,1) ); - m_frameOverlay.AddActor( &m_sprSelectionOverlay ); + m_frameOverlay.AddSubActor( &m_sprSelectionOverlay ); m_MusicSortDisplay.SetXY( SORT_ICON_ON_SCREEN_X, SORT_ICON_ON_SCREEN_Y ); m_MusicSortDisplay.SetEffectGlowing( 1.0f ); - m_frameOverlay.AddActor( &m_MusicSortDisplay ); + m_frameOverlay.AddSubActor( &m_MusicSortDisplay ); - this->AddActor( &m_frameOverlay ); + this->AddSubActor( &m_frameOverlay ); m_ScrollBar.SetX( SCROLLBAR_X ); - this->AddActor( &m_ScrollBar ); + this->AddSubActor( &m_ScrollBar ); m_soundChangeMusic.Load( THEME->GetPathTo(SOUND_SELECT_MUSIC_CHANGE_MUSIC), 16 ); @@ -359,7 +360,7 @@ MusicWheel::MusicWheel() - m_SortOrder = PREFSMAN->m_SongSortOrder; + m_SortOrder = GAMESTATE->m_SongSortOrder; m_MusicSortDisplay.Set( m_SortOrder ); m_MusicSortDisplay.SetXY( SORT_ICON_ON_SCREEN_X, SORT_ICON_ON_SCREEN_Y ); @@ -380,23 +381,23 @@ MusicWheel::MusicWheel() BuildWheelItemDatas( m_WheelItemDatas[so], SongSortOrder(so) ); // select a song if none are selected - if( SONGMAN->m_pCurSong == NULL && // if there is no currently selected song + if( GAMESTATE->m_pCurSong == NULL && // if there is no currently selected song SONGMAN->m_pSongs.GetSize() > 0 ) // and there is at least one song { CArray arraySongs; - SONGMAN->GetSongsInGroup( SONGMAN->m_sPreferredGroup, arraySongs ); + SONGMAN->GetSongsInGroup( GAMESTATE->m_sPreferredGroup, arraySongs ); if( arraySongs.GetSize() > 0 ) - SONGMAN->SetCurrentSong( arraySongs[0] ); // select the first song + GAMESTATE->m_pCurSong = arraySongs[0]; // select the first song } - if( SONGMAN->m_pCurSong != NULL ) + if( GAMESTATE->m_pCurSong != NULL ) { // find the previously selected song (if any) for( int i=0; iGetCurrentSong() ) + if( GetCurWheelItemDatas()[i].m_pSong == GAMESTATE->m_pCurSong ) { m_iSelection = i; // select it m_sExpandedSectionName = GetCurWheelItemDatas()[m_iSelection].m_sSectionName; // make its group the currently expanded group @@ -412,14 +413,14 @@ MusicWheel::MusicWheel() MusicWheel::~MusicWheel() { - PREFSMAN->m_SongSortOrder = m_SortOrder; + GAMESTATE->m_SongSortOrder = m_SortOrder; } void MusicWheel::BuildWheelItemDatas( CArray &arrayWheelItemDatas, SongSortOrder so, bool bRoulette ) { int i; - switch( PREFSMAN->m_PlayMode ) + switch( GAMESTATE->m_PlayMode ) { case PLAY_MODE_ARCADE: { @@ -434,7 +435,7 @@ void MusicWheel::BuildWheelItemDatas( CArray &arr Song* pSong = SONGMAN->m_pSongs[i]; CArray arraySteps; - pSong->GetNotesThatMatch( GAMEMAN->GetCurrentStyleDef()->m_NotesType, arraySteps ); + pSong->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef()->m_NotesType, arraySteps ); if( arraySteps.GetSize() > 0 ) arraySongs.Add( pSong ); @@ -477,7 +478,7 @@ void MusicWheel::BuildWheelItemDatas( CArray &arr { case SORT_MOST_PLAYED: bUseSections = false; break; case SORT_BPM: bUseSections = false; break; - case SORT_GROUP: bUseSections = SONGMAN->m_sPreferredGroup != "ALL MUSIC"; break; + case SORT_GROUP: bUseSections = GAMESTATE->m_sPreferredGroup != "ALL MUSIC"; break; case SORT_TITLE: bUseSections = true; break; default: ASSERT( false ); } @@ -568,7 +569,7 @@ void MusicWheel::BuildWheelItemDatas( CArray &arr arrayWheelItemDatas.SetSize( 1 ); arrayWheelItemDatas[0].Load( TYPE_SECTION, NULL, "NO SONGS", NULL, D3DXCOLOR(1,0,0,1) ); } - else if( PREFSMAN->m_PlayMode == PLAY_MODE_ARCADE && !bRoulette ) + else if( GAMESTATE->m_PlayMode == PLAY_MODE_ARCADE && !bRoulette ) { arrayWheelItemDatas.SetSize( arrayWheelItemDatas.GetSize()+1 ); arrayWheelItemDatas[arrayWheelItemDatas.GetSize()-1].Load( TYPE_ROULETTE, NULL, "", NULL, D3DXCOLOR(1,0,0,1) ); @@ -667,9 +668,9 @@ void MusicWheel::RebuildWheelItemDisplays() void MusicWheel::NotesChanged( PlayerNumber pn ) // update grade graphics and top score { - DifficultyClass dc = PREFSMAN->m_PreferredDifficultyClass[pn]; - Song* pSong = SONGMAN->GetCurrentSong(); - Notes* m_pNotes = SONGMAN->GetCurrentNotes( pn ); + DifficultyClass dc = GAMESTATE->m_PreferredDifficultyClass[pn]; + Song* pSong = GAMESTATE->m_pCurSong; + Notes* m_pNotes = GAMESTATE->m_pCurNotes[ pn ]; if( m_pNotes ) m_HighScore[pn].SetScore( (float)m_pNotes->m_iTopScore ); diff --git a/stepmania/src/MusicWheel.h b/stepmania/src/MusicWheel.h index 9e526bcb2c..d0c73a2b69 100644 --- a/stepmania/src/MusicWheel.h +++ b/stepmania/src/MusicWheel.h @@ -23,7 +23,7 @@ #include "MusicSortDisplay.h" #include "MusicStatusDisplay.h" #include "Screen.h" // for ScreenMessage -#include "ScoreDisplayRolling.h" +#include "ScoreDisplayNormal.h" #include "ScrollBar.h" #include "Course.h" @@ -137,7 +137,7 @@ protected: // Actors inside of m_frameOverlay Sprite m_sprSelectionOverlay; Sprite m_sprHighScoreFrame[NUM_PLAYERS]; - ScoreDisplayRolling m_HighScore[NUM_PLAYERS]; + ScoreDisplayNormal m_HighScore[NUM_PLAYERS]; CArray m_WheelItemDatas[NUM_SORT_ORDERS]; diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 05a08d54f3..0f842c3c16 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -13,7 +13,7 @@ #include "NoteData.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ArrowEffects.h" #include "PrefsManager.h" #include "GameConstantsAndTypes.h" diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index 54cc3e218e..0dc9006981 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -13,11 +13,11 @@ #include "NoteField.h" #include "RageUtil.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ArrowEffects.h" #include "PrefsManager.h" #include "GameManager.h" -#include "SongManager.h" +#include "GameState.h" const float HOLD_NOTE_BITS_PER_BEAT = 6; const float HOLD_NOTE_BITS_PER_ROW = HOLD_NOTE_BITS_PER_BEAT / ELEMENTS_PER_BEAT; @@ -54,10 +54,10 @@ void NoteField::Load( NoteData* pNoteData, PlayerNumber p, StyleDef* pStyleDef, for( int c=0; c arrayTweenColors; - GAMEMAN->GetTweenColors( p, c, arrayTweenColors ); + GAMEMAN->GetTweenColors( c, arrayTweenColors ); - m_ColorNote[c].m_sprColorPart.Load( GAMEMAN->GetPathToGraphic( p, c, GRAPHIC_NOTE_COLOR_PART) ); - m_ColorNote[c].m_sprGrayPart.Load( GAMEMAN->GetPathToGraphic( p, c, GRAPHIC_NOTE_GRAY_PART) ); + m_ColorNote[c].m_sprColorPart.Load( GAMEMAN->GetPathTo(c, GRAPHIC_NOTE_COLOR_PART) ); + m_ColorNote[c].m_sprGrayPart.Load( GAMEMAN->GetPathTo(c, GRAPHIC_NOTE_GRAY_PART) ); } @@ -65,7 +65,7 @@ void NoteField::Load( NoteData* pNoteData, PlayerNumber p, StyleDef* pStyleDef, m_HoldNoteLife[i] = 1; // start with full life - ASSERT( m_iNumTracks == GAMEMAN->GetCurrentStyleDef()->m_iColsPerPlayer ); + ASSERT( m_iNumTracks == GAMESTATE->GetCurrentStyleDef()->m_iColsPerPlayer ); } void NoteField::Update( float fDeltaTime, float fSongBeat ) @@ -214,7 +214,7 @@ void NoteField::DrawPrimitives() // // BPM text // - CArray &aBPMSegments = SONGMAN->GetCurrentSong()->m_BPMSegments; + CArray &aBPMSegments = GAMESTATE->m_pCurSong->m_BPMSegments; for( i=0; i &aStopSegments = SONGMAN->GetCurrentSong()->m_StopSegments; + CArray &aStopSegments = GAMESTATE->m_pCurSong->m_StopSegments; for( i=0; im_iNumTracks = mapDanceNoteToNoteDataColumn.GetCount(); for( int pad=0; pad<2; pad++ ) // foreach pad @@ -528,15 +527,23 @@ bool Notes::LoadFromDWITokens( } void Notes::LoadFromSMTokens( - const CString &sNotesType, - const CString &sDescription, - const CString &sDifficultyClass, - const CString &sMeter, - const CString &sRadarValues, - const CString &sNoteData + CString sNotesType, + CString sDescription, + CString sDifficultyClass, + CString sMeter, + CString sRadarValues, + CString sNoteData ) { - LOG->WriteLine( "Notes::LoadFromSMTokens()" ); + sNotesType.TrimLeft(); + sNotesType.TrimRight(); + sDescription.TrimLeft(); + sDescription.TrimRight(); + sDifficultyClass.TrimLeft(); + sDifficultyClass.TrimRight(); + + +// LOG->WriteLine( "Notes::LoadFromSMTokens()" ); m_NotesType = StringToNotesType(sNotesType); m_sDescription = sDescription; @@ -603,18 +610,21 @@ DifficultyClass Notes::DifficultyClassFromDescriptionAndMeter( CString sDescript { sDescription.MakeLower(); - const CString sDescriptionParts[NUM_DIFFICULTY_CLASSES][3] = { + const CString sDescriptionParts[NUM_DIFFICULTY_CLASSES][4] = { { + "easy", "basic", "light", "SDFKSJDKFJS", }, { + "medium", "another", "trick", "standard", }, { + "hard", "ssr", "maniac", "heavy", diff --git a/stepmania/src/Notes.h b/stepmania/src/Notes.h index 8ee8b2c9b2..bece587b74 100644 --- a/stepmania/src/Notes.h +++ b/stepmania/src/Notes.h @@ -33,12 +33,12 @@ public: CString sStepData1, const CString sStepData2 ); void LoadFromSMTokens( - const CString &sNotesType, - const CString &sDescription, - const CString &sDifficultyClass, - const CString &sMeter, - const CString &sRadarValues, - const CString &sNoteDataOut + CString sNotesType, + CString sDescription, + CString sDifficultyClass, + CString sMeter, + CString sRadarValues, + CString sNoteDataOut ); void WriteSMNotesTag( FILE* fp ); diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 4007b1d68c..f4e2ce397b 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -14,12 +14,13 @@ #include "Math.h" // for fabs() #include "Player.h" #include "RageUtil.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "GameConstantsAndTypes.h" #include "ArrowEffects.h" #include "GameManager.h" #include "InputMapper.h" #include "SongManager.h" +#include "GameState.h" // these two items are in the @@ -42,20 +43,22 @@ Player::Player() m_pLifeMeter = NULL; m_pScore = NULL; - this->AddActor( &m_GrayArrowRow ); - this->AddActor( &m_NoteField ); - this->AddActor( &m_GhostArrowRow ); + this->AddSubActor( &m_GrayArrowRow ); + this->AddSubActor( &m_NoteField ); + this->AddSubActor( &m_GhostArrowRow ); - m_frameJudgeAndCombo.AddActor( &m_Judgement ); - m_frameJudgeAndCombo.AddActor( &m_Combo ); - this->AddActor( &m_frameJudgeAndCombo ); + m_frameJudgement.AddSubActor( &m_Judgement ); + this->AddSubActor( &m_frameJudgement ); + + m_frameCombo.AddSubActor( &m_Combo ); + this->AddSubActor( &m_frameCombo ); for( int c=0; cAddActor( &m_HoldJudgement[c] ); + this->AddSubActor( &m_HoldJudgement[c] ); } -void Player::Load( PlayerNumber player_no, StyleDef* pStyleDef, NoteData* pNoteData, const PlayerOptions& po, LifeMeterBar* pLM, ScoreDisplayRolling* pScore, int iOriginalNumNotes, int iNotesMeter ) +void Player::Load( PlayerNumber player_no, StyleDef* pStyleDef, NoteData* pNoteData, const PlayerOptions& po, LifeMeter* pLM, ScoreDisplay* pScore, int iOriginalNumNotes, int iNotesMeter ) { //LOG->WriteLine( "Player::Load()", ); this->CopyAll( pNoteData ); @@ -84,7 +87,8 @@ void Player::Load( PlayerNumber player_no, StyleDef* pStyleDef, NoteData* pNoteD m_GrayArrowRow.Load( player_no, pStyleDef, po ); m_GhostArrowRow.Load( player_no, pStyleDef, po ); - m_frameJudgeAndCombo.SetY( FRAME_JUDGE_AND_COMBO_Y ); + m_frameJudgement.SetY( FRAME_JUDGE_AND_COMBO_Y ); + m_frameCombo.SetY( FRAME_JUDGE_AND_COMBO_Y ); m_Combo.SetY( po.m_bReverseScroll ? -COMBO_Y_OFFSET : COMBO_Y_OFFSET ); m_Judgement.SetY( po.m_bReverseScroll ? -JUDGEMENT_Y_OFFSET : JUDGEMENT_Y_OFFSET ); @@ -102,6 +106,7 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference { //LOG->WriteLine( "Player::Update(%f, %f, %f)", fDeltaTime, fSongBeat, fMaxBeatDifference ); + m_fSongBeat = fSongBeat; // save song beat // // Check for TapNote misses @@ -125,7 +130,7 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference float fEndBeat = NoteRowToBeat( (float)hn.m_iEndIndex ); const StyleInput StyleI( m_PlayerNumber, hn.m_iTrack ); - const GameInput GameI = GAMEMAN->GetCurrentStyleDef()->StyleInputToGameInput( StyleI ); + const GameInput GameI = GAMESTATE->GetCurrentStyleDef()->StyleInputToGameInput( StyleI ); // update the life @@ -162,6 +167,7 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference if( fLife == 0 ) // the player has not pressed the button for a long time! { hns = HNS_NG; + GAMESTATE->GetLatestGameplayStatistics().iActualDancePoints[m_PlayerNumber] += HoldNoteScoreToDancePoints( hns ); m_Combo.EndCombo(); m_HoldJudgement[hn.m_iTrack].SetHoldJudgement( HNS_NG ); } @@ -172,6 +178,7 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference // At this point fLife > 0, or else we would have marked it NG above fLife = 1; hns = HNS_OK; + GAMESTATE->GetLatestGameplayStatistics().iActualDancePoints[m_PlayerNumber] += HoldNoteScoreToDancePoints( hns ); m_HoldJudgement[hn.m_iTrack].SetHoldJudgement( HNS_OK ); m_NoteField.SetHoldNoteLife( i, fLife ); // update the NoteField display } @@ -181,7 +188,8 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference ActorFrame::Update( fDeltaTime ); - m_frameJudgeAndCombo.Update( fDeltaTime ); + m_frameJudgement.Update( fDeltaTime ); + m_frameCombo.Update( fDeltaTime ); if( m_pLifeMeter ) m_pLifeMeter->SetBeat( fSongBeat ); @@ -189,9 +197,6 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference m_GrayArrowRow.Update( fDeltaTime, fSongBeat ); m_NoteField.Update( fDeltaTime, fSongBeat ); m_GhostArrowRow.Update( fDeltaTime, fSongBeat ); - - m_fSongBeat = fSongBeat; // save song beat - } void Player::DrawPrimitives() @@ -222,6 +227,8 @@ void Player::DrawPrimitives() DISPLAY->GetDevice()->SetTransform( D3DTS_PROJECTION, &matNewProj ); } + m_frameCombo.Draw(); + m_GrayArrowRow.Draw(); m_NoteField.Draw(); m_GhostArrowRow.Draw(); @@ -237,7 +244,7 @@ void Player::DrawPrimitives() DISPLAY->GetDevice()->SetRenderState( D3DRS_ZWRITEENABLE, TRUE ); } - m_frameJudgeAndCombo.Draw(); + m_frameJudgement.Draw(); for( int c=0; cAddToScore( score, m_Combo.GetCurrentCombo() ); // update score - called once per note in this row + // update dance points for Oni lifemeter + GAMESTATE->GetLatestGameplayStatistics().iActualDancePoints[m_PlayerNumber] += TapNoteScoreToDancePoints( score ); + // update combo - called once per note in this row switch( score ) { @@ -383,9 +393,13 @@ void Player::OnRowDestroyed( float fSongBeat, int col, float fMaxBeatDiff, int i case TNS_GOOD: fStartZoom = 1.2f; break; case TNS_BOO: fStartZoom = 1.0f; break; } - m_frameJudgeAndCombo.SetZoom( fStartZoom ); - m_frameJudgeAndCombo.BeginTweening( 0.2f ); - m_frameJudgeAndCombo.SetTweenZoom( 1 ); + m_frameJudgement.SetZoom( fStartZoom ); + m_frameJudgement.BeginTweening( 0.2f ); + m_frameJudgement.SetTweenZoom( 1 ); + + m_frameCombo.SetZoom( fStartZoom ); + m_frameCombo.BeginTweening( 0.2f ); + m_frameCombo.SetTweenZoom( 1 ); } @@ -443,16 +457,12 @@ void Player::CrossedRow( int iNoteRow, float fSongBeat, float fMaxBeatDiff ) -GameplayStatistics Player::GetGameplayStatistics( Song* pS, Notes* pN ) +void Player::SaveGameplayStatistics() { - GameplayStatistics GSreturn; + GameplayStatistics& GS = GAMESTATE->m_aGameplayStatistics[GAMESTATE->m_aGameplayStatistics.GetSize()-1]; + int p = m_PlayerNumber; - GSreturn.pSong = pS; - Notes* pNotes = pN; - GSreturn.dc = pNotes->m_DifficultyClass; - GSreturn.meter = pNotes->m_iMeter; - GSreturn.iPossibleDancePoints = ((NoteData*)this)->GetPossibleDancePoints(); - GSreturn.iActualDancePoints = 0; + GS.iActualDancePoints[p] = 0; for( int t=0; tGetScore() : 0; + GS.max_combo[p] = m_Combo.GetMaxCombo(); + GS.score[p] = m_pScore ? m_pScore->GetScore() : 0; - GSreturn.failed = m_pLifeMeter ? m_pLifeMeter->HasFailed() : false; + GS.failed[p] = m_pLifeMeter ? m_pLifeMeter->FailedEarlier() : false; for( int r=0; rGetRadarValue( (RadarCategory)r, pS->m_fMusicLengthSeconds ); - GSreturn.fRadarActual[r] = this->GetActualRadarValue( (RadarCategory)r, pS->m_fMusicLengthSeconds ); - - GSreturn.fRadarPossible[r] = clamp( GSreturn.fRadarPossible[r], 0, 1 ); - GSreturn.fRadarActual[r] = clamp( GSreturn.fRadarActual[r], 0, 1 ); + GS.fRadarActual[p][r] = this->GetActualRadarValue( (RadarCategory)r, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); + CLAMP( GS.fRadarActual[p][r], 0, 1 ); } - - return GSreturn; } diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 9772c86241..c065509086 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -1,7 +1,7 @@ #pragma once /* ----------------------------------------------------------------------------- - File: Player.h + Class: Player Desc: Object that accepts pad input, knocks down ColorNotes that were stepped on, and keeps score for the player. @@ -23,7 +23,7 @@ #include "HoldGhostArrow.h" #include "ActorFrame.h" #include "RandomSample.h" -#include "ScoreDisplayRolling.h" +#include "ScoreDisplay.h" #include "LifeMeterBar.h" #include "Judgement.h" #include "HoldJudgement.h" @@ -44,12 +44,12 @@ public: void Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference ); void DrawPrimitives(); - void Load( PlayerNumber player_no, StyleDef *pStyleDef, NoteData* pNoteData, const PlayerOptions& po, LifeMeterBar* pLM, ScoreDisplayRolling* pScore, int iOriginalNumNotes, int iNotesMeter ); + void Load( PlayerNumber player_no, StyleDef *pStyleDef, NoteData* pNoteData, const PlayerOptions& po, LifeMeter* pLM, ScoreDisplay* pScore, int iOriginalNumNotes, int iNotesMeter ); void CrossedRow( int iNoteRow, float fSongBeat, float fMaxBeatDiff ); void HandlePlayerStep( float fSongBeat, int col, float fMaxBeatDiff ); int UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat ); - GameplayStatistics GetGameplayStatistics( Song* pS, Notes* pN ); + void SaveGameplayStatistics(); void SetOverrideAdd( float fAdd ) { m_NoteField.m_fOverrideAdd = fAdd; }; float GetOverrideAdd() { return m_NoteField.m_fOverrideAdd; }; @@ -74,10 +74,14 @@ protected: GhostArrowRow m_GhostArrowRow; HoldJudgement m_HoldJudgement[MAX_NOTE_TRACKS]; - ActorFrame m_frameJudgeAndCombo; + + ActorFrame m_frameJudgement; Judgement m_Judgement; + + ActorFrame m_frameCombo; Combo m_Combo; - LifeMeterBar* m_pLifeMeter; - ScoreDisplayRolling* m_pScore; + + LifeMeter* m_pLifeMeter; + ScoreDisplay* m_pScore; }; diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index dd095289a8..0d087853be 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -13,6 +13,7 @@ #include "PrefsManager.h" #include "IniFile.h" #include "GameManager.h" +#include "GameState.h" PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program @@ -21,8 +22,9 @@ PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our pro PrefsManager::PrefsManager() { m_bWindowed = false; - m_bHighDetail = true; - m_bHighTextureDetail = false; + m_iDisplayResolution = 640; + m_iTextureResolution = 512; + m_iRefreshRate = 60; m_bIgnoreJoyAxes = false; m_bShowFPS = false; m_BackgroundMode = BGMODE_ANIMATIONS; @@ -33,21 +35,16 @@ PrefsManager::PrefsManager() m_bAutoPlay = false; m_fJudgeWindow = 0.18f; - for( int p=0; pSwitchGame( game ); + } } -void PrefsManager::SavePrefsToDisk() +void PrefsManager::SaveGlobalPrefsToDisk() { IniFile ini; ini.SetPath( "StepMania.ini" ); ini.SetValueB( "Options", "Windowed", m_bWindowed ); - ini.SetValueB( "Options", "HighDetail", m_bHighDetail ); - ini.SetValueB( "Options", "HighTextureDetail", m_bHighTextureDetail ); + ini.SetValueI( "Options", "DisplayResolution", m_iDisplayResolution ); + ini.SetValueI( "Options", "TextureResolution", m_iTextureResolution ); + ini.SetValueI( "Options", "RefreshRate", m_iRefreshRate ); ini.SetValueB( "Options", "IgnoreJoyAxes", m_bIgnoreJoyAxes ); ini.SetValueB( "Options", "ShowFPS", m_bShowFPS ); ini.SetValueI( "Options", "BackgroundMode", m_BackgroundMode); @@ -94,78 +97,48 @@ void PrefsManager::SavePrefsToDisk() ini.SetValueB( "Options", "AutoPlay", m_bAutoPlay ); ini.SetValueF( "Options", "JudgeWindow", m_fJudgeWindow ); - ini.SetValue( "Options", "Announcer", m_sAnnouncer ); - ini.SetValue( "Options", "NoteSkin", m_sNoteSkin ); - ini.SetValue( "Options", "SongFolders", join(",", m_asSongFolders) ); + ini.SetValueI( "Options", "Game", GAMESTATE->GetCurGame() ); + ini.WriteFile(); } -int PrefsManager::GetStageIndex() +void PrefsManager::ReadGamePrefsFromDisk() { - return m_iCurrentStageIndex; + if( !GAMESTATE ) + return; + + CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName; + IniFile ini; + ini.SetPath( sGameName + "Prefs.ini" ); + if( !ini.ReadFile() ) + return; // could not read config file, load nothing + + CString sAnnouncer, sTheme, sNoteSkin; + + ini.GetValue( "Options", "Announcer", sAnnouncer ); + ini.GetValue( "Options", "Theme", sTheme ); + ini.GetValue( "Options", "NoteSkin", sNoteSkin ); + + + ANNOUNCER->SwitchAnnouncer( sAnnouncer ); + THEME->SwitchTheme( sTheme ); + GAMEMAN->SwitchNoteSkin( sNoteSkin ); } -bool PrefsManager::IsFinalStage() +void PrefsManager::SaveGamePrefsToDisk() { - if( PREFSMAN->m_bEventMode ) - return false; - return m_iCurrentStageIndex == m_iNumArcadeStages-1; + if( !GAMESTATE ) + return; + + CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName; + IniFile ini; + ini.SetPath( sGameName + "Prefs.ini" ); + + ini.SetValue( "Options", "Announcer", ANNOUNCER->GetCurAnnouncerName() ); + ini.SetValue( "Options", "Theme", THEME->GetCurThemeName() ); + ini.SetValue( "Options", "NoteSkin", GAMEMAN->GetCurNoteSkin() ); + + ini.WriteFile(); } - -bool PrefsManager::IsExtraStage() -{ - if( PREFSMAN->m_bEventMode ) - return false; - return m_iCurrentStageIndex == m_iNumArcadeStages; -} - -bool PrefsManager::IsExtraStage2() -{ - if( PREFSMAN->m_bEventMode ) - return false; - return m_iCurrentStageIndex == m_iNumArcadeStages+1; -} - -CString PrefsManager::GetStageText() -{ - if( IsFinalStage() ) - return "Final"; - else if( IsExtraStage() ) - return "Extra"; - else if( IsExtraStage2() ) - return "Extra 2"; - - - int iStageNo = m_iCurrentStageIndex+1; - - CString sNumberSuffix; - if( ( (iStageNo/10) % 10 ) == 1 ) // in the teens (e.g. 19, 213) - { - sNumberSuffix = "th"; - } - else // not in the teens - { - const int iLastDigit = iStageNo%10; - switch( iLastDigit ) - { - case 1: sNumberSuffix = "st"; break; - case 2: sNumberSuffix = "nd"; break; - case 3: sNumberSuffix = "rd"; break; - default:sNumberSuffix = "th"; break; - } - } - return ssprintf( "%d%s", iStageNo, sNumberSuffix ); -} - -D3DXCOLOR PrefsManager::GetStageColor() -{ - if( IsFinalStage() ) - return D3DXCOLOR(1,0.1f,0.1f,1); // red - else if( IsExtraStage() || IsExtraStage2() ) - return D3DXCOLOR(1,1,0.3f,1); // yellow - else - return D3DXCOLOR(0.3f,1,0.3f,1); // green -} - diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 3313910db1..cbb657c90d 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -3,9 +3,7 @@ ----------------------------------------------------------------------------- Class: PrefsManager - Desc: Holds user-chosen preferences and saves it between sessions. This class - also has temporary holders for information that passed between windows - e.g. - GameplayStatistics. + Desc: Holds user-chosen preferences that are saved between sessions. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford @@ -15,7 +13,9 @@ #include "GameConstantsAndTypes.h" -const int NUM_PAD_TO_DEVICE_SLOTS = 3; // three device inputs may map to one pad input +#include "AnnouncerManager.h" +#include "ThemeManager.h" +#include "GameManager.h" class PrefsManager @@ -28,8 +28,9 @@ public: // GameOptions (ARE saved between sessions) bool m_bWindowed; - bool m_bHighDetail; - bool m_bHighTextureDetail; + int m_iDisplayResolution; + int m_iTextureResolution; + int m_iRefreshRate; bool m_bIgnoreJoyAxes; bool m_bShowFPS; BackgroundMode m_BackgroundMode; @@ -40,32 +41,34 @@ public: bool m_bAutoPlay; float m_fJudgeWindow; - // AppearanceOptions (ARE saved between sessions) - CString m_sAnnouncer; - CString m_sNoteSkin; - CStringArray m_asSongFolders; - void ReadPrefsFromDisk(); - void SavePrefsToDisk(); + int GetDisplayHeight() + { + switch( m_iDisplayResolution ) + { + case 1280: return 1024; break; + case 1024: return 768; break; + case 800: return 600; break; + case 640: return 480; break; + case 512: return 384; break; + case 400: return 300; break; + case 320: return 240; break; + default: throw RageException( "Invalid DisplayWidth '%d'", m_iDisplayResolution ); return 480; + } + } + + void ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame ); + void SaveGlobalPrefsToDisk(); - // Options that are NOT saved between sessions - DifficultyClass m_PreferredDifficultyClass[NUM_PLAYERS]; - SongSortOrder m_SongSortOrder; // used by MusicWheel and should be saved until the app exits - PlayMode m_PlayMode; - int m_iCurrentStageIndex; // starts at 0, and is incremented with each Stage Clear + // AppearanceOptions (ARE saved between sessions, and saved per game) +// CString m_sAnnouncer; // need to make sure to call ANNOUNCER->SwitchAnnouncer() when this changes +// CString m_sTheme; // need to make sure to call THEME->SwitchTheme() when this changes +// CString m_sNoteSkin; - int GetStageIndex(); - bool IsFinalStage(); - bool IsExtraStage(); - bool IsExtraStage2(); - CString GetStageText(); - D3DXCOLOR GetStageColor(); - - - PlayerOptions m_PlayerOptions[NUM_PLAYERS]; - SongOptions m_SongOptions; + void ReadGamePrefsFromDisk(); + void SaveGamePrefsToDisk(); }; diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index ee0cb4915f..32e327ed01 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -103,9 +103,12 @@ RageDisplay::~RageDisplay() // Desc: //----------------------------------------------------------------------------- bool RageDisplay::SwitchDisplayMode( - const bool bWindowed, const DWORD dwWidth, const DWORD dwHeight, const DWORD dwBPP ) + const bool bWindowed, const int iWidth, const int iHeight, const int iBPP, const int iFullScreenHz ) { - LOG->WriteLine( "RageDisplay::SwitchDisplayModes( %d, %u, %u, %u )", bWindowed, dwWidth, dwHeight, dwBPP ); + LOG->WriteLine( "RageDisplay::SwitchDisplayModes( %d, %d, %d, %d, %d )", bWindowed, iWidth, iHeight, iBPP, iFullScreenHz ); + + if( !bWindowed ) + SetCursor( NULL ); HRESULT hr; @@ -126,7 +129,7 @@ bool RageDisplay::SwitchDisplayMode( else // full screen { // add only the formats that match dwBPP - switch( dwBPP ) + switch( iBPP ) { case 16: arrayBackBufferFormats.Add( D3DFMT_R5G6B5 ); @@ -139,7 +142,7 @@ bool RageDisplay::SwitchDisplayMode( arrayBackBufferFormats.Add( D3DFMT_A8R8G8B8 ); break; default: - throw RageException( ssprintf("Invalid BPP '%u' specified", dwBPP) ); + throw RageException( ssprintf("Invalid BPP '%u' specified", iBPP) ); return false; } } @@ -184,7 +187,7 @@ bool RageDisplay::SwitchDisplayMode( if( i == arrayBackBufferFormats.GetSize() ) // we didn't find an appropriate format { - LOG->WriteLineHr( hr, "failed to find an appropriate format for %d, %u, %u, %u.", bWindowed, dwWidth, dwHeight, dwBPP ); + LOG->WriteLineHr( hr, "failed to find an appropriate format for %d, %u, %u, %u.", bWindowed, iWidth, iHeight, iBPP ); return false; } @@ -193,8 +196,8 @@ bool RageDisplay::SwitchDisplayMode( // Set up presentation parameters for the display ZeroMemory( &m_d3dpp, sizeof(m_d3dpp) ); - m_d3dpp.BackBufferWidth = dwWidth; - m_d3dpp.BackBufferHeight = dwHeight; + m_d3dpp.BackBufferWidth = iWidth; + m_d3dpp.BackBufferHeight = iHeight; m_d3dpp.BackBufferFormat = fmtBackBuffer; m_d3dpp.BackBufferCount = 1; m_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; @@ -204,7 +207,7 @@ bool RageDisplay::SwitchDisplayMode( m_d3dpp.EnableAutoDepthStencil = TRUE; m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; m_d3dpp.Flags = 0; - m_d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; + m_d3dpp.FullScreen_RefreshRateInHz = bWindowed ? D3DPRESENT_RATE_DEFAULT : iFullScreenHz; m_d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; LOG->WriteLine( "Present Parameters: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", @@ -245,7 +248,7 @@ bool RageDisplay::SwitchDisplayMode( D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &m_d3dpp, &m_pd3dDevice) ) ) { - LOG->WriteLineHr( hr, "failed to create device: %d, %u, %u, %u.", bWindowed, dwWidth, dwHeight, dwBPP ); + LOG->WriteLineHr( hr, "failed to create device: %d, %u, %u, %u.", bWindowed, iWidth, iHeight, iBPP ); return false; } LOG->WriteLine( @@ -261,7 +264,7 @@ bool RageDisplay::SwitchDisplayMode( // device is already created. Just reset it. if( FAILED( hr = m_pd3dDevice->Reset( &m_d3dpp ) ) ) { - LOG->WriteLineHr( hr, "failed to reset device: %d, %u, %u, %u.", bWindowed, dwWidth, dwHeight, dwBPP ); + LOG->WriteLineHr( hr, "failed to reset device: %d, %u, %u, %u.", bWindowed, iWidth, iHeight, iBPP ); return false; } } diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 81131c69de..251665adf3 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -41,7 +41,7 @@ public: RageDisplay( HWND hWnd ); ~RageDisplay(); bool SwitchDisplayMode( - const bool bWindowed, const DWORD dwWidth, const DWORD dwHeight, const DWORD dwBPP ); + const bool bWindowed, const int iWidth, const int iHeight, const int iBPP, const int iFullScreenHz ); LPDIRECT3D8 GetD3D() { return m_pd3d; }; inline LPDIRECT3DDEVICE8 GetDevice() { return m_pd3dDevice; }; diff --git a/stepmania/src/RageLog.cpp b/stepmania/src/RageLog.cpp index a1f6ac438c..f2836a9ac4 100644 --- a/stepmania/src/RageLog.cpp +++ b/stepmania/src/RageLog.cpp @@ -31,8 +31,6 @@ RageLog::RageLog() // delete old log files DeleteFile( LOG_FILE_NAME ); - ShowConsole(); - // Open log file and leave it open. Let the OS close it when the app exits m_fileLog = fopen( LOG_FILE_NAME, "w" ); diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index a4998e79c1..3aeb2f3dcc 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -12,7 +12,9 @@ */ #include "RageUtil.h" -#include "RageCRC32.h" // Backend for GetHashForString + +ULONG randseed = time(NULL); + bool IsAnInt( LPCTSTR s ) @@ -21,10 +23,8 @@ bool IsAnInt( LPCTSTR s ) return false; for( UINT i=0; i '9' ) return false; - } return true; } @@ -286,16 +286,6 @@ void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bRe ::FindClose( hFind ); } -//----------------------------------------------------------------------------- -// Name: GetCrc32ForString( CString s) -// Desc: Coerces CString into an unsigned char array and runs CRC-32 on it. -//----------------------------------------------------------------------------- -unsigned int GetCrc32ForString( CString s ) -{ - // A CString has built in length data! Isn't that great? - return GetCrc32((unsigned char*)s.GetBuffer(s.GetLength()), s.GetLength()); -} - //----------------------------------------------------------------------------- // Name: GetHashForString( CString s ) // Desc: This new version of GetHashForString uses a stronger hashing algorithm @@ -305,9 +295,139 @@ unsigned int GetCrc32ForString( CString s ) // characters in the CString are recast as unsigned char and that the // unsigned int result from the hash is recast as a signed int). //----------------------------------------------------------------------------- -int GetHashForString ( CString s ) +int GetHashForString ( CString string ) { - return (int)abs(GetCrc32((unsigned char*)s.GetBuffer(s.GetLength()), s.GetLength())); +/* + * RageCRC32.cpp + * + * Original code + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + * + * Code was extracted from IETF Internet Draft + * draft-ietf-tsvwg-sctpcsum-00 at URI + * http://www.ietf.org/proceedings/01dec/I-D/draft-ietf-tsvwg-sctpcsum-00.txt + * + * Adaptation + * Copyright (C) 2002 Peter S. May. + * SourceForge ID: drokulix + * + * - Header file added + * - Name of function changed to GetCrc32 + * - Values in table changed from long int to int + * + * Chris: + * Moved this code out of RageCRC32 since it's not terribly long. Thanks Dro Kulix! + */ + +/* + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + * + * First, the polynomial itself and its table of feedback terms. The + * polynomial is + * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + * + * Note that we take it "backwards" and put the highest-order term in + * the lowest-order bit. The X^32 term is "implied"; the LSB is the + * X^31 term, etc. The X^0 term (usually shown as "+1") results in + * the MSB being 1 + * + * Note that the usual hardware shift register implementation, which + * is what we're using (we're merely optimizing it by doing eight-bit + * chunks at a time) shifts bits into the lowest-order term. In our + * implementation, that means shifting towards the right. Why do we + * do it this way? Because the calculated CRC must be transmitted in + * order from highest-order term to lowest-order term. UARTs transmit + * characters in order from LSB to MSB. By storing the CRC this way + * we hand it to the UART in the order low-byte to high-byte; the UART + * sends each low-bit to hight-bit; and the result is transmission bit + * by bit from highest- to lowest-order term without requiring any bit + * shuffling on our part. Reception works similarly + * + * The feedback terms table consists of 256, 32-bit entries. Notes + * + * The table can be generated at runtime if desired; code to do so + * is shown later. It might not be obvious, but the feedback + * terms simply represent the results of eight shift/xor opera + * tions for all combinations of data and CRC register values + * + * The values must be right-shifted by eight bits by the "updcrc + * logic; the shift must be unsigned (bring in zeroes). On some + * hardware you could probably optimize the shift in assembler by + * using byte-swap instructions + * polynomial $edb88320 + */ + +static const unsigned int crc32_tab[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d +}; + +/* Return a 32-bit CRC of the contents of the buffer. */ + +//unsigned int +//GetCrc32(const unsigned char *s, unsigned int len) +//{ + const char* s = string; + int len = string.GetLength(); + + unsigned int crc32val = 0; + for( int i=0; i> 8); + + return crc32val; +//} } int GetHashForFile( CString sPath ) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index c3ed424355..2a6abcb887 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -3,7 +3,7 @@ ----------------------------------------------------------------------------- File: RageUtil - Desc: Miscellaneous helper functions. + Desc: Miscellaneous helper macros and functions. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford @@ -18,10 +18,8 @@ #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } +#define ZERO(x) memset(&x, 0, sizeof(x)) -//----------------------------------------------------------------------------- -// Other Macros -//----------------------------------------------------------------------------- #define RECTWIDTH(rect) ((rect).right - (rect).left) #define RECTHEIGHT(rect) ((rect).bottom - (rect).top) inline int RECTCENTERX(RECT rect) { return rect.left + (rect.right-rect.left)/2; } @@ -37,11 +35,55 @@ inline int RECTCENTERY(RECT rect) { return rect.top + (rect.bottom-rect.top)/2; #define clamp(val,low,high) ( max( (low), min((val),(high)) ) ) +#define PI D3DX_PI +#define DEG (PI / 180.0f) +#define RAD (180.0f / PI) +// Scales x so that l1 corresponds to l2 and h1 corresponds to h2. Does not modify x, MUST assign the result to something! +#define SCALE(x, l1, h1, l2, h2) (((x) - (l1)) / ((h1) - (l1)) * ((h2) - (l2)) + (l2)) +// Clamps x +#define CLAMP(x, l, h) {if (x > h) x = h; else if (x < l) x = l;} + //----------------------------------------------------------------------------- // Misc helper functions //----------------------------------------------------------------------------- +// Fast random number generators +// Taken from "Numerical Recipes in C" + +extern ULONG randseed; + +inline ULONG Random() +{ + randseed = 1664525L * randseed + 1013904223L; + return randseed; +} + +inline float RandomFloat() +{ + randseed = 1664525L * randseed + 1013904223L; + ULONG itemp = 0x3f800000 | (0x007fffff & randseed); + return (*(float *)&itemp) - 1.0f; +} + +// Returns a float between dLow and dHigh inclusive +inline float RandomFloat(float fLow, float fHigh) +{ + return RandomFloat() * (fHigh - fLow) + fLow; +} + +// Returns an integer between nLow and nHigh inclusive +inline int RandomInt(int nLow, int nHigh) +{ + return ((Random() >> 2) % (nHigh - nLow + 1)) + nLow; +} + +// Debug new for memory leak tracing +//#ifdef _DEBUG +//#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) +//#endif + + // Simple function for generating random numbers inline float randomf( const float low=-1.0f, const float high=1.0f ) { @@ -98,7 +140,6 @@ CString join( void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs=false, bool bReturnPathToo=false ); int GetHashForString( CString s ); -unsigned int GetCrc32ForString( CString s ); int GetHashForFile( CString sPath ); int GetHashForDirectory( CString sDir ); // a hash value that remains the same as long as nothing in the directory has changed diff --git a/stepmania/src/RandomSample.cpp b/stepmania/src/RandomSample.cpp index 57b3ecf865..edad2d1540 100644 --- a/stepmania/src/RandomSample.cpp +++ b/stepmania/src/RandomSample.cpp @@ -31,6 +31,9 @@ RandomSample::~RandomSample() bool RandomSample::LoadSoundDir( CString sDir ) { + if( sDir == "" ) + return true; + // make sure there's a backslash at the end of this path if( sDir[sDir.GetLength()-1] != '\\' ) sDir += "\\"; diff --git a/stepmania/src/ScoreDisplay.cpp b/stepmania/src/ScoreDisplay.cpp new file mode 100644 index 0000000000..8059fd4677 --- /dev/null +++ b/stepmania/src/ScoreDisplay.cpp @@ -0,0 +1,18 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: ScoreDisplay.h + + Desc: A graphic displayed in the ScoreDisplay during Dancing. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ScoreDisplay.h" +#include "RageUtil.h" +#include "RageLog.h" +#include "PrefsManager.h" +#include "RageLog.h" +#include "GameState.h" diff --git a/stepmania/src/ScoreDisplay.h b/stepmania/src/ScoreDisplay.h new file mode 100644 index 0000000000..c82bf54ddc --- /dev/null +++ b/stepmania/src/ScoreDisplay.h @@ -0,0 +1,33 @@ +#pragma once +/* +----------------------------------------------------------------------------- + Class: ScoreDisplay + + Desc: A graphic displayed in the ScoreDisplay during Dancing. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "Sprite.h" +#include "Song.h" +#include "ActorFrame.h" +#include "BitmapText.h" + + + +class ScoreDisplay : public BitmapText +{ +public: + virtual void Init( PlayerNumber pn, PlayerOptions po, int iOriginalNumNotes, int iNotesMeter ) = 0; + + virtual void SetScore( float fNewScore ) = 0; + virtual int GetScore() = 0; + virtual void AddToScore( TapNoteScore score, int iCurCombo ) = 0; + + virtual void Update( float fDeltaTime ) = 0; + virtual void Draw() = 0; + +protected: +}; diff --git a/stepmania/src/ScoreDisplayNormal.cpp b/stepmania/src/ScoreDisplayNormal.cpp new file mode 100644 index 0000000000..2a5a4edfe7 --- /dev/null +++ b/stepmania/src/ScoreDisplayNormal.cpp @@ -0,0 +1,159 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: ScoreDisplayNormal.h + + Desc: A graphic displayed in the ScoreDisplayNormal during Dancing. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ScoreDisplayNormal.h" +#include "RageUtil.h" +#include "RageLog.h" +#include "PrefsManager.h" +#include "RageLog.h" +#include "GameState.h" + + +const float SCORE_TWEEN_TIME = 0.5f; + + +ScoreDisplayNormal::ScoreDisplayNormal() +{ + LOG->WriteLine( "ScoreDisplayNormal::ScoreDisplayNormal()" ); + + // init the text + Load( THEME->GetPathTo(FONT_SCORE_NUMBERS) ); + TurnShadowOff(); + + m_fTrailingScore = 0; + + SetScore( 0 ); +} + + +void ScoreDisplayNormal::Init( PlayerNumber pn, PlayerOptions po, int iOriginalNumNotes, int iNotesMeter ) +{ + m_PlayerNumber = pn; + m_PlayerOptions = po; + m_iTotalNotes = iOriginalNumNotes; + m_iNotesMeter = iNotesMeter; + + //for( int i=0; im_bAutoPlay ) + return; // No Scoring on Autoplay! + + + static int iNumTimesCalled = 0; + iNumTimesCalled ++; + LOG->WriteLine("Called %d times - param %d.",iNumTimesCalled, iCurCombo); + + + int p; // score multiplier + switch( score ) + { + case TNS_PERFECT: p = 10; break; + case TNS_GREAT: p = 5; break; + default: p = 0; break; + } + + int N = m_iTotalNotes; + int n = iCurCombo+1; + int B = m_iNotesMeter * 1000000; + float S = (1+N)*N/2.0f; + + int one_step_score = roundf( p * (B/S) * n ); + + m_fScore += one_step_score; + ASSERT( m_fScore >= 0 ); + + // HACK: The final total is slightly off because of rounding errors + if( fabsf(m_fScore-B*10) < 100.0f ) + m_fScore = (float)B*10; + + this->SetScore( m_fScore ); +} diff --git a/stepmania/src/ScoreDisplayNormal.h b/stepmania/src/ScoreDisplayNormal.h new file mode 100644 index 0000000000..dd2a1461d6 --- /dev/null +++ b/stepmania/src/ScoreDisplayNormal.h @@ -0,0 +1,43 @@ +#pragma once +/* +----------------------------------------------------------------------------- + Class: ScoreDisplayNormal + + Desc: A graphic displayed in the ScoreDisplayNormal during Dancing. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ScoreDisplay.h" + + +const int NUM_SCORE_DIGITS = 9; + + +class ScoreDisplayNormal : public ScoreDisplay +{ +public: + ScoreDisplayNormal(); + + virtual void Init( PlayerNumber pn, PlayerOptions po, int iOriginalNumNotes, int iNotesMeter ); + + virtual void SetScore( float fNewScore ); + virtual int GetScore(); + virtual void AddToScore( TapNoteScore score, int iCurCombo ); + + virtual void Update( float fDeltaTime ); + virtual void Draw(); + +protected: + PlayerNumber m_PlayerNumber; + PlayerOptions m_PlayerOptions; + int m_iTotalNotes; + int m_iNotesMeter; + + float m_fScore; + + float m_fTrailingScore; + float m_fScoreVelocity; +}; diff --git a/stepmania/src/ScoreDisplayOni.cpp b/stepmania/src/ScoreDisplayOni.cpp new file mode 100644 index 0000000000..588d0ee51b --- /dev/null +++ b/stepmania/src/ScoreDisplayOni.cpp @@ -0,0 +1,152 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: ScoreDisplayOni.h + + Desc: A graphic displayed in the ScoreDisplayOni during Dancing. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ScoreDisplayOni.h" +#include "RageUtil.h" +#include "RageLog.h" +#include "PrefsManager.h" +#include "RageLog.h" +#include "GameState.h" + + +const float SCORE_TWEEN_TIME = 0.5f; + + +ScoreDisplayOni::ScoreDisplayOni() +{ + LOG->WriteLine( "ScoreDisplayOni::ScoreDisplayOni()" ); + + // init the text + Load( THEME->GetPathTo(FONT_SCORE_NUMBERS) ); + TurnShadowOff(); + + m_fTrailingScore = 0; + + SetScore( 0 ); +} + + +void ScoreDisplayOni::Init( PlayerNumber pn, PlayerOptions po, int iOriginalNumNotes, int iNotesMeter ) +{ + m_PlayerNumber = pn; + m_PlayerOptions = po; + m_iTotalNotes = iOriginalNumNotes; + m_iNotesMeter = iNotesMeter; + + //for( int i=0; im_aGameplayStatistics.GetSize(); i++ ) + fSecsIntoPlay += GAMESTATE->m_aGameplayStatistics[i].fSecsIntoPlay[m_PlayerNumber]; + int iMinsDisplay = (int)fSecsIntoPlay/60; + int iSecsDisplay = (int)fSecsIntoPlay - iMinsDisplay*60; + int iLeftoverDisplay = int( (fSecsIntoPlay - iMinsDisplay*60 - iSecsDisplay) * 100 ); + SetText( ssprintf( "%02d:%02d:%02d", iMinsDisplay, iSecsDisplay, iLeftoverDisplay ) ); + + BitmapText::Draw(); +} + + +void ScoreDisplayOni::AddToScore( TapNoteScore score, int iCurCombo ) +{ +//A single step's points are calculated as follows: +// +//Let p = score multiplier (Perfect = 10, Great = 5, other = 0) +//N = total number of steps and freeze steps +//n = number of the current step or freeze step (varies from 1 to N) +//B = Base value of the song (1,000,000 X the number of feet difficulty) - All edit data is rated as 5 feet +//So, the score for one step is: +//one_step_score = p * (B/S) * n +//Where S = The sum of all integers from 1 to N (the total number of steps/freeze steps) +// +//*IMPORTANT* : Double steps (U+L, D+R, etc.) count as two steps instead of one, so if you get a double L+R on the 112th step of a song, you score is calculated with a Perfect/Great/whatever for both the 112th and 113th steps. Got it? Now, through simple algebraic manipulation +//S = 1+...+N = (1+N)*N/2 (1 through N added together) +//Okay, time for an example: +// +//So, for example, suppose we wanted to calculate the step score of a "Great" on the 57th step of a 441 step, 8-foot difficulty song (I'm just making this one up): +// +//S = (1 + 441)*441 / 2 +//= 194,222 / 2 +//= 97,461 +//StepScore = p * (B/S) * n +//= 5 * (8,000,000 / 97,461) * 57 +//= 5 * (82) * 57 (The 82 is rounded down from 82.08411...) +//= 23,370 +//Remember this is just the score for the step, not the cumulative score up to the 57th step. Also, please note that I am currently checking into rounding errors with the system and if there are any, how they are resolved in the system. +// +//Note: if you got all Perfect on this song, you would get (p=10)*B, which is 80,000,000. In fact, the maximum possible score for any song is the number of feet difficulty X 10,000,000. + + static int iNumTimesCalled = 0; + iNumTimesCalled ++; + LOG->WriteLine("Called %d times - param %d.",iNumTimesCalled, iCurCombo); + + + int p; // score multiplier + switch( score ) + { + case TNS_PERFECT: p = 10; break; + case TNS_GREAT: p = 5; break; + default: p = 0; break; + } + + int N = m_iTotalNotes; + int n = iCurCombo+1; + int B = m_iNotesMeter * 1000000; + float S = (1+N)*N/2.0f; + + int one_step_score = roundf( p * (B/S) * n ); + + m_fScore += one_step_score; + ASSERT( m_fScore >= 0 ); + + // HACK: The final total is slightly off because of rounding errors + if( fabsf(m_fScore-B*10) < 100.0f ) + m_fScore = (float)B*10; + + this->SetScore( m_fScore ); +} diff --git a/stepmania/src/ScoreDisplayOni.h b/stepmania/src/ScoreDisplayOni.h new file mode 100644 index 0000000000..a54f560127 --- /dev/null +++ b/stepmania/src/ScoreDisplayOni.h @@ -0,0 +1,42 @@ +#pragma once +/* +----------------------------------------------------------------------------- + Class: ScoreDisplayOni + + Desc: A graphic displayed in the ScoreDisplayOni during Dancing. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "Song.h" +#include "ScoreDisplay.h" + + + +class ScoreDisplayOni : public ScoreDisplay +{ +public: + ScoreDisplayOni(); + + virtual void Init( PlayerNumber pn, PlayerOptions po, int iOriginalNumNotes, int iNotesMeter ); + + virtual void SetScore( float fNewScore ); + virtual int GetScore(); + virtual void AddToScore( TapNoteScore score, int iCurCombo ); + + virtual void Update( float fDeltaTime ); + virtual void Draw(); + +protected: + PlayerNumber m_PlayerNumber; + PlayerOptions m_PlayerOptions; + int m_iTotalNotes; + int m_iNotesMeter; + + float m_fScore; + + float m_fTrailingScore; + float m_fScoreVelocity; +}; diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index 4b1f36ec13..f13b3ad2a8 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -12,6 +12,7 @@ #include "Screen.h" #include "GameManager.h" +#include "GameState.h" Screen::Screen() { @@ -51,7 +52,7 @@ void Screen::Input( const DeviceInput& DeviceI, const InputEventType type, const if( !MenuI.IsValid() ) return; - if( !GAMEMAN->IsPlayerEnabled(MenuI.player) ) + if( !GAMESTATE->IsPlayerEnabled(MenuI.player) ) return; switch( MenuI.button ) diff --git a/stepmania/src/ScreenAppearanceOptions.cpp b/stepmania/src/ScreenAppearanceOptions.cpp index eff4698aee..232dbd06a7 100644 --- a/stepmania/src/ScreenAppearanceOptions.cpp +++ b/stepmania/src/ScreenAppearanceOptions.cpp @@ -21,22 +21,25 @@ #include "ScreenTitleMenu.h" #include "GameConstantsAndTypes.h" #include "StepMania.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" #include "AnnouncerManager.h" #include "GameManager.h" +#include "GameState.h" enum { AO_ANNOUNCER = 0, + AO_THEME, AO_SKIN, NUM_APPEARANCE_OPTIONS_LINES }; OptionLineData g_AppearanceOptionsLines[NUM_APPEARANCE_OPTIONS_LINES] = { { "Announcer", 1, {"OFF"} }, // fill this in on ImportOptions() - { "Note Skin", 0, {""} }, // fill this in on ImportOptions() + { "Theme", 0, {""} }, // fill this in on ImportOptions() + { "Note Skin", 0, {""} }, // fill this in on ImportOptions() }; ScreenAppearanceOptions::ScreenAppearanceOptions() : @@ -57,7 +60,9 @@ ScreenAppearanceOptions::ScreenAppearanceOptions() : void ScreenAppearanceOptions::ImportOptions() { + // // fill in announcer names + // CStringArray arrayAnnouncerNames; ANNOUNCER->GetAnnouncerNames( arrayAnnouncerNames ); @@ -71,7 +76,7 @@ void ScreenAppearanceOptions::ImportOptions() m_iSelectedOption[0][AO_ANNOUNCER] = -1; for( i=1; iGetCurrentAnnouncerName())==0 ) + if( 0==stricmp(m_OptionLineData[AO_ANNOUNCER].szOptionsText[i], ANNOUNCER->GetCurAnnouncerName()) ) { m_iSelectedOption[0][AO_ANNOUNCER] = i; break; @@ -81,9 +86,37 @@ void ScreenAppearanceOptions::ImportOptions() m_iSelectedOption[0][AO_ANNOUNCER] = 0; + // + // fill in theme names + // + CStringArray arrayThemeNames; + THEME->GetThemeNames( arrayThemeNames ); + + m_OptionLineData[AO_THEME].iNumOptions = arrayThemeNames.GetSize() + 1; + + for( i=0; iGetCurThemeName()) ) + { + m_iSelectedOption[0][AO_THEME] = i; + break; + } + } + if( m_iSelectedOption[0][AO_THEME] == -1 ) + m_iSelectedOption[0][AO_THEME] = 0; + + + // // fill in skin names + // CStringArray arraySkinNames; - GAMEMAN->GetSkinNames( arraySkinNames ); + GAMEMAN->GetNoteSkinNames( arraySkinNames ); m_OptionLineData[AO_SKIN].iNumOptions = arraySkinNames.GetSize(); @@ -94,7 +127,7 @@ void ScreenAppearanceOptions::ImportOptions() m_iSelectedOption[0][AO_SKIN] = -1; for( i=0; im_sCurrentSkin)==0 ) + if( 0==stricmp(m_OptionLineData[AO_SKIN].szOptionsText[i], GAMEMAN->GetCurNoteSkin()) ) { m_iSelectedOption[0][AO_SKIN] = i; break; @@ -110,26 +143,26 @@ void ScreenAppearanceOptions::ExportOptions() CString sNewAnnouncer = m_OptionLineData[AO_ANNOUNCER].szOptionsText[iSelectedAnnouncer]; if( iSelectedAnnouncer == 0 ) sNewAnnouncer = ""; - PREFSMAN->m_sAnnouncer = sNewAnnouncer; ANNOUNCER->SwitchAnnouncer( sNewAnnouncer ); + int iSelectedTheme = m_iSelectedOption[0][AO_THEME]; + CString sNewTheme = m_OptionLineData[AO_THEME].szOptionsText[iSelectedTheme]; + THEME->SwitchTheme( sNewTheme ); + int iSelectedSkin = m_iSelectedOption[0][AO_SKIN]; CString sNewSkin = m_OptionLineData[AO_SKIN].szOptionsText[iSelectedSkin]; - PREFSMAN->m_sNoteSkin = sNewSkin; - GAMEMAN->m_sCurrentSkin = sNewSkin; + GAMEMAN->SwitchNoteSkin( sNewSkin ); } void ScreenAppearanceOptions::GoToPrevState() { - SCREENMAN->SetNewScreen( new ScreenTitleMenu ); - PREFSMAN->SavePrefsToDisk(); - + GoToNextState(); } void ScreenAppearanceOptions::GoToNextState() { SCREENMAN->SetNewScreen( new ScreenTitleMenu ); - PREFSMAN->SavePrefsToDisk(); + PREFSMAN->SaveGlobalPrefsToDisk(); } diff --git a/stepmania/src/ScreenCaution.cpp b/stepmania/src/ScreenCaution.cpp index 1ddaacc397..8a4a72414d 100644 --- a/stepmania/src/ScreenCaution.cpp +++ b/stepmania/src/ScreenCaution.cpp @@ -14,7 +14,7 @@ Desc: Screen that displays while resources are being loaded. #include "GameConstantsAndTypes.h" #include "ScreenSelectStyle.h" #include "RageTextureManager.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "AnnouncerManager.h" @@ -27,10 +27,10 @@ ScreenCaution::ScreenCaution() { m_sprCaution.Load( THEME->GetPathTo(GRAPHIC_CAUTION) ); m_sprCaution.StretchTo( CRect(0,0,640,480) ); - this->AddActor( &m_sprCaution ); + this->AddSubActor( &m_sprCaution ); m_Wipe.OpenWipingRight( SM_DoneOpening ); - this->AddActor( &m_Wipe ); + this->AddSubActor( &m_Wipe ); this->SendScreenMessage( SM_StartClosing, 3 ); } diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 448193dd66..dcdb039f18 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -17,11 +17,13 @@ #include "ScreenSelectMusic.h" #include "ScreenEvaluation.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "GameManager.h" #include "ScreenEditMenu.h" #include "GameConstantsAndTypes.h" #include "RageLog.h" +#include "GameState.h" +#include "GameState.h" // @@ -87,9 +89,9 @@ ScreenEdit::ScreenEdit() { LOG->WriteLine( "ScreenEdit::ScreenEdit()" ); - m_pSong = SONGMAN->GetCurrentSong(); + m_pSong = GAMESTATE->m_pCurSong; - m_pNotes = SONGMAN->m_pCurNotes[PLAYER_1]; + m_pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; if( m_pNotes == NULL ) { m_pNotes = new Notes; @@ -107,7 +109,7 @@ ScreenEdit::ScreenEdit() // GAMEMAN->m_CurStyle is set to the target game style // of the current edit. Naturally, this is where we'll // want to extract the NotesType for a (NEW) sequence. - m_pNotes->m_NotesType = StyleToNotesType( GAMEMAN->m_CurStyle ); + m_pNotes->m_NotesType = GAMESTATE->GetCurrentStyleDef()->m_NotesType; m_pSong->m_apNotes.Add( m_pNotes ); } @@ -134,27 +136,27 @@ ScreenEdit::ScreenEdit() m_GranularityIndicator.SetZoom( 0.5f ); m_GrayArrowRowEdit.SetXY( EDIT_X, EDIT_GRAY_Y ); - m_GrayArrowRowEdit.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions ); + m_GrayArrowRowEdit.Load( PLAYER_1, GAMESTATE->GetCurrentStyleDef(), m_PlayerOptions ); m_GrayArrowRowEdit.SetZoom( 0.5f ); m_NoteFieldEdit.SetXY( EDIT_X, EDIT_GRAY_Y ); m_NoteFieldEdit.SetZoom( 0.5f ); - m_NoteFieldEdit.Load( ¬eData, PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions, 10, 12, NoteField::MODE_EDITING ); + m_NoteFieldEdit.Load( ¬eData, PLAYER_1, GAMESTATE->GetCurrentStyleDef(), m_PlayerOptions, 10, 12, NoteField::MODE_EDITING ); m_rectRecordBack.StretchTo( CRect(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) ); m_rectRecordBack.SetDiffuseColor( D3DXCOLOR(0,0,0,0) ); m_GrayArrowRowRecord.SetXY( EDIT_X, EDIT_GRAY_Y ); - m_GrayArrowRowRecord.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions ); + m_GrayArrowRowRecord.Load( PLAYER_1, GAMESTATE->GetCurrentStyleDef(), m_PlayerOptions ); m_GrayArrowRowRecord.SetZoom( 1.0f ); m_NoteFieldRecord.SetXY( EDIT_X, EDIT_GRAY_Y ); m_NoteFieldRecord.SetZoom( 1.0f ); - m_NoteFieldRecord.Load( ¬eData, PLAYER_1, GAMEMAN->GetCurrentStyleDef(), m_PlayerOptions, 2, 5, NoteField::MODE_EDITING ); + m_NoteFieldRecord.Load( ¬eData, PLAYER_1, GAMESTATE->GetCurrentStyleDef(), m_PlayerOptions, 2, 5, NoteField::MODE_EDITING ); m_Clipboard.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks; - m_Player.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), ¬eData, PlayerOptions(), NULL, NULL, 1, 1 ); + m_Player.Load( PLAYER_1, GAMESTATE->GetCurrentStyleDef(), ¬eData, PlayerOptions(), NULL, NULL, 1, 1 ); m_Player.SetXY( PLAYER_X, PLAYER_Y ); m_Fade.SetClosed(); @@ -314,7 +316,7 @@ void ScreenEdit::Update( float fDeltaTime ) m_fBeat, m_NoteFieldEdit.m_fBeginMarker, m_NoteFieldEdit.m_fEndMarker, DifficultyClassToString( m_pNotes->m_DifficultyClass ), - SONGMAN->GetCurrentNotes(PLAYER_1) ? SONGMAN->GetCurrentNotes(PLAYER_1)->m_sDescription : "no description", + GAMESTATE->m_pCurNotes[PLAYER_1] ? GAMESTATE->m_pCurNotes[PLAYER_1]->m_sDescription : "no description", iNumTapNotes, iNumHoldNotes, m_pSong->m_fBeat0OffsetInSeconds, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds @@ -423,21 +425,21 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ case DIK_S: { // copy edit into current Notes - Song* pSong = SONGMAN->GetCurrentSong(); - Notes* pNotes = SONGMAN->GetCurrentNotes(PLAYER_1); + Song* pSong = GAMESTATE->m_pCurSong; + Notes* pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; if( pNotes == NULL ) { // allocate a new Notes pNotes = new Notes; pSong->m_apNotes.Add( pNotes ); - pNotes->m_NotesType = GAMEMAN->m_CurNotesType; + pNotes->m_NotesType = GAMEMAN->GetStyleDefForStyle( GAMESTATE->m_CurStyle )->m_NotesType; pNotes->m_sDescription = "Untitled"; pNotes->m_iMeter = 1; } pNotes->SetNoteData( (NoteData*)&m_NoteFieldEdit ); - SONGMAN->GetCurrentSong()->SaveToSMFile(); + GAMESTATE->m_pCurSong->SaveToSMFile(); } break; case DIK_UP: @@ -567,7 +569,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_Mode = MODE_PLAY; - m_Player.Load( PLAYER_1, GAMEMAN->GetCurrentStyleDef(), (NoteData*)&m_NoteFieldEdit, PlayerOptions(), NULL, NULL, 1, 1 ); + m_Player.Load( PLAYER_1, GAMESTATE->GetCurrentStyleDef(), (NoteData*)&m_NoteFieldEdit, PlayerOptions(), NULL, NULL, 1, 1 ); m_rectRecordBack.BeginTweening( 0.5f ); m_rectRecordBack.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,0.5f) ); @@ -882,7 +884,7 @@ void ScreenEdit::InputPlay( const DeviceInput& DeviceI, const InputEventType typ float fSongBeat, fBPS; bool bFreeze; m_pSong->GetBeatAndBPSFromElapsedTime( m_soundMusic.GetPositionSeconds(), fSongBeat, fBPS, bFreeze ); - const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow / PREFSMAN->m_SongOptions.m_fMusicRate; + const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow / GAMESTATE->m_SongOptions.m_fMusicRate; switch( StyleI.player ) { diff --git a/stepmania/src/ScreenEditMenu.cpp b/stepmania/src/ScreenEditMenu.cpp index f462a902f9..bafecf68dc 100644 --- a/stepmania/src/ScreenEditMenu.cpp +++ b/stepmania/src/ScreenEditMenu.cpp @@ -16,10 +16,11 @@ #include "ScreenEdit.h" #include "GameConstantsAndTypes.h" #include "RageUtil.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "GameManager.h" #include "ScreenPrompt.h" #include "RageLog.h" +#include "GameState.h" // @@ -70,33 +71,33 @@ ScreenEditMenu::ScreenEditMenu() m_textGroup.Load( THEME->GetPathTo(FONT_HEADER1) ); m_textGroup.SetXY( GROUP_X, GROUP_Y ); m_textGroup.SetDiffuseColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) ); - this->AddActor( &m_textGroup ); + this->AddSubActor( &m_textGroup ); m_Banner.SetXY( SONG_BANNER_X, SONG_BANNER_Y ); - this->AddActor( &m_Banner ); + this->AddSubActor( &m_Banner ); m_TextBanner.SetXY( SONG_TEXT_BANNER_X, SONG_TEXT_BANNER_Y ); - this->AddActor( &m_TextBanner ); + this->AddSubActor( &m_TextBanner ); m_sprArrowLeft.Load( THEME->GetPathTo(GRAPHIC_ARROWS_LEFT) ); m_sprArrowLeft.SetXY( ARROWS_X[0], ARROWS_Y[0] ); m_sprArrowLeft.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); - this->AddActor( &m_sprArrowLeft ); + this->AddSubActor( &m_sprArrowLeft ); m_sprArrowRight.Load( THEME->GetPathTo(GRAPHIC_ARROWS_RIGHT) ); m_sprArrowRight.SetXY( ARROWS_X[1], ARROWS_Y[1] ); m_sprArrowRight.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); - this->AddActor( &m_sprArrowRight ); + this->AddSubActor( &m_sprArrowRight ); m_textNotesType.Load( THEME->GetPathTo(FONT_HEADER1) ); m_textNotesType.SetXY( GAME_STYLE_X, GAME_STYLE_Y ); m_textNotesType.SetDiffuseColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) ); - this->AddActor( &m_textNotesType ); + this->AddSubActor( &m_textNotesType ); m_textNotes.Load( THEME->GetPathTo(FONT_HEADER1) ); m_textNotes.SetXY( STEPS_X, STEPS_Y ); m_textNotes.SetDiffuseColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) ); - this->AddActor( &m_textNotes ); + this->AddSubActor( &m_textNotes ); AfterRowChange(); @@ -107,7 +108,7 @@ ScreenEditMenu::ScreenEditMenu() m_textExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y ); m_textExplanation.SetText( EXPLANATION_TEXT ); m_textExplanation.SetZoom( 0.7f ); - this->AddActor( &m_textExplanation ); + this->AddSubActor( &m_textExplanation ); m_Menu.Load( THEME->GetPathTo(GRAPHIC_EDIT_BACKGROUND), @@ -115,11 +116,11 @@ ScreenEditMenu::ScreenEditMenu() ssprintf("%s %s change music START to continue", CString(char(1)), CString(char(2)) ), false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_Fade.SetOpened(); - this->AddActor( &m_Fade); + this->AddSubActor( &m_Fade); m_soundChangeMusic.Load( THEME->GetPathTo(SOUND_SELECT_MUSIC_CHANGE_MUSIC) ); @@ -163,20 +164,16 @@ void ScreenEditMenu::HandleScreenMessage( const ScreenMessage SM ) case SM_GoToNextState: // set the current style based on the notes type - //switch( GetSelectedNotesType() ) - //{ - //case NOTES_TYPE_DANCE_SINGLE: GAMEMAN->m_CurStyle = STYLE_DANCE_SINGLE; break; - //case NOTES_TYPE_DANCE_DOUBLE: GAMEMAN->m_CurStyle = STYLE_DANCE_DOUBLE; break; - //case NOTES_TYPE_DANCE_COUPLE: GAMEMAN->m_CurStyle = STYLE_DANCE_COUPLE; break; - //case NOTES_TYPE_DANCE_SOLO: GAMEMAN->m_CurStyle = STYLE_DANCE_SOLO; break; - //case NOTES_TYPE_PUMP_SINGLE: GAMEMAN->m_CurStyle = STYLE_PUMP_SINGLE; break; - //case NOTES_TYPE_PUMP_DOUBLE: GAMEMAN->m_CurStyle = STYLE_PUMP_DOUBLE; break; - //} - // Dro Kulix: // A centralized solution for this switching mess... // (See GameConstantsAndTypes.h) - GAMEMAN->m_CurStyle = NotesTypeToStyle( GetSelectedNotesType() ); + // + // Chris: + // Find the first Style that will play the selected notes type. + // Set the current Style, then let ScreenEdit infer the desired + // NotesType from that Style. + NotesType nt = GetSelectedNotesType(); + GAMESTATE->m_CurStyle = GAMEMAN->GetStyleThatPlaysNotesType( nt ); SCREENMAN->SetNewScreen( new ScreenEdit ); break; @@ -349,9 +346,12 @@ void ScreenEditMenu::MenuStart( const PlayerNumber p ) MUSIC->Stop(); - SONGMAN->SetCurrentSong( GetSelectedSong() ); - GAMEMAN->m_CurNotesType = GetSelectedNotesType(); - SONGMAN->SetCurrentNotes( PLAYER_1, GetSelectedNotes() ); + GAMESTATE->m_pCurSong = GetSelectedSong(); + + // find the first style that matches this notes type + GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); + GAMESTATE->m_CurStyle = GAMEMAN->GetStyleThatPlaysNotesType( GetSelectedNotesType() ); + GAMESTATE->m_pCurNotes[PLAYER_1] = GetSelectedNotes(); m_soundSelect.PlayRandom(); diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 28293342a5..9b236e922a 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -18,10 +18,11 @@ #include "RageUtil.h" #include "GameConstantsAndTypes.h" #include "Notes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" #include "AnnouncerManager.h" #include "ScreenMusicScroll.h" +#include "GameState.h" const float BANNER_X = CENTER_X; @@ -66,7 +67,7 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) /////////////////////////// // Set m_ResultMode. This enum will make our life easier later when we init different pieces depending on context. /////////////////////////// - switch( PREFSMAN->m_PlayMode ) + switch( GAMESTATE->m_PlayMode ) { case PLAY_MODE_ARCADE: m_ResultMode = bSummary ? RM_ARCADE_SUMMARY : RM_ARCADE_STAGE; @@ -83,78 +84,103 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) /////////////////////////// // Calculate total statistics depending on m_ResultMode /////////////////////////// - GameplayStatistics total_statistics[NUM_PLAYERS]; - for( p=0; pIsPlayerEnabled(pn) ) - continue; // skip - - switch( m_ResultMode ) + case RM_ARCADE_STAGE: { - case RM_ARCADE_STAGE: - total_statistics[p] = SONGMAN->GetLatestGameplayStatistics((PlayerNumber)p); - break; - case RM_ARCADE_SUMMARY: + // take the latest GameplayStatistics + totalGS = GAMESTATE->m_aGameplayStatistics[GAMESTATE->m_aGameplayStatistics.GetSize()-1]; + } + break; + case RM_ARCADE_SUMMARY: + case RM_ONI: + { + int iFirstToTakeFrom; + switch( m_ResultMode ) { - int iStageIndex = PREFSMAN->GetStageIndex(); - int s = 0; - for( int i=max(0,iStageIndex-STAGES_TO_SHOW_IN_SUMMARY); i<=iStageIndex; i++, s++ ) + case RM_ARCADE_SUMMARY: + iFirstToTakeFrom = max( 0, GAMESTATE->m_aGameplayStatistics.GetSize()-STAGES_TO_SHOW_IN_SUMMARY ); + break; + case RM_ONI: + iFirstToTakeFrom = 0; + break; + default: + ASSERT(0); + } + + for( int i=iFirstToTakeFrom; im_aGameplayStatistics.GetSize(); i++ ) + totalGS += GAMESTATE->m_aGameplayStatistics[i]; + + // Chris: + // ugly... GameplayStatistics::operator+= simply sums the radar values, so we need + // to divide by the number of stages taken from to normalize the values. + int iNumTakenFrom = GAMESTATE->m_aGameplayStatistics.GetSize() - iFirstToTakeFrom; + + for( int p=0; pGetLatestGameplayStatistics((PlayerNumber)p); + totalGS.fRadarActual[p][r] /= iNumTakenFrom; + totalGS.fRadarPossible[p][r] /= iNumTakenFrom; } } - break; - case RM_ONI: - { - int iStageIndex = PREFSMAN->GetStageIndex(); - int s = 0; - for( int i=0; i<=iStageIndex; i++ ) - total_statistics[p] = SONGMAN->GetLatestGameplayStatistics((PlayerNumber)p); - } - break; + } + break; + } + + // Andy: + // Fake COOL! / GOOD / OOPS for Ez2dancer using the DDR Rankings. + if( GAMESTATE->GetCurGame() == GAME_EZ2 ) + { + for( int p=0; pm_CurGame != GAME_EZ2 ) + /////////////////////////// + // Init the song banners depending on m_ResultMode + /////////////////////////// + if( GAMESTATE->GetCurGame() != GAME_EZ2 ) { - /////////////////////////// - // Init the song banners depending on m_ResultMode - /////////////////////////// switch( m_ResultMode ) { case RM_ARCADE_STAGE: - m_BannerWithFrame[0].LoadFromSong( SONGMAN->GetCurrentSong() ); + m_BannerWithFrame[0].LoadFromSong( GAMESTATE->m_pCurSong ); m_BannerWithFrame[0].SetXY( BANNER_X, BANNER_Y ); - this->AddActor( &m_BannerWithFrame[0] ); + this->AddSubActor( &m_BannerWithFrame[0] ); break; case RM_ARCADE_SUMMARY: { // crop down to 3 for( int p=0; pm_aGameplayStatistics[p].GetSize() > STAGES_TO_SHOW_IN_SUMMARY ) - SONGMAN->m_aGameplayStatistics[p].RemoveAt( 0, SONGMAN->m_aGameplayStatistics[p].GetSize() - STAGES_TO_SHOW_IN_SUMMARY ); + { + if( GAMESTATE->m_aGameplayStatistics.GetSize() > STAGES_TO_SHOW_IN_SUMMARY ) + GAMESTATE->m_aGameplayStatistics.RemoveAt( 0, GAMESTATE->m_aGameplayStatistics.GetSize() - STAGES_TO_SHOW_IN_SUMMARY ); + } - const int iSongsToShow = SONGMAN->m_aGameplayStatistics[0].GetSize(); + const int iSongsToShow = GAMESTATE->m_aGameplayStatistics.GetSize(); ASSERT( iSongsToShow > 0 ); for( int i=0; im_aGameplayStatistics[0][i]; + GameplayStatistics &GS = GAMESTATE->m_aGameplayStatistics[i]; m_BannerWithFrame[i].LoadFromSong( GS.pSong ); float fBannerOffset = i - (iSongsToShow-1)/2.0f; m_BannerWithFrame[i].SetXY( BANNER_X + fBannerOffset*32, BANNER_Y + fBannerOffset*16 ); m_BannerWithFrame[i].SetZoom( 0.70f ); - this->AddActor( &m_BannerWithFrame[i] ); + this->AddSubActor( &m_BannerWithFrame[i] ); } } break; case RM_ONI: - m_BannerWithFrame[0].LoadFromGroup( SONGMAN->m_sPreferredGroup ); + m_BannerWithFrame[0].LoadFromGroup( GAMESTATE->m_sPreferredGroup ); m_BannerWithFrame[0].SetXY( BANNER_X, BANNER_Y ); - this->AddActor( &m_BannerWithFrame[0] ); + this->AddSubActor( &m_BannerWithFrame[0] ); break; } } @@ -170,19 +196,19 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) "Press START to continue.", false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); for( l=0; lm_CurGame != GAME_EZ2) + if (GAMESTATE->GetCurGame() != GAME_EZ2) { m_sprJudgeLabels[l].Load( THEME->GetPathTo(GRAPHIC_EVALUATION_JUDGE_LABELS) ); m_sprJudgeLabels[l].StopAnimating(); m_sprJudgeLabels[l].SetState( l ); m_sprJudgeLabels[l].SetXY( JUDGE_LABELS_X, JUDGE_START_Y + l*JUDGE_SPACING ); m_sprJudgeLabels[l].SetZoom( 1.0f ); - this->AddActor( &m_sprJudgeLabels[l] ); + this->AddSubActor( &m_sprJudgeLabels[l] ); } for( int p=0; pm_CurGame == GAME_EZ2) // Change Position For Ez2dancer + if (l == 0 && GAMESTATE->GetCurGame() == GAME_EZ2) // Change Position For Ez2dancer { m_textJudgeNumbers[l][p].SetXY( JUDGE_NUMBERS_X_EZ2[p], JUDGE_EZ2_COOL_Y); } - else if (l == 2 && GAMEMAN->m_CurGame == GAME_EZ2) + else if (l == 2 && GAMESTATE->GetCurGame() == GAME_EZ2) { m_textJudgeNumbers[l][p].SetXY( JUDGE_NUMBERS_X_EZ2[p], JUDGE_EZ2_COOL_Y + 55); } - else if (l == 4 && GAMEMAN->m_CurGame == GAME_EZ2) + else if (l == 4 && GAMESTATE->GetCurGame() == GAME_EZ2) { m_textJudgeNumbers[l][p].SetXY( JUDGE_NUMBERS_X_EZ2[p], JUDGE_EZ2_COOL_Y + 120); } - else if ((l == 1 || l == 3 ) && GAMEMAN->m_CurGame == GAME_EZ2) + else if ((l == 1 || l == 3 ) && GAMESTATE->GetCurGame() == GAME_EZ2) { m_textJudgeNumbers[l][p].SetZoomX(0); // Hide These Ones } - else if (l == 5 && GAMEMAN->m_CurGame == GAME_EZ2 ) // sneakily use this one for the max combo. + else if (l == 5 && GAMESTATE->GetCurGame() == GAME_EZ2 ) // sneakily use this one for the max combo. { if (p == PLAYER_1 ) { @@ -224,117 +250,75 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) } } - this->AddActor( &m_textJudgeNumbers[l][p] ); + this->AddSubActor( &m_textJudgeNumbers[l][p] ); } } - if (GAMEMAN->m_CurGame != GAME_EZ2) + if (GAMESTATE->GetCurGame() != GAME_EZ2) { m_sprScoreLabel.Load( THEME->GetPathTo(GRAPHIC_EVALUATION_SCORE_LABELS) ); m_sprScoreLabel.StopAnimating(); m_sprScoreLabel.SetXY( SCORE_LABEL_X, SCORE_Y ); m_sprScoreLabel.SetZoom( 1.0f ); - this->AddActor( &m_sprScoreLabel ); + this->AddSubActor( &m_sprScoreLabel ); } for( p=0; pIsPlayerEnabled( (PlayerNumber)p ) || GAMEMAN->m_CurGame == GAME_EZ2 ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) || GAMESTATE->GetCurGame() == GAME_EZ2 ) continue; // skip m_ScoreDisplay[p].SetXY( SCORE_DISPLAY_X[p], SCORE_Y ); m_ScoreDisplay[p].SetZoomY( 0.9f ); m_ScoreDisplay[p].SetDiffuseColor( PlayerToColor(p) ); - this->AddActor( &m_ScoreDisplay[p] ); + this->AddSubActor( &m_ScoreDisplay[p] ); } + // + // Calculate grades + // Grade grade[NUM_PLAYERS]; + Grade max_grade = GRADE_NO_DATA; + for( p=0; pIsPlayerEnabled(pn) ? GRADE_NO_DATA : totalGS.GetGrade(pn); + max_grade = max( max_grade, grade[p] ); + } + ////////////////////////// // Set Numbers ////////////////////////// for( p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - GameplayStatistics GS[NUM_PLAYERS]; // fill this in depending on m_ResultMode - - switch( m_ResultMode ) - { - case RM_ARCADE_STAGE: - { - GS[p] = SONGMAN->m_aGameplayStatistics[p][SONGMAN->m_aGameplayStatistics[p].GetSize()-1]; - } - break; - case RM_ARCADE_SUMMARY: - case RM_ONI: - { - const int iSongsToShow = SONGMAN->m_aGameplayStatistics[0].GetSize(); - ASSERT( iSongsToShow > 0 ); + m_textJudgeNumbers[0][p].SetText( ssprintf("%4d", totalGS.perfect[p]) ); + m_textJudgeNumbers[1][p].SetText( ssprintf("%4d", totalGS.great[p]) ); + m_textJudgeNumbers[2][p].SetText( ssprintf("%4d", totalGS.good[p]) ); + m_textJudgeNumbers[3][p].SetText( ssprintf("%4d", totalGS.boo[p]) ); + m_textJudgeNumbers[4][p].SetText( ssprintf("%4d", totalGS.miss[p]) ); + m_textJudgeNumbers[5][p].SetText( ssprintf("%4d", totalGS.ok[p]) ); - for( int i=0; im_aGameplayStatistics[p][i]; - - GS[p].iPossibleDancePoints += GSstage.iPossibleDancePoints; - GS[p].iActualDancePoints += GSstage.iActualDancePoints; - - GS[p].perfect += GSstage.perfect; - GS[p].great += GSstage.great; - GS[p].good += GSstage.good; - GS[p].boo += GSstage.boo; - GS[p].miss += GSstage.miss; - GS[p].ok += GSstage.ok; - GS[p].ng += GSstage.ng; - GS[p].max_combo = max( GS[p].max_combo, GSstage.max_combo ); - GS[p].score += GSstage.score; - - for( int i=0; im_CurGame == GAME_EZ2) // Fake COOL! / GOOD / OOPS for Ez2dancer using the DDR Rankings. - { - GS[p].perfect += GS[p].great; - GS[p].great = 0; - GS[p].miss += GS[p].boo; - GS[p].boo = 0; - } - grade[p] = GS[p].GetGrade(); - - m_textJudgeNumbers[0][p].SetText( ssprintf("%4d", GS[p].perfect) ); - m_textJudgeNumbers[1][p].SetText( ssprintf("%4d", GS[p].great) ); - m_textJudgeNumbers[2][p].SetText( ssprintf("%4d", GS[p].good) ); - m_textJudgeNumbers[3][p].SetText( ssprintf("%4d", GS[p].boo) ); - m_textJudgeNumbers[4][p].SetText( ssprintf("%4d", GS[p].miss) ); - m_textJudgeNumbers[5][p].SetText( ssprintf("%4d", GS[p].ok) ); + m_ScoreDisplay[p].SetScore( (float)totalGS.max_combo[p] * 1000 ); + m_ScoreDisplay[p].SetScore( (float)totalGS.score[p] ); // SNEAKY! We take the max combo, and put it into element 5, because Ez2dancer // doesn't care for OK's and plus this text element is already nicely aligned =) - if (GAMEMAN->m_CurGame == GAME_EZ2) + if (GAMESTATE->GetCurGame() == GAME_EZ2) { - m_textJudgeNumbers[5][p].SetText( ssprintf("%4d", GS[p].max_combo) ); + m_textJudgeNumbers[5][p].SetText( ssprintf("%4d", totalGS.max_combo[p]) ); } - m_ScoreDisplay[p].SetScore( (float)GS[p].max_combo * 1000 ); - m_ScoreDisplay[p].SetScore( (float)GS[p].score ); + m_ScoreDisplay[p].SetScore( (float)totalGS.max_combo[p] * 1000 ); + m_ScoreDisplay[p].SetScore( (float)totalGS.score[p] ); - m_BonusInfoFrame[p].SetBonusInfo( (PlayerNumber)p, GS[p].fRadarPossible, GS[p].fRadarActual, GS[p].max_combo ); + + m_BonusInfoFrame[p].SetBonusInfo( (PlayerNumber)p, totalGS.fRadarPossible[p], totalGS.fRadarActual[p], totalGS.max_combo[p] ); switch( m_ResultMode ) { @@ -343,15 +327,15 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) // update song stats //////////////////////// - Notes* pNotes = SONGMAN->GetCurrentNotes((PlayerNumber)p); + Notes* pNotes = GAMESTATE->m_pCurNotes[p]; pNotes->m_iNumTimesPlayed++; - if( GS[p].max_combo > pNotes->m_iMaxCombo ) - pNotes->m_iMaxCombo = GS[p].max_combo; + if( totalGS.max_combo[p] > pNotes->m_iMaxCombo ) + pNotes->m_iMaxCombo = totalGS.max_combo[p]; - if( GS[p].score > pNotes->m_iTopScore ) + if( totalGS.score[p] > pNotes->m_iTopScore ) { - pNotes->m_iTopScore = (int)GS[p].score; + pNotes->m_iTopScore = (int)totalGS.score[p]; m_bNewRecord[p] = true; } @@ -363,20 +347,16 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) - Grade max_grade = GRADE_NO_DATA; - for( p=0; pIsFinalStage() || PREFSMAN->IsExtraStage()) && m_ResultMode==RM_ARCADE_STAGE ) + if( (GAMESTATE->IsFinalStage() || GAMESTATE->IsExtraStage()) && m_ResultMode==RM_ARCADE_STAGE ) { for( p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - if( SONGMAN->GetCurrentNotes((PlayerNumber)p)->m_DifficultyClass == CLASS_HARD && grade[p] >= GRADE_AA ) + if( GAMESTATE->m_pCurNotes[p]->m_DifficultyClass == CLASS_HARD && grade[p] >= GRADE_AA ) m_bTryExtraStage = true; } } @@ -387,32 +367,41 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) for( p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - if ( GAMEMAN->m_CurGame != GAME_EZ2) + + if ( GAMESTATE->GetCurGame() != GAME_EZ2) { m_sprGradeFrame[p].Load( THEME->GetPathTo(GRAPHIC_EVALUATION_GRADE_FRAME) ); m_sprGradeFrame[p].StopAnimating(); m_sprGradeFrame[p].SetState( p ); m_sprGradeFrame[p].SetXY( GRADE_X[p], GRADE_Y ); - this->AddActor( &m_sprGradeFrame[p] ); + this->AddSubActor( &m_sprGradeFrame[p] ); } switch( m_ResultMode ) { case RM_ONI: - m_textOniPercent[p].Load( THEME->GetPathTo(FONT_HEADER1) ); - m_textOniPercent[p].SetXY( GRADE_X[p], GRADE_Y ); - m_textOniPercent[p].SetShadowLength( 2 ); - m_textOniPercent[p].SetZoomX( 1.5f ); - m_textOniPercent[p].SetZoomY( 3 ); - m_textOniPercent[p].SetEffectGlowing( 1.0f ); - m_textOniPercent[p].SetText( "100.0%" ); - this->AddActor( &m_textOniPercent[p] ); + { + m_textOniPercent[p].Load( THEME->GetPathTo(FONT_HEADER1) ); + m_textOniPercent[p].SetXY( GRADE_X[p], GRADE_Y ); + m_textOniPercent[p].SetShadowLength( 2 ); + m_textOniPercent[p].SetZoomX( 1.3f ); + m_textOniPercent[p].SetZoomY( 2.5f ); + m_textOniPercent[p].SetEffectGlowing( 1.0f ); + + int iActualDancePoints = 0; + for( int i=0; im_aGameplayStatistics.GetSize(); i++ ) + iActualDancePoints += GAMESTATE->m_aGameplayStatistics[i].iActualDancePoints[p]; + int iPossibleDancePoints = GAMESTATE->m_iCoursePossibleDancePoints; + float fPercentDancePoints = iActualDancePoints / (float)iPossibleDancePoints + 0.0001f; // correct for rounding errors + m_textOniPercent[p].SetText( ssprintf("%.1f%%", fPercentDancePoints*100) ); + this->AddSubActor( &m_textOniPercent[p] ); + } break; case RM_ARCADE_STAGE: case RM_ARCADE_SUMMARY: - if (GAMEMAN->m_CurGame != GAME_EZ2 ) + if (GAMESTATE->GetCurGame() != GAME_EZ2 ) { m_Grades[p].SetXY( GRADE_X[p], GRADE_Y ); m_Grades[p].SetZ( -2 ); @@ -437,15 +426,15 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) m_Grades[p].SetTweenZoom( 2 ); } - this->AddActor( &m_Grades[p] ); + this->AddSubActor( &m_Grades[p] ); break; } - if ( GAMEMAN->m_CurGame == GAME_EZ2) + if ( GAMESTATE->GetCurGame() == GAME_EZ2) continue; m_BonusInfoFrame[p].SetXY( BONUS_FRAME_X[p], BONUS_FRAME_Y ); - this->AddActor( &m_BonusInfoFrame[p] ); + this->AddSubActor( &m_BonusInfoFrame[p] ); m_bNewRecord[p] = false; @@ -457,7 +446,7 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) m_textNewRecord[p].SetText( "IT'S A NEW RECORD!" ); m_textNewRecord[p].SetZoom( 0.5f ); m_textNewRecord[p].SetEffectGlowing( 1.0f ); - this->AddActor( &m_textNewRecord[p] ); + this->AddSubActor( &m_textNewRecord[p] ); } } @@ -466,36 +455,61 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) { m_textTryExtraStage.Load( THEME->GetPathTo(FONT_HEADER1) ); m_textTryExtraStage.SetXY( TRY_EXTRA_STAGE_X, TRY_EXTRA_STAGE_Y ); - if( PREFSMAN->IsExtraStage() ) + if( GAMESTATE->IsExtraStage() ) m_textTryExtraStage.SetText( "Try Another Extra Stage!" ); else m_textTryExtraStage.SetText( "Try Extra Stage!" ); m_textTryExtraStage.SetZoom( 1 ); m_textTryExtraStage.SetEffectGlowing( 1.0f ); - this->AddActor( &m_textTryExtraStage ); + this->AddSubActor( &m_textTryExtraStage ); SOUND->PlayOnceStreamed( THEME->GetPathTo(SOUND_EVALUATION_EXTRA_STAGE) ); } else { - switch( max_grade ) + switch( m_ResultMode ) { - case GRADE_D: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_D) ); break; - case GRADE_C: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_C) ); break; - case GRADE_B: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_B) ); break; - case GRADE_A: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_A) ); break; - case GRADE_AA: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_AA) ); break; - case GRADE_AAA: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_AAA) ); break; - case GRADE_NO_DATA: + case RM_ARCADE_STAGE: + switch( max_grade ) + { + case GRADE_E: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_E) ); break; + case GRADE_D: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_D) ); break; + case GRADE_C: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_C) ); break; + case GRADE_B: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_B) ); break; + case GRADE_A: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_A) ); break; + case GRADE_AA: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_AA) ); break; + case GRADE_AAA: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_AAA) ); break; + case GRADE_NO_DATA: + default: + ASSERT(0); // invalid grade + } + break; + case RM_ONI: + case RM_ARCADE_SUMMARY: + switch( max_grade ) + { + case GRADE_E: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_FINAL_E) ); break; + case GRADE_D: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_FINAL_D) ); break; + case GRADE_C: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_FINAL_C) ); break; + case GRADE_B: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_FINAL_B) ); break; + case GRADE_A: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_FINAL_A) ); break; + case GRADE_AA: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_FINAL_AA) ); break; + case GRADE_AAA: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_EVALUATION_FINAL_AAA) ); break; + case GRADE_NO_DATA: + default: + ASSERT(0); // invalid grade + } + break; default: - ASSERT(0); // invalid grade + ASSERT(0); } } m_Menu.TweenOnScreenFromBlack( SM_None ); } + void ScreenEvaluation::TweenOnScreen() { int i, p; @@ -515,7 +529,7 @@ void ScreenEvaluation::TweenOnScreen() for( i=0; im_CurGame != GAME_EZ2) + if (GAMESTATE->GetCurGame() != GAME_EZ2) { fOriginalY = m_sprJudgeLabels[i].GetY(); m_sprJudgeLabels[i].SetY( fOriginalY + SCREEN_HEIGHT ); @@ -534,7 +548,7 @@ void ScreenEvaluation::TweenOnScreen() } } - if (GAMEMAN->m_CurGame != GAME_EZ2) + if (GAMESTATE->GetCurGame() != GAME_EZ2) { fOriginalY = m_sprScoreLabel.GetY(); @@ -590,7 +604,7 @@ void ScreenEvaluation::TweenOffScreen() for( i=0; im_CurGame != GAME_EZ2) + if (GAMESTATE->GetCurGame() != GAME_EZ2) { m_sprJudgeLabels[i].BeginTweeningQueued( MENU_ELEMENTS_TWEEN_TIME, Actor::TWEEN_BIAS_END ); m_sprJudgeLabels[i].SetTweenZoomY( 0 ); @@ -603,7 +617,7 @@ void ScreenEvaluation::TweenOffScreen() } } - if (GAMEMAN->m_CurGame != GAME_EZ2) + if (GAMESTATE->GetCurGame() != GAME_EZ2) { m_sprScoreLabel.BeginTweeningQueued( MENU_ELEMENTS_TWEEN_TIME, Actor::TWEEN_BIAS_END ); m_sprScoreLabel.SetTweenZoomY( 0 ); @@ -690,7 +704,7 @@ void ScreenEvaluation::MenuStart( const PlayerNumber p ) if( PREFSMAN->m_bEventMode ) { - PREFSMAN->m_iCurrentStageIndex++; + GAMESTATE->m_iCurrentStageIndex++; m_Menu.TweenOffScreenToMenu( SM_GoToSelectMusic ); return; } @@ -703,19 +717,19 @@ void ScreenEvaluation::MenuStart( const PlayerNumber p ) case RM_ARCADE_STAGE: if( m_bTryExtraStage ) { - PREFSMAN->m_iCurrentStageIndex++; + GAMESTATE->m_iCurrentStageIndex++; m_Menu.TweenOffScreenToMenu( SM_GoToSelectMusic ); } else if( - PREFSMAN->m_iCurrentStageIndex == PREFSMAN->m_iNumArcadeStages-1 || - PREFSMAN->IsExtraStage() || - PREFSMAN->IsExtraStage2() ) + GAMESTATE->m_iCurrentStageIndex == PREFSMAN->m_iNumArcadeStages-1 || + GAMESTATE->IsExtraStage() || + GAMESTATE->IsExtraStage2() ) { m_Menu.TweenOffScreenToMenu( SM_GoToFinalEvaluation ); } else { - PREFSMAN->m_iCurrentStageIndex++; + GAMESTATE->m_iCurrentStageIndex++; m_Menu.TweenOffScreenToMenu( SM_GoToSelectMusic ); } diff --git a/stepmania/src/ScreenEvaluation.h b/stepmania/src/ScreenEvaluation.h index 92354d70fb..c1d80fb2f9 100644 --- a/stepmania/src/ScreenEvaluation.h +++ b/stepmania/src/ScreenEvaluation.h @@ -18,7 +18,7 @@ #include "GradeDisplay.h" #include "MenuElements.h" #include "Banner.h" -#include "ScoreDisplayRolling.h" +#include "ScoreDisplayNormal.h" #include "BonusInfoFrame.h" #include "BannerWithFrame.h" @@ -58,7 +58,7 @@ protected: BitmapText m_textJudgeNumbers[NUM_JUDGE_LINES][NUM_PLAYERS]; Sprite m_sprScoreLabel; - ScoreDisplayRolling m_ScoreDisplay[NUM_PLAYERS]; + ScoreDisplayNormal m_ScoreDisplay[NUM_PLAYERS]; bool m_bNewRecord[NUM_PLAYERS]; BitmapText m_textNewRecord[NUM_PLAYERS]; diff --git a/stepmania/src/ScreenEz2SelectPlayer.cpp b/stepmania/src/ScreenEz2SelectPlayer.cpp index 1dc4d49b3c..2d18844a79 100644 --- a/stepmania/src/ScreenEz2SelectPlayer.cpp +++ b/stepmania/src/ScreenEz2SelectPlayer.cpp @@ -15,13 +15,14 @@ Andrew Livy #include "ScreenTitleMenu.h" #include "ScreenCaution.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenSelectDifficulty.h" #include "ScreenSandbox.h" #include "GameManager.h" #include "RageLog.h" #include "AnnouncerManager.h" #include "ScreenEz2SelectStyle.h" +#include "GameState.h" /* Constants */ @@ -58,9 +59,9 @@ ScreenEz2SelectPlayer::ScreenEz2SelectPlayer() LOG->WriteLine( "ScreenEz2SelectPlayer::ScreenEz2SelectPlayer()" ); ez2_lasttimercheck[0] = TIMER->GetTimeSinceStart(); ez2_lasttimercheck[1] = 0.0f; - m_iSelectedStyle=3; // set to invalid style - GAMEMAN->m_CurStyle = STYLE_NONE; - GAMEMAN->m_sMasterPlayerNumber = PLAYER_INVALID; + m_iSelectedStyle=0; + GAMESTATE->m_CurStyle = STYLE_NONE; + GAMESTATE->m_MasterPlayerNumber = PLAYER_INVALID; // Load in the sprites we will be working with. for( int i=0; iAddActor( &m_sprOpt[i] ); + this->AddSubActor( &m_sprOpt[i] ); } @@ -94,7 +95,7 @@ ScreenEz2SelectPlayer::ScreenEz2SelectPlayer() ssprintf("Press %c on the pad you wish to play on", char(4) ), false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_soundChange.Load( THEME->GetPathTo(SOUND_SELECT_STYLE_CHANGE) ); m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) ); @@ -181,18 +182,18 @@ void ScreenEz2SelectPlayer::DrawPrimitives() if (m_iSelectedStyle == 0) // only the left pad was selected { - GAMEMAN->m_sMasterPlayerNumber = PLAYER_1; - GAMEMAN->m_CurStyle = STYLE_EZ2_SINGLE; + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; + GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; } else if (m_iSelectedStyle == 1) // only the right pad was selected { - GAMEMAN->m_sMasterPlayerNumber = PLAYER_2; - GAMEMAN->m_CurStyle = STYLE_EZ2_SINGLE; + GAMESTATE->m_MasterPlayerNumber = PLAYER_2; + GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; } else // they both selected { - GAMEMAN->m_sMasterPlayerNumber = PLAYER_1; - GAMEMAN->m_CurStyle = STYLE_EZ2_SINGLE_VERSUS; + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; + GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_VERSUS; } MUSIC->Stop(); @@ -287,9 +288,11 @@ void ScreenEz2SelectPlayer::MenuStart( PlayerNumber p ) } // figure out whether we should add a player into the fray or not -// if( GAMEMAN->m_sMasterPlayerNumber != PLAYER_2 && GAMEMAN->m_sMasterPlayerNumber != PLAYER_1 ) +// if( GAMESTATE->m_MasterPlayerNumber != PLAYER_2 && GAMESTATE->m_MasterPlayerNumber != PLAYER_1 ) if (m_iSelectedStyle == 3) { + GAMESTATE->m_MasterPlayerNumber = p; + if (p == PLAYER_1) { m_iSelectedStyle = 0; diff --git a/stepmania/src/ScreenEz2SelectStyle.cpp b/stepmania/src/ScreenEz2SelectStyle.cpp index cb45a66644..31794fd4c0 100644 --- a/stepmania/src/ScreenEz2SelectStyle.cpp +++ b/stepmania/src/ScreenEz2SelectStyle.cpp @@ -18,7 +18,7 @@ and sloppy and err needs cleaning up ;) #include "ScreenTitleMenu.h" #include "ScreenCaution.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenSelectDifficulty.h" #include "ScreenSandbox.h" #include "GameManager.h" @@ -27,6 +27,7 @@ and sloppy and err needs cleaning up ;) #include "GameConstantsAndTypes.h" #include "Background.h" #include "ScreenSelectGroup.h" +#include "GameState.h" /* Constants */ @@ -146,7 +147,7 @@ ScreenEz2SelectStyle::ScreenEz2SelectStyle() m_sprBackground[i].Load( sPadGraphicPath ); m_sprBackground[i].SetXY( CENTER_X, CENTER_Y ); m_sprBackground[i].SetZoom( 1 ); - this->AddActor( &m_sprBackground[i] ); + this->AddSubActor( &m_sprBackground[i] ); } for( i=0; iAddActor( &m_sprOpt[i] ); + this->AddSubActor( &m_sprOpt[i] ); } for( i=0; iAddActor( &m_sprPly[i] ); + this->AddSubActor( &m_sprPly[i] ); } m_Menu.Load( - THEME->GetPathTo(GRAPHIC_SELECT_STYLE_PREVIEW_GAME_0_STYLE_0), + THEME->GetPathTo(GRAPHIC_SELECT_STYLE_BACKGROUND), THEME->GetPathTo(GRAPHIC_SELECT_STYLE_TOP_EDGE), ssprintf("Use %c %c to select, then press START", char(1), char(2) ), false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_soundChange.Load( THEME->GetPathTo(SOUND_SELECT_STYLE_CHANGE) ); m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) ); @@ -218,7 +219,7 @@ ScreenEz2SelectStyle::ScreenEz2SelectStyle() MUSIC->Play( true ); } - if ( GAMEMAN->m_sMasterPlayerNumber == PLAYER_1 && GAMEMAN->m_CurStyle == STYLE_EZ2_SINGLE) //if p1 already selected hide graphic. + if ( GAMESTATE->m_MasterPlayerNumber == PLAYER_1 && GAMESTATE->m_CurStyle == STYLE_EZ2_SINGLE) //if p1 already selected hide graphic. { m_iSelectedPlayer = 0; m_sprPly[1].BeginTweening( 0 ); @@ -226,7 +227,7 @@ ScreenEz2SelectStyle::ScreenEz2SelectStyle() m_sprPly[2].BeginTweening( 0 ); m_sprPly[2].SetTweenZoomY( 0 ); } - else if ( GAMEMAN->m_sMasterPlayerNumber == PLAYER_2 && GAMEMAN->m_CurStyle == STYLE_EZ2_SINGLE) //if p2 already selected hide graphic. + else if ( GAMESTATE->m_MasterPlayerNumber == PLAYER_2 && GAMESTATE->m_CurStyle == STYLE_EZ2_SINGLE) //if p2 already selected hide graphic. { m_iSelectedPlayer = 1; m_sprPly[3].BeginTweening( 0 ); @@ -256,7 +257,7 @@ ScreenEz2SelectStyle::ScreenEz2SelectStyle() MenuLeft( PLAYER_1 ); // shift left so that we're clean again. } - GAMEMAN->m_CurStyle = STYLE_NONE; // why reset this? because we want player2 to be able to input at this stage. + GAMESTATE->m_CurStyle = STYLE_NONE; // why reset this? because we want player2 to be able to input at this stage. m_Menu.TweenOnScreenFromBlack( SM_None ); @@ -324,7 +325,6 @@ void ScreenEz2SelectStyle::HandleScreenMessage( const ScreenMessage SM ) if (m_iSelectedStyle == 0) // easy { - GAMEMAN->m_CurStyle = STYLE_EZ2_SINGLE_VERSUS; } else if (m_iSelectedStyle == 1) // hard { @@ -334,7 +334,7 @@ void ScreenEz2SelectStyle::HandleScreenMessage( const ScreenMessage SM ) } else if (m_iSelectedStyle == 2) // real { - GAMEMAN->m_CurStyle = STYLE_EZ2_REAL_VERSUS; + GAMESTATE->m_CurStyle = STYLE_EZ2_REAL_VERSUS; //m_soundInvalid.PlayRandom(); //return; } @@ -352,17 +352,17 @@ void ScreenEz2SelectStyle::HandleScreenMessage( const ScreenMessage SM ) } else if (m_iSelectedStyle == 2) // real { - GAMEMAN->m_CurStyle = STYLE_EZ2_REAL; + GAMESTATE->m_CurStyle = STYLE_EZ2_REAL; } else // club { - GAMEMAN->m_CurStyle = STYLE_EZ2_DOUBLE; - GAMEMAN->m_sMasterPlayerNumber = PLAYER_1; + GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; } } m_soundSelect.PlayRandom(); - PREFSMAN->m_PlayMode = PLAY_MODE_ARCADE; + GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; SCREENMAN->SetNewScreen( new ScreenSelectGroup ); break; @@ -388,7 +388,7 @@ void ScreenEz2SelectStyle::MenuBack( const PlayerNumber p ) MUSIC->Stop(); m_Menu.TweenOffScreenToBlack( SM_GoToPrevState, true ); - GAMEMAN->m_CurStyle = STYLE_NONE; // Make sure that both players can scroll around title menu... + GAMESTATE->m_CurStyle = STYLE_NONE; // Make sure that both players can scroll around title menu... // m_Fade.CloseWipingLeft( SM_GoToPrevState ); @@ -687,7 +687,7 @@ presses the button bound to start ************************************/ void ScreenEz2SelectStyle::MenuStart( PlayerNumber p ) { -// GAMEMAN->m_CurStyle = DANCE_STYLES[m_iSelectedStyle]; +// GAMESTATE->m_CurStyle = DANCE_STYLES[m_iSelectedStyle]; if ((m_iSelectedPlayer == 0 && p == PLAYER_2) || (m_iSelectedPlayer == 1 && p == PLAYER_1)) { @@ -742,14 +742,15 @@ void ScreenEz2SelectStyle::MenuStart( PlayerNumber p ) } else if (m_iSelectedStyle == 2) // real { - GAMEMAN->m_CurStyle = STYLE_EZ2_REAL; + GAMESTATE->m_CurStyle = STYLE_EZ2_REAL; //m_soundInvalid.PlayRandom(); //return; } else // club { - GAMEMAN->m_CurStyle = STYLE_EZ2_DOUBLE; - GAMEMAN->m_sMasterPlayerNumber = PLAYER_1; + GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; + GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; //m_soundInvalid.PlayRandom(); //return; } @@ -758,7 +759,7 @@ void ScreenEz2SelectStyle::MenuStart( PlayerNumber p ) this->ClearMessageQueue(); - PREFSMAN->m_PlayMode = PLAY_MODE_ARCADE; + GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; m_Menu.TweenOffScreenToMenu( SM_GoToNextState ); diff --git a/stepmania/src/ScreenGameOver.cpp b/stepmania/src/ScreenGameOver.cpp index 3bf5b93c49..4022ea3dea 100644 --- a/stepmania/src/ScreenGameOver.cpp +++ b/stepmania/src/ScreenGameOver.cpp @@ -11,7 +11,7 @@ */ #include "ScreenGameOver.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" #include "TransitionFadeWipe.h" #include "Sprite.h" @@ -19,6 +19,8 @@ #include "ScreenManager.h" #include "ScreenTitleMenu.h" #include "AnnouncerManager.h" +#include "GameState.h" + const ScreenMessage SM_StartFadingOut = ScreenMessage(SM_User + 1); const ScreenMessage SM_GoToNextState = ScreenMessage(SM_User + 2); @@ -27,9 +29,11 @@ const ScreenMessage SM_PlayAnnouncer = ScreenMessage(SM_User + 3); ScreenGameOver::ScreenGameOver() { + m_bClosing = false; + m_sprGameOver.Load( THEME->GetPathTo(GRAPHIC_GAME_OVER) ); m_sprGameOver.SetXY( CENTER_X, CENTER_Y ); - this->AddActor( &m_sprGameOver ); + this->AddSubActor( &m_sprGameOver ); // tween game over m_sprGameOver.SetAddColor( D3DXCOLOR(1,1,1,0) ); @@ -45,7 +49,7 @@ ScreenGameOver::ScreenGameOver() m_sprGameOver.SetTweenAddColor( D3DXCOLOR(1,1,1,0) ); // BUGFIX by ANDY: Stage will now reset back to 0 when game ends. - PREFSMAN->m_iCurrentStageIndex = 0; + GAMESTATE->m_iCurrentStageIndex = 0; this->SendScreenMessage( SM_PlayAnnouncer, 0.5 ); this->SendScreenMessage( SM_StartFadingOut, 5 ); @@ -60,6 +64,7 @@ void ScreenGameOver::HandleScreenMessage( const ScreenMessage SM ) SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_GAME_OVER) ); break; case SM_StartFadingOut: + m_bClosing = true; m_sprGameOver.BeginTweening( 0.8f ); m_sprGameOver.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) ); this->SendScreenMessage( SM_GoToNextState, 0.8f ); @@ -72,6 +77,9 @@ void ScreenGameOver::HandleScreenMessage( const ScreenMessage SM ) void ScreenGameOver::MenuStart( PlayerNumber p ) { + if( m_bClosing ) + return; + this->ClearMessageQueue(); this->SendScreenMessage( SM_StartFadingOut, 0 ); } diff --git a/stepmania/src/ScreenGameOver.h b/stepmania/src/ScreenGameOver.h index 31a0ffca52..ace371fb7a 100644 --- a/stepmania/src/ScreenGameOver.h +++ b/stepmania/src/ScreenGameOver.h @@ -23,6 +23,8 @@ public: virtual void MenuStart( const PlayerNumber p ); private: + + bool m_bClosing; Sprite m_sprGameOver; }; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 3980400b73..3ea6f9652b 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -17,19 +17,24 @@ #include "ScreenSelectMusic.h" #include "ScreenEvaluation.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "GameManager.h" #include "SongManager.h" #include "RageLog.h" #include "AnnouncerManager.h" #include "ScreenGameOver.h" +#include "LifeMeterBar.h" +#include "LifeMeterBattery.h" +#include "GameState.h" +#include "ScoreDisplayNormal.h" +#include "ScoreDisplayOni.h" // -// Defines specific to GameScreenTitleMenu +// Defines // const float LIFE_LOCAL_X[NUM_PLAYERS] = { -180, +180 }; -const float LIFE_LOCAL_Y[NUM_PLAYERS] = { -10, -10 }; +const float LIFE_LOCAL_Y[NUM_PLAYERS] = { -8, -8 }; const float STAGE_NUMBER_LOCAL_X = 0; const float STAGE_NUMBER_LOCAL_Y = +20; @@ -50,12 +55,13 @@ const float DIFFICULTY_Y[NUM_PLAYERS] = { SCREEN_BOTTOM-70, SCREEN_BOTTOM-70 }; const float DEBUG_X = CENTER_X; const float DEBUG_Y = CENTER_Y-70; -const float TIME_BETWEEN_DANCING_COMMENTS = 15; +const float TIME_BETWEEN_DANCING_COMMENTS = 13; // received while STATE_DANCING const ScreenMessage SM_NotesEnded = ScreenMessage(SM_User+102); -const ScreenMessage SM_LifeIs0 = ScreenMessage(SM_User+103); +const ScreenMessage SM_LastNotesEnded = ScreenMessage(SM_User+103); +const ScreenMessage SM_LifeIs0 = ScreenMessage(SM_User+104); // received while STATE_OUTRO @@ -75,37 +81,33 @@ ScreenGameplay::ScreenGameplay() { LOG->WriteLine( "ScreenGameplay::ScreenGameplay()" ); - m_pCurSong = NULL; - - switch( PREFSMAN->m_PlayMode ) + switch( GAMESTATE->m_PlayMode ) { case PLAY_MODE_ARCADE: { - m_apSongQueue.Add( SONGMAN->GetCurrentSong() ); + m_apSongQueue.Add( GAMESTATE->m_pCurSong ); for( int p=0; pGetCurrentNotes(PlayerNumber(p)) ); + m_apNotesQueue[p].Add( GAMESTATE->m_pCurNotes[p] ); } break; case PLAY_MODE_ONI: { - Course* pCourse = SONGMAN->m_pCurCourse; + Course* pCourse = GAMESTATE->m_pCurCourse; ASSERT( pCourse != NULL ); - for( int i=0; im_iStages; i++ ) - { - Song* pSong = pCourse->m_apSongs[i]; - DifficultyClass dc = pCourse->m_aDifficultyClasses[i]; - for( int j=0; jm_apNotes.GetSize(); j++ ) - { - Notes* pNotes = pSong->m_apNotes[j]; - if( pSong->m_apNotes[j]->m_DifficultyClass == dc ) - { - m_apSongQueue.Add( pSong ); - for( int p=0; pGetSongAndNotesForCurrentStyle( m_apSongQueue, m_apNotesQueue ); + + // store possible dance points in GAMESTATE + GAMESTATE->m_iCoursePossibleDancePoints = 0; + for( int i=0; iGetNoteData( &nd ); + GAMESTATE->m_iCoursePossibleDancePoints += nd.GetPossibleDancePoints(); } } break; @@ -118,62 +120,65 @@ ScreenGameplay::ScreenGameplay() m_Background.SetDiffuseColor( D3DXCOLOR(0.4f,0.4f,0.4f,1) ); - this->AddActor( &m_Background ); + this->AddSubActor( &m_Background ); for( int p=0; pIsPlayerEnabled(PlayerNumber(p)) ) + if( !GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) ) continue; - m_Player[p].SetX( (float) GAMEMAN->GetCurrentStyleDef()->m_iCenterX[p] ); - this->AddActor( &m_Player[p] ); + m_Player[p].SetX( (float) GAMESTATE->GetCurrentStyleDef()->m_iCenterX[p] ); + this->AddSubActor( &m_Player[p] ); } - ////////////////////////////////// // Add all Actors to m_frameTop ////////////////////////////////// - this->AddActor( &m_frameTop ); + this->AddSubActor( &m_frameTop ); - // LifeMeter goes underneath top frame for( p=0; pm_PlayMode ) + { + case PLAY_MODE_ARCADE: + m_pLifeMeter[p] = new LifeMeterBar; + break; + case PLAY_MODE_ONI: + m_pLifeMeter[p] = new LifeMeterBattery; + break; + default: + ASSERT(0); + } - if( !GAMEMAN->IsPlayerEnabled(PlayerNumber(p)) ) - continue; - - m_LifeMeter[p].SetPlayerOptions( PREFSMAN->m_PlayerOptions[p] ); - m_LifeMeter[p].SetXY( LIFE_LOCAL_X[p], LIFE_LOCAL_Y[p] ); - m_LifeMeter[p].SetZoomX( 256 ); - m_LifeMeter[p].SetZoomY( (p==PLAYER_1) ? 20.0f : -20.0f ); - m_frameTop.AddActor( &m_LifeMeter[p] ); + m_pLifeMeter[p]->Load( (PlayerNumber)p, GAMESTATE->m_PlayerOptions[p] ); + m_pLifeMeter[p]->SetXY( LIFE_LOCAL_X[p], LIFE_LOCAL_Y[p] ); + m_frameTop.AddSubActor( m_pLifeMeter[p] ); - if ( GAMEMAN->m_CurGame == GAME_EZ2 ) + if( GAMESTATE->GetCurGame() == GAME_EZ2 ) { - m_ScoreDisplay[p].SetXY( SCORE_LOCALEZ2_X[p], SCORE_LOCALEZ2_Y[p] ); - m_ScoreDisplay[p].SetZoom( 0.5f ); - m_ScoreDisplay[p].SetDiffuseColor( PlayerToColor(p) ); - m_frameTop.AddActor( &m_ScoreDisplay[p] ); + m_pScoreDisplay[p]->SetXY( SCORE_LOCALEZ2_X[p], SCORE_LOCALEZ2_Y[p] ); + m_pScoreDisplay[p]->SetZoom( 0.5f ); + m_pScoreDisplay[p]->SetDiffuseColor( PlayerToColor(p) ); + m_frameTop.AddSubActor( m_pScoreDisplay[p] ); } } // TopFrame goes above LifeMeter - m_sprTopFrame.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_TOP_FRAME_ARCADE) ); - m_frameTop.AddActor( &m_sprTopFrame ); + m_sprTopFrame.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_TOP_FRAME) ); + m_frameTop.AddSubActor( &m_sprTopFrame ); m_frameTop.SetXY( CENTER_X, SCREEN_TOP + m_sprTopFrame.GetZoomedHeight()/2 ); m_textStageNumber.Load( THEME->GetPathTo(FONT_HEADER2) ); m_textStageNumber.TurnShadowOff(); - if ( GAMEMAN->m_CurGame == GAME_EZ2 ) + m_textStageNumber.SetXY( STAGE_NUMBER_LOCAL_X, STAGE_NUMBER_LOCAL_Y ); + m_textStageNumber.SetText( GAMESTATE->GetStageText() ); + m_textStageNumber.SetDiffuseColor( GAMESTATE->GetStageColor() ); + + if( GAMESTATE->GetCurGame() == GAME_EZ2 ) { m_textStageNumber.SetXY( STAGE_NUMBER_LOCAL_X, STAGE_NUMBER_LOCALEZ2_Y ); } @@ -181,61 +186,96 @@ ScreenGameplay::ScreenGameplay() { m_textStageNumber.SetXY( STAGE_NUMBER_LOCAL_X, STAGE_NUMBER_LOCAL_Y ); } - m_textStageNumber.SetText( PREFSMAN->GetStageText() ); - m_textStageNumber.SetDiffuseColor( PREFSMAN->GetStageColor() ); - m_frameTop.AddActor( &m_textStageNumber ); + m_textStageNumber.SetText( GAMESTATE->GetStageText() ); + m_textStageNumber.SetDiffuseColor( GAMESTATE->GetStageColor() ); + + m_frameTop.AddSubActor( &m_textStageNumber ); ////////////////////////////////// // Add all Actors to m_frameBottom ////////////////////////////////// - this->AddActor( &m_frameBottom ); + this->AddSubActor( &m_frameBottom ); - if ( GAMEMAN->m_CurGame != GAME_EZ2 ) + m_sprBottomFrame.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_BOTTOM_FRAME) ); + m_frameBottom.AddSubActor( &m_sprBottomFrame ); + + m_frameBottom.SetXY( CENTER_X, SCREEN_BOTTOM - m_sprBottomFrame.GetZoomedHeight()/2 ); + + if( GAMESTATE->GetCurGame() != GAME_EZ2 ) { m_sprBottomFrame.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_BOTTOM_FRAME) ); - m_frameBottom.AddActor( &m_sprBottomFrame ); + m_frameBottom.AddSubActor( &m_sprBottomFrame ); m_frameBottom.SetXY( CENTER_X, SCREEN_BOTTOM - m_sprBottomFrame.GetZoomedHeight()/2 ); } + for( p=0; pIsPlayerEnabled(PlayerNumber(p)) ) + switch( GAMESTATE->m_PlayMode ) + { + case PLAY_MODE_ARCADE: + m_pScoreDisplay[p] = new ScoreDisplayNormal; + break; + case PLAY_MODE_ONI: + m_pScoreDisplay[p] = new ScoreDisplayOni; + break; + default: + ASSERT(0); + } + + m_pScoreDisplay[p]->Init( (PlayerNumber)p, GAMESTATE->m_PlayerOptions[p], 100, 7 ); + m_pScoreDisplay[p]->SetXY( SCORE_LOCAL_X[p], SCORE_LOCAL_Y[p] ); + m_pScoreDisplay[p]->SetZoom( 0.8f ); + m_pScoreDisplay[p]->SetDiffuseColor( PlayerToColor(p) ); + m_frameBottom.AddSubActor( m_pScoreDisplay[p] ); + + m_textPlayerOptions[p].Load( THEME->GetPathTo(FONT_NORMAL) ); + + if( !GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) ) continue; - if ( GAMEMAN->m_CurGame != GAME_EZ2 ) + if( GAMESTATE->GetCurGame() != GAME_EZ2 ) { - m_ScoreDisplay[p].SetXY( SCORE_LOCAL_X[p], SCORE_LOCAL_Y[p] ); - m_ScoreDisplay[p].SetZoom( 0.8f ); - m_ScoreDisplay[p].SetDiffuseColor( PlayerToColor(p) ); - m_frameBottom.AddActor( &m_ScoreDisplay[p] ); + m_pScoreDisplay[p]->SetXY( SCORE_LOCAL_X[p], SCORE_LOCAL_Y[p] ); + m_pScoreDisplay[p]->SetZoom( 0.8f ); + m_pScoreDisplay[p]->SetDiffuseColor( PlayerToColor(p) ); + m_frameBottom.AddSubActor( m_pScoreDisplay[p] ); } m_textPlayerOptions[p].Load( THEME->GetPathTo(FONT_NORMAL) ); + m_textPlayerOptions[p].TurnShadowOff(); m_textPlayerOptions[p].SetXY( PLAYER_OPTIONS_LOCAL_X[p], PLAYER_OPTIONS_LOCAL_Y[p] ); m_textPlayerOptions[p].SetZoom( 0.5f ); m_textPlayerOptions[p].SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); - m_textPlayerOptions[p].SetText( PREFSMAN->m_PlayerOptions[p].GetString() ); - m_frameBottom.AddActor( &m_textPlayerOptions[p] ); + m_textPlayerOptions[p].SetText( GAMESTATE->m_PlayerOptions[p].GetString() ); + m_frameBottom.AddSubActor( &m_textPlayerOptions[p] ); } // Get the current StyleDef definition (used below) - StyleDef* pStyleDef = GAMEMAN->GetCurrentStyleDef(); + StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); for( p=0; pIsPlayerEnabled(PlayerNumber(p)) ) + if( !GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) ) continue; - if (GAMEMAN->m_CurGame != GAME_EZ2) + + float fDifficultyY = DIFFICULTY_Y[p]; + if( GAMESTATE->m_PlayerOptions[p].m_bReverseScroll ) + fDifficultyY = SCREEN_HEIGHT - DIFFICULTY_Y[p]; + m_DifficultyBanner[p].SetXY( DIFFICULTY_X[p], fDifficultyY ); + this->AddSubActor( &m_DifficultyBanner[p] ); + + if( GAMESTATE->GetCurGame() != GAME_EZ2 ) { float fDifficultyY = DIFFICULTY_Y[p]; - if( PREFSMAN->m_PlayerOptions[p].m_bReverseScroll ) + if( GAMESTATE->m_PlayerOptions[p].m_bReverseScroll ) fDifficultyY = SCREEN_HEIGHT - DIFFICULTY_Y[p]; m_DifficultyBanner[p].SetXY( DIFFICULTY_X[p], fDifficultyY ); - this->AddActor( &m_DifficultyBanner[p] ); + this->AddSubActor( &m_DifficultyBanner[p] ); } } @@ -243,42 +283,42 @@ ScreenGameplay::ScreenGameplay() m_textDebug.Load( THEME->GetPathTo(FONT_NORMAL) ); m_textDebug.SetXY( DEBUG_X, DEBUG_Y ); m_textDebug.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); - this->AddActor( &m_textDebug ); + this->AddSubActor( &m_textDebug ); m_StarWipe.SetClosed(); - this->AddActor( &m_StarWipe ); + this->AddSubActor( &m_StarWipe ); m_sprReady.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_READY) ); m_sprReady.SetXY( CENTER_X, CENTER_Y ); m_sprReady.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); - this->AddActor( &m_sprReady ); + this->AddSubActor( &m_sprReady ); m_sprHereWeGo.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_HERE_WE_GO) ); m_sprHereWeGo.SetXY( CENTER_X, CENTER_Y ); m_sprHereWeGo.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); - this->AddActor( &m_sprHereWeGo ); + this->AddSubActor( &m_sprHereWeGo ); m_sprCleared.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_CLEARED) ); m_sprCleared.SetXY( CENTER_X, CENTER_Y ); m_sprCleared.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); - this->AddActor( &m_sprCleared ); + this->AddSubActor( &m_sprCleared ); m_sprFailed.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_FAILED) ); m_sprFailed.SetXY( CENTER_X, CENTER_Y ); m_sprFailed.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); - this->AddActor( &m_sprFailed ); + this->AddSubActor( &m_sprFailed ); m_soundFail.Load( THEME->GetPathTo(SOUND_GAMEPLAY_FAILED) ); m_announcerReady.Load( ANNOUNCER->GetPathTo(ANNOUNCER_GAMEPLAY_READY) ); - if( PREFSMAN->IsExtraStage() || PREFSMAN->IsExtraStage2() ) + if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() ) m_announcerHereWeGo.Load( ANNOUNCER->GetPathTo(ANNOUNCER_GAMEPLAY_HERE_WE_GO_EXTRA) ); - else if( PREFSMAN->IsFinalStage() ) + else if( GAMESTATE->IsFinalStage() ) m_announcerHereWeGo.Load( ANNOUNCER->GetPathTo(ANNOUNCER_GAMEPLAY_HERE_WE_GO_FINAL) ); else m_announcerHereWeGo.Load( ANNOUNCER->GetPathTo(ANNOUNCER_GAMEPLAY_HERE_WE_GO_NORMAL) ); @@ -304,7 +344,7 @@ ScreenGameplay::ScreenGameplay() m_soundAssistTick.Load( THEME->GetPathTo(SOUND_GAMEPLAY_ASSIST_TICK) ); - LoadNextSong(); + LoadNextSong( false ); // Send some messages every have second to we can get the introduction rolling for( int i=0; i<30; i++ ) @@ -314,85 +354,95 @@ ScreenGameplay::ScreenGameplay() ScreenGameplay::~ScreenGameplay() { LOG->WriteLine( "ScreenGameplay::~ScreenGameplay()" ); + + for( int p=0; pIsPlayerEnabled((PlayerNumber)p) ) - continue; // skip - - SONGMAN->m_aGameplayStatistics[p].Add( m_Player[p].GetGameplayStatistics( m_pCurSong, m_pCurNotes[p]) ); - } - - m_pCurSong = NULL; - for( p=0; pSendScreenMessage( SM_LastNotesEnded, 0 ); + return; } -} -void ScreenGameplay::LoadNextSong() -{ int p; + // add a new GameplayStatistic for this song + GAMESTATE->m_aGameplayStatistics.Add( GameplayStatistics() ); - SaveSummary(); - - m_pCurSong = m_apSongQueue[m_apSongQueue.GetSize()-1]; - m_apSongQueue.RemoveAt(m_apSongQueue.GetSize()-1); + GAMESTATE->m_pCurSong = m_apSongQueue[0]; + m_apSongQueue.RemoveAt(0); for( p=0; pm_pCurNotes[p] = m_apNotesQueue[p][0]; + m_apNotesQueue[p].RemoveAt(0); } // Get the current StyleDef definition (used below) - StyleDef* pStyleDef = GAMEMAN->GetCurrentStyleDef(); + StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); for( p=0; pIsPlayerEnabled(PlayerNumber(p)) ) + if( !GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) ) continue; - m_DifficultyBanner[p].SetFromNotes( PlayerNumber(p), m_pCurNotes[p] ); + m_DifficultyBanner[p].SetFromNotes( PlayerNumber(p), GAMESTATE->m_pCurNotes[p] ); NoteData originalNoteData; - m_pCurNotes[p]->GetNoteData( &originalNoteData ); + GAMESTATE->m_pCurNotes[p]->GetNoteData( &originalNoteData ); NoteData newNoteData; pStyleDef->GetTransformedNoteDataForStyle( (PlayerNumber)p, &originalNoteData, &newNoteData ); + + // Fill in info about these notes in the latest GameplayStatistics + GAMESTATE->GetLatestGameplayStatistics().dc[p] = GAMESTATE->m_pCurNotes[p]->m_DifficultyClass; + GAMESTATE->GetLatestGameplayStatistics().meter[p] = GAMESTATE->m_pCurNotes[p]->m_iMeter; + GAMESTATE->GetLatestGameplayStatistics().iPossibleDancePoints[p] = newNoteData.GetPossibleDancePoints(); + for( int r=0; rGetLatestGameplayStatistics().fRadarPossible[p][r] = newNoteData.GetRadarValue( (RadarCategory)r, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); + m_Player[p].Load( (PlayerNumber)p, - GAMEMAN->GetCurrentStyleDef(), + GAMESTATE->GetCurrentStyleDef(), &newNoteData, - PREFSMAN->m_PlayerOptions[p], - &m_LifeMeter[p], - &m_ScoreDisplay[p], + GAMESTATE->m_PlayerOptions[p], + m_pLifeMeter[p], + m_pScoreDisplay[p], originalNoteData.GetNumTapNotes(), - m_pCurNotes[p]->m_iMeter + GAMESTATE->m_pCurNotes[p]->m_iMeter ); } - m_soundMusic.Load( m_pCurSong->GetMusicPath(), true ); // enable accurate sync - float fStartSeconds = min( 0, m_pCurSong->GetElapsedTimeFromBeat(m_pCurSong->m_fFirstBeat-4) ); - m_soundMusic.SetPositionSeconds( fStartSeconds ); - m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate ); - m_Background.LoadFromSong( m_pCurSong ); + m_Background.LoadFromSong( GAMESTATE->m_pCurSong ); m_Background.SetDiffuseColor( D3DXCOLOR(0.5f,0.5f,0.5f,1) ); m_Background.BeginTweeningQueued( 2 ); m_Background.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,1) ); + + m_soundMusic.Load( GAMESTATE->m_pCurSong->GetMusicPath(), true ); // enable accurate sync + float fStartSeconds = min( 0, -4+GAMESTATE->m_pCurSong->GetElapsedTimeFromBeat(GAMESTATE->m_pCurSong->m_fFirstBeat) ); + m_soundMusic.SetPositionSeconds( fStartSeconds ); + m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate ); + if( bPlayMusic ) + m_soundMusic.Play(); + + if( bPlayMusic ) + for( int p=0; pIsPlayerEnabled(PlayerNumber(p)) ) + m_pLifeMeter[p]->NextSong( NULL ); } @@ -403,76 +453,88 @@ void ScreenGameplay::Update( float fDeltaTime ) m_soundMusic.Update( fDeltaTime ); - if( m_pCurSong == NULL ) + if( GAMESTATE->m_pCurSong == NULL ) return; float fPositionSeconds = m_soundMusic.GetPositionSeconds(); float fSongBeat, fBPS; bool bFreeze; - m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); + GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); + + // update the global music statistics for other classes to access + GAMESTATE->m_fMusicSeconds = fPositionSeconds; + GAMESTATE->m_fMusicBeat = fSongBeat; + GAMESTATE->m_fCurBPS = fBPS; + GAMESTATE->m_bFreeze = bFreeze; + m_Background.SetSongBeat( fSongBeat, bFreeze, fPositionSeconds ); //LOG->WriteLine( "m_fOffsetInBeats = %f, m_fBeatsPerSecond = %f, m_Music.GetPositionSeconds = %f", m_fOffsetInBeats, m_fBeatsPerSecond, m_Music.GetPositionSeconds() ); - const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * PREFSMAN->m_SongOptions.m_fMusicRate; + const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * GAMESTATE->m_SongOptions.m_fMusicRate; for( int p=0; pIsPlayerEnabled(PlayerNumber(p)) ) + if( !GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) ) continue; m_Player[p].Update( fDeltaTime, fSongBeat, fMaxBeatDifference ); } // check for fail - switch( PREFSMAN->m_SongOptions.m_FailType ) + switch( GAMESTATE->m_SongOptions.m_FailType ) { case SongOptions::FAIL_ARCADE: case SongOptions::FAIL_END_OF_SONG: - - if( m_bBothHaveFailed ) - break; // if they have already failed, don't bother checking again - { - // check for both players fail - bool bAllInDanger = true; - bool bAllFailed = true; - for( int p=0; pIsPlayerEnabled(PlayerNumber(p)) ) - continue; - if( !m_LifeMeter[p].IsInDanger() ) - bAllInDanger = false; + if( m_bBothHaveFailed ) + break; // if they have already failed, don't bother checking again - if( !m_LifeMeter[p].HasFailed() ) - bAllFailed = false; - } + // check for both players fail + bool bAllInDanger = true; + bool bAllAreFailing = true; + for( int p=0; pIsPlayerEnabled(PlayerNumber(p)) ) + continue; - if( bAllInDanger ) m_Background.TurnDangerOn(); - else m_Background.TurnDangerOff(); + if( !m_pLifeMeter[p]->IsInDanger() ) + bAllInDanger = false; - if( bAllFailed ) - { - m_bBothHaveFailed = true; - SCREENMAN->SendMessageToTopScreen( SM_LifeIs0, 0 ); - } + if( !m_pLifeMeter[p]->IsFailing() ) + bAllAreFailing = false; + } + + if( bAllInDanger ) m_Background.TurnDangerOn(); + else m_Background.TurnDangerOff(); + + if( bAllAreFailing ) + { + m_bBothHaveFailed = true; + SCREENMAN->SendMessageToTopScreen( SM_LifeIs0, 0 ); + } } break; case SongOptions::FAIL_OFF: break; } + // update seconds into play + for( p=0; pIsPlayerEnabled((PlayerNumber)p) && !m_pLifeMeter[p]->FailedEarlier() ) + GAMESTATE->GetLatestGameplayStatistics().fSecsIntoPlay[p] = max( GAMESTATE->GetLatestGameplayStatistics().fSecsIntoPlay[p], GAMESTATE->m_fMusicSeconds ); + switch( m_DancingState ) { case STATE_DANCING: // Check for end of song - if( fSongBeat > m_pCurSong->m_fLastBeat+4 ) + if( fSongBeat > GAMESTATE->m_pCurSong->m_fLastBeat+4 ) this->SendScreenMessage( SM_NotesEnded, 0 ); // Check to see if it's time to play a gameplay comment @@ -483,12 +545,12 @@ void ScreenGameplay::Update( float fDeltaTime ) bool bAllInDanger = true; for( int p=0; pIsInDanger() ) bAllInDanger = false; bool bOneIsHot = false; for( p=0; pIsHot() ) bOneIsHot = true; if( bOneIsHot ) @@ -512,7 +574,7 @@ void ScreenGameplay::Update( float fDeltaTime ) { for( int p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip m_Player[p].CrossedRow( r, fSongBeat, fMaxBeatDifference ); @@ -529,10 +591,10 @@ void ScreenGameplay::Update( float fDeltaTime ) // Sound cards have a latency between when a sample is Play()ed and when the sound // will start coming out the speaker. Compensate for this by boosting // fPositionSeconds ahead - if( PREFSMAN->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK ) + if( GAMESTATE->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK ) { fPositionSeconds += (SOUND->GetPlayLatency()+0.04f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.04 seconds to make them play a tiny bit earlier - m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); + GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); int iRowNow = BeatToNoteRowNotRounded( fSongBeat ); static int iRowLastCrossed = 0; @@ -543,7 +605,7 @@ void ScreenGameplay::Update( float fDeltaTime ) { for( int p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip m_Player[p].CrossedRow( r, fSongBeat, fMaxBeatDifference ); @@ -564,7 +626,7 @@ void ScreenGameplay::Update( float fDeltaTime ) { for( int p=0; pIsPlayerEnabled((PlayerNumber)p) ) + if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) ) continue; float fOverrideAdd = m_Player[p].GetOverrideAdd(); @@ -595,7 +657,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ float fSongBeat, fBPS; bool bFreeze; - m_pCurSong->GetBeatAndBPSFromElapsedTime( m_soundMusic.GetPositionSeconds(), fSongBeat, fBPS, bFreeze ); + GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( m_soundMusic.GetPositionSeconds(), fSongBeat, fBPS, bFreeze ); // Handle special keys to adjust the offset @@ -616,9 +678,9 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ if( type == IET_FAST_REPEAT ) fOffsetDelta *= 40; - m_pCurSong->m_fBeat0OffsetInSeconds += fOffsetDelta; + GAMESTATE->m_pCurSong->m_fBeat0OffsetInSeconds += fOffsetDelta; - m_textDebug.SetText( ssprintf("Offset = %f.", m_pCurSong->m_fBeat0OffsetInSeconds) ); + m_textDebug.SetText( ssprintf("Offset = %f.", GAMESTATE->m_pCurSong->m_fBeat0OffsetInSeconds) ); m_textDebug.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); m_textDebug.StopTweening(); m_textDebug.BeginTweeningQueued( 3 ); // sleep @@ -637,13 +699,13 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ SCREENMAN->SendMessageToTopScreen( SM_BeginFailed, 0 ); } - const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * PREFSMAN->m_SongOptions.m_fMusicRate; + const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * GAMESTATE->m_SongOptions.m_fMusicRate; if( type == IET_FIRST_PRESS ) { if( StyleI.IsValid() ) { - if( GAMEMAN->IsPlayerEnabled( StyleI.player ) ) + if( GAMESTATE->IsPlayerEnabled( StyleI.player ) ) m_Player[StyleI.player].HandlePlayerStep( fSongBeat, StyleI.col, fMaxBeatDifference ); } } @@ -669,11 +731,12 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) m_sprReady.StartBlurring(); break; case SM_User+5: - m_sprHereWeGo.StartFocusing(); - m_announcerHereWeGo.PlayRandom(); - m_Background.FadeIn(); - m_soundMusic.Play(); - m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate ); + { + m_sprHereWeGo.StartFocusing(); + m_announcerHereWeGo.PlayRandom(); + m_Background.FadeIn(); + m_soundMusic.Play(); + } break; case SM_User+6: break; @@ -688,11 +751,19 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) // received while STATE_DANCING case SM_LifeIs0: - if( PREFSMAN->m_SongOptions.m_FailType == SongOptions::FAIL_ARCADE ) // fail them now! + if( GAMESTATE->m_SongOptions.m_FailType == SongOptions::FAIL_ARCADE ) // fail them now! this->SendScreenMessage( SM_BeginFailed, 0 ); m_DancingState = STATE_OUTRO; break; case SM_NotesEnded: + { + for( int p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + m_Player[p].SaveGameplayStatistics(); + LoadNextSong( true ); + } + break; + case SM_LastNotesEnded: if( m_DancingState == STATE_OUTRO ) // gameplay already ended return; // ignore @@ -797,8 +868,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) SCREENMAN->SendMessageToTopScreen( SM_GoToResults, 1 ); break; case SM_GoToResults: - SaveSummary(); - SCREENMAN->SetNewScreen( new ScreenEvaluation(false) ); + SCREENMAN->SetNewScreen( new ScreenEvaluation(false) ); break; @@ -827,7 +897,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) m_sprFailed.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0.7f) ); // and fade in // BUGFIX by ANDY: Stage will now reset back to 0 when game ends. - PREFSMAN->m_iCurrentStageIndex = 0; + GAMESTATE->m_iCurrentStageIndex = 0; SCREENMAN->SendMessageToTopScreen( SM_PlayFailComment, 1.5f ); SCREENMAN->SendMessageToTopScreen( SM_HideFailed, 3.0f ); diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index 207cf57ee4..c1538fd485 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -21,8 +21,8 @@ #include "RageMusic.h" #include "MotionBlurSprite.h" #include "Background.h" -#include "LifeMeterBar.h" -#include "ScoreDisplayRolling.h" +#include "LifeMeter.h" +#include "ScoreDisplay.h" #include "DifficultyBanner.h" @@ -61,14 +61,12 @@ public: private: void TweenOnScreen(); void TweenOffScreen(); - void SaveSummary(); - void LoadNextSong(); + + void LoadNextSong( bool bPlayMusic ); DancingState m_DancingState; - Song* m_pCurSong; - Notes* m_pCurNotes[NUM_PLAYERS]; CArray m_apSongQueue; // nearest songs are on back of queue CArray m_apNotesQueue[NUM_PLAYERS]; // nearest notes are on back of queue bool m_bBothHaveFailed; @@ -80,13 +78,12 @@ private: ActorFrame m_frameTop; Sprite m_sprTopFrame; - Quad m_quadLifeMeterBG[NUM_PLAYERS]; // just a black quad to fill in hole for the life meter - LifeMeterBar m_LifeMeter[NUM_PLAYERS]; + LifeMeter* m_pLifeMeter[NUM_PLAYERS]; BitmapText m_textStageNumber; ActorFrame m_frameBottom; Sprite m_sprBottomFrame; - ScoreDisplayRolling m_ScoreDisplay[NUM_PLAYERS]; + ScoreDisplay* m_pScoreDisplay[NUM_PLAYERS]; BitmapText m_textPlayerOptions[NUM_PLAYERS]; BitmapText m_textDebug; diff --git a/stepmania/src/ScreenLoading.cpp b/stepmania/src/ScreenLoading.cpp new file mode 100644 index 0000000000..be07621c35 --- /dev/null +++ b/stepmania/src/ScreenLoading.cpp @@ -0,0 +1,32 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: ScreenLoading + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ScreenLoading.h" +#include "GameState.h" + +ScreenLoading::ScreenLoading() +{ + m_sprLoading.Load( THEME->GetPathTo(GRAPHIC_LOADING) ); + m_sprLoading.SetXY( CENTER_X, CENTER_Y ); + this->AddSubActor( &m_sprLoading ); + + m_textMessage.Load( THEME->GetPathTo(FONT_NORMAL) ); + m_textMessage.SetXY( CENTER_X, CENTER_Y ); + this->AddSubActor( &m_textMessage ); +} + +void ScreenLoading::DrawPrimitives() +{ + m_textMessage.SetText( GAMESTATE->m_sLoadingMessage ); + + Screen::DrawPrimitives(); +} diff --git a/stepmania/src/ScreenLoading.h b/stepmania/src/ScreenLoading.h new file mode 100644 index 0000000000..6467595a8d --- /dev/null +++ b/stepmania/src/ScreenLoading.h @@ -0,0 +1,29 @@ +#pragma once +/* +----------------------------------------------------------------------------- + Class: ScreenLoading + + Desc: Shows while game loads. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "Screen.h" +#include "BitmapText.h" +#include "Sprite.h" + +class ScreenLoading : public Screen +{ +public: + ScreenLoading(); + + virtual void DrawPrimitives(); + +protected: + BitmapText m_textMessage; + Sprite m_sprLoading; + +}; + diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 18ec0b1db4..fad5cbabfa 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -12,7 +12,7 @@ #include "ScreenManager.h" #include "IniFile.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" diff --git a/stepmania/src/ScreenMusicScroll.cpp b/stepmania/src/ScreenMusicScroll.cpp index d4d95c6359..c2cc315dae 100644 --- a/stepmania/src/ScreenMusicScroll.cpp +++ b/stepmania/src/ScreenMusicScroll.cpp @@ -14,13 +14,14 @@ #include "ScreenMusicScroll.h" #include "ScreenManager.h" #include "PrefsManager.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenSelectMusic.h" #include "ScreenTitleMenu.h" #include "GameManager.h" #include "RageLog.h" #include "GameConstantsAndTypes.h" #include "SongManager.h" +#include "GameState.h" const ScreenMessage SM_StartFadingOut = ScreenMessage(SM_User + 1); @@ -60,8 +61,9 @@ const CString CREDIT_LINES[] = "", "PROGRAMMING:", "Chris Danford", - "Ben Nordstrom", "Lord Frieza (Andrew Livy)", + "Dro Kulix", + "Ben Nordstrom", "Parasyte (Chris Gomez)", "angedelamort (Sauleil Lamarre)", "Edwin Evans", @@ -112,8 +114,7 @@ const CString CREDIT_LINES[] = "", "", "", - "If your name is missing from this list,", - " send me an e-mail!", + "Please, join the StepMania team and help us out!" " -Chris" }; const int NUM_CREDIT_LINES = sizeof(CREDIT_LINES) / sizeof(CString); @@ -125,12 +126,9 @@ ScreenMusicScroll::ScreenMusicScroll() int i; - // BUGFIX by ANDY: Stage will now reset back to 0 when game ends. - PREFSMAN->m_iCurrentStageIndex = 0; - m_sprBackground.Load( THEME->GetPathTo(GRAPHIC_MUSIC_SCROLL_BACKGROUND) ); m_sprBackground.StretchTo( CRect(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); - this->AddActor( &m_sprBackground ); + this->AddSubActor( &m_sprBackground ); CArray arraySongs; @@ -153,7 +151,7 @@ ScreenMusicScroll::ScreenMusicScroll() { m_textLines[m_iNumLines].Load( THEME->GetPathTo(FONT_NORMAL) ); m_textLines[m_iNumLines].SetText( CREDIT_LINES[i] ); -// this->AddActor( &m_textLines[m_iNumLines] ); +// this->AddSubActor( &m_textLines[m_iNumLines] ); m_iNumLines++; } @@ -169,9 +167,9 @@ ScreenMusicScroll::ScreenMusicScroll() this->SendScreenMessage( SM_StartFadingOut, 0.3f * i + 3.0f ); - this->AddActor( &m_Fade ); + this->AddSubActor( &m_Fade ); - if ( GAMEMAN->m_CurGame != GAME_EZ2 ) + if ( GAMESTATE->GetCurGame() != GAME_EZ2 ) { m_soundMusic.Load( THEME->GetPathTo(SOUND_MUSIC_SCROLL_MUSIC) ); } @@ -181,7 +179,7 @@ ScreenMusicScroll::ScreenMusicScroll() } m_Fade.OpenWipingRight(); - if ( GAMEMAN->m_CurGame != GAME_EZ2 ) + if ( GAMESTATE->GetCurGame() != GAME_EZ2 ) { m_soundMusic.Play( true ); } diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index c6e50b6b4a..07ace1c82a 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -17,7 +17,7 @@ #include "ScreenManager.h" #include "PrefsManager.h" #include "ScreenGameplay.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "GameConstantsAndTypes.h" #include "RageLog.h" @@ -53,7 +53,7 @@ ScreenOptions::ScreenOptions( CString sBackgroundPath, CString sTopEdgePath ) ssprintf("%s %s to change line %s %s to select between options then press START", CString(char(3)), CString(char(4)), CString(char(1)), CString(char(2)) ), false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_Menu.TweenOnScreenFromBlack( SM_None ); // init row numbers and element colors @@ -62,32 +62,32 @@ ScreenOptions::ScreenOptions( CString sBackgroundPath, CString sTopEdgePath ) m_iCurrentRow[p] = 0; m_SelectionHighlight[p].SetDiffuseColor( PlayerToColor((PlayerNumber)p) ); - this->AddActor( &m_SelectionHighlight[p] ); + this->AddSubActor( &m_SelectionHighlight[p] ); for( int l=0; lAddActor( &m_OptionUnderline[p][l] ); + this->AddSubActor( &m_OptionUnderline[p][l] ); } } // add sub actors for( int i=0; iAddActor( &m_textOptionLineTitles[i] ); + this->AddSubActor( &m_textOptionLineTitles[i] ); for( int j=0; jAddActor( &m_textOptions[i][j] ); // this array has to be big enough to hold all of the options + this->AddSubActor( &m_textOptions[i][j] ); // this array has to be big enough to hold all of the options } } m_Wipe.OpenWipingRight(SM_None); - this->AddActor( &m_Wipe ); + this->AddSubActor( &m_Wipe ); } void ScreenOptions::Init( InputMode im, OptionLineData optionLineData[], int iNumOptionLines ) @@ -149,7 +149,7 @@ void ScreenOptions::InitOptionsText() title.SetXY( LABELS_X, fY ); title.SetZoom( 0.7f ); title.SetVertAlign( Actor::align_middle ); - this->AddActor( &title ); + this->AddSubActor( &title ); // init all text in this line and count the width of the line float fX = 150; // indent 70 pixels @@ -162,7 +162,7 @@ void ScreenOptions::InitOptionsText() option.SetText( optline.szOptionsText[j] ); option.SetZoom( 0.65f ); option.SetShadowLength( 2 ); - this->AddActor( &option ); + this->AddSubActor( &option ); // set the XY position of each item in the line float fItemWidth = option.GetWidestLineWidthInSourcePixels() * option.GetZoomX(); diff --git a/stepmania/src/ScreenPlayerOptions.cpp b/stepmania/src/ScreenPlayerOptions.cpp index af854f3df6..40fa6c89d8 100644 --- a/stepmania/src/ScreenPlayerOptions.cpp +++ b/stepmania/src/ScreenPlayerOptions.cpp @@ -18,10 +18,11 @@ #include "ScreenGameplay.h" #include "ScreenSongOptions.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenSelectMusic.h" #include "RageLog.h" #include "GameManager.h" +#include "GameState.h" enum { @@ -38,7 +39,7 @@ enum { NUM_PLAYER_OPTIONS_LINES }; OptionLineData g_PlayerOptionsLines[NUM_PLAYER_OPTIONS_LINES] = { - { "Speed", 6, {"x1","x1.5","x2","x3","x5","x8"} }, + { "Speed", 8, {"x0.5","x0.75","x1","x1.5","x2","x3","x5","x8"} }, { "Effect", 6, {"OFF","BOOST","WAVE", "DRUNK", "DIZZY", "SPACE"} }, { "Appear", 4, {"VISIBLE","HIDDEN","SUDDEN","STEALTH"} }, { "Turn", 5, {"OFF","MIRROR","LEFT","RIGHT","SHUFFLE"} }, @@ -72,15 +73,17 @@ void ScreenPlayerOptions::ImportOptions() { for( int p=0; pm_PlayerOptions[p]; + PlayerOptions &po = GAMESTATE->m_PlayerOptions[p]; - if( po.m_fArrowScrollSpeed == 1.0f ) m_iSelectedOption[p][PO_SPEED] = 0; - else if( po.m_fArrowScrollSpeed == 1.5f ) m_iSelectedOption[p][PO_SPEED] = 1; - else if( po.m_fArrowScrollSpeed == 2.0f ) m_iSelectedOption[p][PO_SPEED] = 2; - else if( po.m_fArrowScrollSpeed == 3.0f ) m_iSelectedOption[p][PO_SPEED] = 3; - else if( po.m_fArrowScrollSpeed == 5.0f ) m_iSelectedOption[p][PO_SPEED] = 4; - else if( po.m_fArrowScrollSpeed == 8.0f ) m_iSelectedOption[p][PO_SPEED] = 5; - else m_iSelectedOption[p][PO_SPEED] = 0; + if( po.m_fArrowScrollSpeed == 0.5f ) m_iSelectedOption[p][PO_SPEED] = 0; + else if( po.m_fArrowScrollSpeed == 0.75f) m_iSelectedOption[p][PO_SPEED] = 1; + else if( po.m_fArrowScrollSpeed == 1.0f ) m_iSelectedOption[p][PO_SPEED] = 2; + else if( po.m_fArrowScrollSpeed == 1.5f ) m_iSelectedOption[p][PO_SPEED] = 3; + else if( po.m_fArrowScrollSpeed == 2.0f ) m_iSelectedOption[p][PO_SPEED] = 4; + else if( po.m_fArrowScrollSpeed == 3.0f ) m_iSelectedOption[p][PO_SPEED] = 5; + else if( po.m_fArrowScrollSpeed == 5.0f ) m_iSelectedOption[p][PO_SPEED] = 6; + else if( po.m_fArrowScrollSpeed == 8.0f ) m_iSelectedOption[p][PO_SPEED] = 7; + else m_iSelectedOption[p][PO_SPEED] = 2; m_iSelectedOption[p][PO_EFFECT] = po.m_EffectType; m_iSelectedOption[p][PO_APPEAR] = po.m_AppearanceType; @@ -98,16 +101,18 @@ void ScreenPlayerOptions::ExportOptions() { for( int p=0; pm_PlayerOptions[p]; + PlayerOptions &po = GAMESTATE->m_PlayerOptions[p]; switch( m_iSelectedOption[p][PO_SPEED] ) { - case 0: po.m_fArrowScrollSpeed = 1.0f; break; - case 1: po.m_fArrowScrollSpeed = 1.5f; break; - case 2: po.m_fArrowScrollSpeed = 2.0f; break; - case 3: po.m_fArrowScrollSpeed = 3.0f; break; - case 4: po.m_fArrowScrollSpeed = 5.0f; break; - case 5: po.m_fArrowScrollSpeed = 8.0f; break; + case 0: po.m_fArrowScrollSpeed = 0.5f; break; + case 1: po.m_fArrowScrollSpeed = 0.75f; break; + case 2: po.m_fArrowScrollSpeed = 1.0f; break; + case 3: po.m_fArrowScrollSpeed = 1.5f; break; + case 4: po.m_fArrowScrollSpeed = 2.0f; break; + case 5: po.m_fArrowScrollSpeed = 3.0f; break; + case 6: po.m_fArrowScrollSpeed = 5.0f; break; + case 7: po.m_fArrowScrollSpeed = 8.0f; break; } diff --git a/stepmania/src/ScreenPrompt.cpp b/stepmania/src/ScreenPrompt.cpp index e9f1b5f31b..ab719fa7e3 100644 --- a/stepmania/src/ScreenPrompt.cpp +++ b/stepmania/src/ScreenPrompt.cpp @@ -16,7 +16,7 @@ #include "RageMusic.h" #include "ScreenTitleMenu.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" ScreenPrompt::ScreenPrompt( CString sText, PromptType pt, bool* pbAnswer ) { @@ -37,7 +37,7 @@ ScreenPrompt::ScreenPrompt( CString sText, PromptType pt, bool* pbAnswer ) m_Fade.SetOpened(); m_Fade.CloseWipingRight(); m_Fade.SetZ(-2); - this->AddActor( &m_Fade ); + this->AddSubActor( &m_Fade ); CStringArray arrayTextLines; split( sText, "\n", arrayTextLines ); @@ -47,7 +47,7 @@ ScreenPrompt::ScreenPrompt( CString sText, PromptType pt, bool* pbAnswer ) m_textQuestion[i].SetText( arrayTextLines[i] ); m_textQuestion[i].SetXY( CENTER_X, CENTER_Y-50 + i*27 - arrayTextLines.GetSize()*27/2 ); m_textQuestion[i].SetZ(-2); - this->AddActor( &m_textQuestion[i] ); + this->AddSubActor( &m_textQuestion[i] ); } m_rectAnswerBox.SetDiffuseColor( D3DXCOLOR(0.5f,0.5f,1.0f,0.7f) ); @@ -55,7 +55,7 @@ ScreenPrompt::ScreenPrompt( CString sText, PromptType pt, bool* pbAnswer ) m_rectAnswerBox.SetZoomX( m_textAnswer[*m_pbAnswer].GetWidestLineWidthInSourcePixels()+10.0f ); m_rectAnswerBox.SetZoomY( 30 ); m_rectAnswerBox.SetZ(-2); - this->AddActor( &m_rectAnswerBox ); + this->AddSubActor( &m_rectAnswerBox ); m_textAnswer[0].Load( THEME->GetPathTo(FONT_HEADER1) ); m_textAnswer[1].Load( THEME->GetPathTo(FONT_HEADER1) ); @@ -63,8 +63,8 @@ ScreenPrompt::ScreenPrompt( CString sText, PromptType pt, bool* pbAnswer ) m_textAnswer[1].SetY( CENTER_Y+120 ); m_textAnswer[0].SetZ(-2); m_textAnswer[1].SetZ(-2); - this->AddActor( &m_textAnswer[0] ); - this->AddActor( &m_textAnswer[1] ); + this->AddSubActor( &m_textAnswer[0] ); + this->AddSubActor( &m_textAnswer[1] ); diff --git a/stepmania/src/ScreenSandbox.cpp b/stepmania/src/ScreenSandbox.cpp index 872588cdfa..6ab70cc989 100644 --- a/stepmania/src/ScreenSandbox.cpp +++ b/stepmania/src/ScreenSandbox.cpp @@ -16,21 +16,34 @@ #include "ScreenTitleMenu.h" #include "ScreenSelectMusic.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "Quad.h" ScreenSandbox::ScreenSandbox() { - m_text.Load( THEME->GetPathTo(FONT_NORMAL) ); +// m_text.Load( THEME->GetPathTo(FONT_NORMAL) ); m_text.SetXY( CENTER_X, CENTER_Y ); - this->AddActor( &m_text ); + CStringArray as; + as.Add( "Testing... Attention please." ); + m_text.SetTips( as ); + m_text.SetXY( CENTER_X, CENTER_Y ); + this->AddSubActor( &m_text ); + + m_Menu.Load( + THEME->GetPathTo(GRAPHIC_SELECT_STYLE_BACKGROUND), + THEME->GetPathTo(GRAPHIC_SELECT_STYLE_TOP_EDGE), + ssprintf("Use %c %c to select, then press START", char(1), char(2) ), + false, true, 40 + ); + this->AddSubActor( &m_Menu ); + m_Menu.TweenOnScreenFromBlack( SM_None ); m_sound.Load( THEME->GetPathTo(SOUND_MENU_MUSIC) ); m_sound.SetPositionSeconds( -10 ); m_sound.Play(); - //this->AddActor( &m_spr ); + //this->AddSubActor( &m_spr ); } @@ -38,12 +51,13 @@ void ScreenSandbox::Update( float fDeltaTime ) { Screen::Update( fDeltaTime ); m_sound.Update( fDeltaTime ); - m_text.SetText( ssprintf("%f", m_sound.GetPositionSeconds()) ); } void ScreenSandbox::DrawPrimitives() { + m_Menu.DrawBottomLayer(); Screen::DrawPrimitives(); + m_Menu.DrawTopLayer(); } void ScreenSandbox::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) diff --git a/stepmania/src/ScreenSandbox.h b/stepmania/src/ScreenSandbox.h index 1a9186bc4a..a63f3f92f6 100644 --- a/stepmania/src/ScreenSandbox.h +++ b/stepmania/src/ScreenSandbox.h @@ -15,6 +15,7 @@ #include "Quad.h" #include "TransitionStarWipe.h" #include "MenuElements.h" +#include "TipDisplay.h" class ScreenSandbox : public Screen @@ -27,7 +28,8 @@ public: virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); virtual void HandleScreenMessage( const ScreenMessage SM ); - BitmapText m_text; + TipDisplay m_text; + MenuElements m_Menu; RageSoundStream m_sound; }; diff --git a/stepmania/src/ScreenSelectCourse.cpp b/stepmania/src/ScreenSelectCourse.cpp index bef9c26927..fce32e63bd 100644 --- a/stepmania/src/ScreenSelectCourse.cpp +++ b/stepmania/src/ScreenSelectCourse.cpp @@ -19,7 +19,7 @@ #include "RageMusic.h" #include "ScreenTitleMenu.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenGameplay.h" #include "ScreenPrompt.h" #include "ScreenPlayerOptions.h" @@ -28,13 +28,14 @@ #include "InputQueue.h" #include "ScreenStage.h" #include "AnnouncerManager.h" +#include "GameState.h" const float COURSE_INFO_FRAME_X = 160; const float COURSE_INFO_FRAME_Y = SCREEN_TOP+118; const float COURSE_CONTENTS_FRAME_X = 160; -const float COURSE_CONTENTS_FRAME_Y = CENTER_Y+100; +const float COURSE_CONTENTS_FRAME_Y = CENTER_Y+70; const float WHEEL_X = CENTER_X+160; const float WHEEL_Y = CENTER_Y+8; @@ -54,8 +55,8 @@ ScreenSelectCourse::ScreenSelectCourse() LOG->WriteLine( "ScreenSelectCourse::ScreenSelectCourse()" ); // for debugging - if( GAMEMAN->m_CurStyle == STYLE_NONE ) - GAMEMAN->m_CurStyle = STYLE_DANCE_SINGLE; + if( GAMESTATE->m_CurStyle == STYLE_NONE ) + GAMESTATE->m_CurStyle = STYLE_DANCE_SINGLE; m_Menu.Load( THEME->GetPathTo(GRAPHIC_SELECT_COURSE_BACKGROUND), @@ -64,16 +65,16 @@ ScreenSelectCourse::ScreenSelectCourse() char(1), char(2), char(3), char(3), char(4), char(4), char(3), char(4), char(3), char(4) ), false, true, 60 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_CourseInfoFrame.SetXY( COURSE_INFO_FRAME_X, COURSE_INFO_FRAME_Y ); - this->AddActor( &m_CourseInfoFrame ); + this->AddSubActor( &m_CourseInfoFrame ); m_CourseContentsFrame.SetXY( COURSE_CONTENTS_FRAME_X, COURSE_CONTENTS_FRAME_Y ); - this->AddActor( &m_CourseContentsFrame ); + this->AddSubActor( &m_CourseContentsFrame ); m_MusicWheel.SetXY( WHEEL_X, WHEEL_Y ); - this->AddActor( &m_MusicWheel ); + this->AddSubActor( &m_MusicWheel ); m_textHoldForOptions.Load( THEME->GetPathTo(FONT_STAGE) ); m_textHoldForOptions.SetXY( CENTER_X, CENTER_Y ); @@ -82,7 +83,7 @@ ScreenSelectCourse::ScreenSelectCourse() m_textHoldForOptions.SetZoomY( 0 ); m_textHoldForOptions.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); m_textHoldForOptions.SetZ( -2 ); - this->AddActor( &m_textHoldForOptions ); + this->AddSubActor( &m_textHoldForOptions ); m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) ); @@ -222,7 +223,7 @@ void ScreenSelectCourse::MenuStart( const PlayerNumber p ) m_Menu.TweenOffScreenToBlack( SM_None, false ); - SONGMAN->m_pCurCourse = m_MusicWheel.GetSelectedCourse(); + GAMESTATE->m_pCurCourse = m_MusicWheel.GetSelectedCourse(); this->SendScreenMessage( SM_GoToNextState, 2.5f ); diff --git a/stepmania/src/ScreenSelectDifficulty.cpp b/stepmania/src/ScreenSelectDifficulty.cpp index 2be425c227..59179f1267 100644 --- a/stepmania/src/ScreenSelectDifficulty.cpp +++ b/stepmania/src/ScreenSelectDifficulty.cpp @@ -13,7 +13,7 @@ #include "ScreenSelectDifficulty.h" #include "ScreenManager.h" #include "PrefsManager.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenSelectGroup.h" #include "ScreenTitleMenu.h" #include "GameManager.h" @@ -21,6 +21,7 @@ #include "GameConstantsAndTypes.h" #include "AnnouncerManager.h" #include "ScreenSelectCourse.h" +#include "GameState.h" const float MORE_ARROWS_X[NUM_PAGES] = { SCREEN_RIGHT-60, SCREEN_WIDTH + SCREEN_LEFT+60}; @@ -73,7 +74,7 @@ ScreenSelectDifficulty::ScreenSelectDifficulty() LOG->WriteLine( "ScreenSelectDifficulty::ScreenSelectDifficulty()" ); // Reset the current PlayMode - PREFSMAN->m_PlayMode = PLAY_MODE_INVALID; + GAMESTATE->m_PlayMode = PLAY_MODE_INVALID; int p; @@ -84,7 +85,7 @@ ScreenSelectDifficulty::ScreenSelectDifficulty() ssprintf("Use %c %c to select, then press START", char(1), char(2)), false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); for( int d=0; dGetPathTo(te_header) ); m_sprHeader[d].SetXY( DIFFICULTY_ITEM_X[d], DIFFICULTY_ITEM_Y[d] ); m_sprHeader[d].SetVertAlign( align_top ); m_sprHeader[d].TurnShadowOff(); - m_framePages.AddActor( &m_sprHeader[d] ); + m_framePages.AddSubActor( &m_sprHeader[d] ); } for( p=0; pGetPathTo( p==0 ? GRAPHIC_ARROWS_RIGHT : GRAPHIC_ARROWS_LEFT ) ); m_sprMoreArrows[p].SetXY( MORE_ARROWS_X[p], MORE_ARROWS_Y[p] ); - m_framePages.AddActor( &m_sprMoreArrows[p] ); + m_framePages.AddSubActor( &m_sprMoreArrows[p] ); m_sprExplanation[p].Load( THEME->GetPathTo(GRAPHIC_SELECT_DIFFICULTY_EXPLANATION) ); m_sprExplanation[p].SetXY( EXPLANATION_X[p], EXPLANATION_Y[p] ); m_sprExplanation[p].StopAnimating(); m_sprExplanation[p].SetState( p ); - m_framePages.AddActor( &m_sprExplanation[p] ); + m_framePages.AddSubActor( &m_sprExplanation[p] ); } @@ -131,7 +132,7 @@ ScreenSelectDifficulty::ScreenSelectDifficulty() m_iSelection[p] = 1; // Select "medium" m_bChosen[p] = false; - if( !GAMEMAN->IsPlayerEnabled((PlayerNumber)p) ) + if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) ) continue; m_sprArrowShadow[p].Load( THEME->GetPathTo(GRAPHIC_SELECT_DIFFICULTY_ARROWS) ); @@ -139,7 +140,7 @@ ScreenSelectDifficulty::ScreenSelectDifficulty() m_sprArrowShadow[p].SetState( p ); m_sprArrowShadow[p].TurnShadowOff(); m_sprArrowShadow[p].SetDiffuseColor( D3DXCOLOR(0,0,0,0.6f) ); - m_framePages.AddActor( &m_sprArrowShadow[p] ); + m_framePages.AddSubActor( &m_sprArrowShadow[p] ); m_sprArrow[p].Load( THEME->GetPathTo(GRAPHIC_SELECT_DIFFICULTY_ARROWS) ); m_sprArrow[p].StopAnimating(); @@ -147,13 +148,13 @@ ScreenSelectDifficulty::ScreenSelectDifficulty() m_sprArrow[p].TurnShadowOff(); m_sprArrow[p].SetDiffuseColor( PlayerToColor((PlayerNumber)p) ); m_sprArrow[p].SetEffectGlowing(); - m_framePages.AddActor( &m_sprArrow[p] ); + m_framePages.AddSubActor( &m_sprArrow[p] ); m_sprOK[p].Load( THEME->GetPathTo(GRAPHIC_SELECT_DIFFICULTY_OK) ); - m_framePages.AddActor( &m_sprOK[p] ); + m_framePages.AddSubActor( &m_sprOK[p] ); } - this->AddActor( &m_framePages ); + this->AddSubActor( &m_framePages ); m_soundChange.Load( THEME->GetPathTo(SOUND_SELECT_DIFFICULTY_CHANGE) ); m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) ); @@ -216,9 +217,9 @@ void ScreenSelectDifficulty::HandleScreenMessage( const ScreenMessage SM ) for( int p=0; pm_PreferredDifficultyClass[p] = CLASS_EASY; break; - case 1: PREFSMAN->m_PreferredDifficultyClass[p] = CLASS_MEDIUM; break; - case 2: PREFSMAN->m_PreferredDifficultyClass[p] = CLASS_HARD; break; + case 0: GAMESTATE->m_PreferredDifficultyClass[p] = CLASS_EASY; break; + case 1: GAMESTATE->m_PreferredDifficultyClass[p] = CLASS_MEDIUM; break; + case 2: GAMESTATE->m_PreferredDifficultyClass[p] = CLASS_HARD; break; } } @@ -227,12 +228,12 @@ void ScreenSelectDifficulty::HandleScreenMessage( const ScreenMessage SM ) case 0: case 1: case 2: // something on page 1 was chosen - PREFSMAN->m_PlayMode = PLAY_MODE_ARCADE; + GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; SCREENMAN->SetNewScreen( new ScreenSelectGroup ); break; case 3: case 4: - PREFSMAN->m_PlayMode = PLAY_MODE_ONI; + GAMESTATE->m_PlayMode = PLAY_MODE_ONI; SCREENMAN->SetNewScreen( new ScreenSelectCourse ); break; default: @@ -378,7 +379,7 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn ) // check to see if everyone has chosen for( int p=0; pIsPlayerEnabled((PlayerNumber)p) && m_bChosen[p] == false ) + if( GAMESTATE->IsPlayerEnabled((PlayerNumber)p) && m_bChosen[p] == false ) return; } this->SendScreenMessage( SM_StartTweeningOffScreen, 0.7f ); @@ -405,7 +406,7 @@ void ScreenSelectDifficulty::TweenOffScreen() for( p=0; pIsPlayerEnabled((PlayerNumber)p) ) + if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) ) continue; m_sprArrow[p].BeginTweening( 0.3f ); @@ -449,8 +450,6 @@ void ScreenSelectDifficulty::TweenOnScreen() { int p; - m_Menu.TweenOnScreenFromMenu( SM_None ); - for( p=0; pIsPlayerEnabled((PlayerNumber)p) ) + if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) ) continue; int iSelection = m_iSelection[p]; diff --git a/stepmania/src/ScreenSelectGame.cpp b/stepmania/src/ScreenSelectGame.cpp index 9156d31899..dad04fcf19 100644 --- a/stepmania/src/ScreenSelectGame.cpp +++ b/stepmania/src/ScreenSelectGame.cpp @@ -20,11 +20,12 @@ #include "ScreenTitleMenu.h" #include "GameConstantsAndTypes.h" #include "StepMania.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" #include "GameManager.h" -#include "string.h" -#include "AnnouncerManager.h" +#include +#include "GameState.h" +#include "InputMapper.h" enum { @@ -35,7 +36,7 @@ enum { OptionLineData g_SelectGameLines[NUM_SELECT_GAME_LINES] = { - "Game", -1, { "" } + "Game", 0, { "" } }; @@ -66,82 +67,21 @@ ScreenSelectGame::ScreenSelectGame() : void ScreenSelectGame::ImportOptions() { - m_iSelectedOption[0][SG_GAME] = GAMEMAN->m_CurGame; + m_iSelectedOption[0][SG_GAME] = GAMESTATE->GetCurGame(); } void ScreenSelectGame::ExportOptions() { LOG->WriteLine("ScreenSelectGame::ExportOptions()"); + INPUTMAPPER->SaveMappingsToDisk(); // save mappings before switching the game + PREFSMAN->SaveGamePrefsToDisk(); + // Switch the current style to the frist style of the selected game Game game = (Game)m_iSelectedOption[0][SG_GAME]; - switch( game ) - { - case GAME_DANCE: - GAMEMAN->m_CurStyle = STYLE_DANCE_SINGLE; - GAMEMAN->m_CurGame = GAME_DANCE; - ANNOUNCER->SwitchAnnouncer( "default" ); - // Does anyone wanna code something fancy that 'remembers' each - // announcer preference per game type?, I think it would be better than - // resetting the annoncer to a default each time? - // - // - Andy. - break; - case GAME_PUMP: - GAMEMAN->m_CurStyle = STYLE_PUMP_SINGLE; - GAMEMAN->m_CurGame = GAME_PUMP; - ANNOUNCER->SwitchAnnouncer( "default" ); - break; - case GAME_EZ2: - GAMEMAN->m_CurStyle = STYLE_EZ2_SINGLE; - GAMEMAN->m_CurGame = GAME_EZ2; - ANNOUNCER->SwitchAnnouncer( "ez2" ); - break; - default: ASSERT(0); // invalid Game - } - - // Try to switch themes to a theme with the same name as the current game - CStringArray asGameNames; - GAMEMAN->GetGameNames( asGameNames ); - CString sGameName = asGameNames[game]; - THEME->SwitchTheme( sGameName ); - - // THE NEXT FEW LINES OF CODE: - // Figure out all the valid skin names for the game and.... - // Chooses the first one and loads it in - // This is needed because otherwise ALL gametypes will be looking - // for a MAX skin. Ez2dancer MAX? Pump It Up MAX? Not likely. - - // This was stolen from ScreenAppearance Options, if you can do a cleaner - // version PLEASE DO!!! - // - // - Andy. - - CStringArray arraySkinNames; - GAMEMAN->GetSkinNames( arraySkinNames ); - - m_OptionLineData[0].iNumOptions = arraySkinNames.GetSize(); - - for(int i=0; im_sCurrentSkin)==0 ) - { - m_iSelectedOption[0][0] = i; - break; - } - } - if( m_iSelectedOption[0][0] == -1 ) - m_iSelectedOption[0][0] = 0; - - int iSelectedSkin = m_iSelectedOption[0][0]; - CString sNewSkin = m_OptionLineData[0].szOptionsText[iSelectedSkin]; - PREFSMAN->m_sNoteSkin = sNewSkin; - GAMEMAN->m_sCurrentSkin = sNewSkin; - + GAMESTATE->SwitchGame( game ); + PREFSMAN->ReadGamePrefsFromDisk(); + INPUTMAPPER->ReadMappingsFromDisk(); } void ScreenSelectGame::GoToPrevState() diff --git a/stepmania/src/ScreenSelectGroup.cpp b/stepmania/src/ScreenSelectGroup.cpp index ce4c396d1b..b49ec6766b 100644 --- a/stepmania/src/ScreenSelectGroup.cpp +++ b/stepmania/src/ScreenSelectGroup.cpp @@ -14,7 +14,7 @@ #include "ScreenSelectGroup.h" #include "ScreenManager.h" #include "PrefsManager.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenSelectMusic.h" #include "ScreenTitleMenu.h" #include "GameManager.h" @@ -22,6 +22,7 @@ #include "GameConstantsAndTypes.h" #include "SongManager.h" #include "AnnouncerManager.h" +#include "GameState.h" const float GROUP_INFO_FRAME_X = SCREEN_LEFT + 180; @@ -48,11 +49,7 @@ const ScreenMessage SM_StartFadingOut = ScreenMessage(SM_User + 3); ScreenSelectGroup::ScreenSelectGroup() { - LOG->WriteLine( "ScreenSelectGroup::ScreenSelectGroup()" ); - -#define CSKEY(s) GetCrc32ForString(s) // Allows (indirect) use of strings as map keys -#define CSKEY_TYPE unsigned int - + LOG->WriteLine( "ScreenSelectGroup::ScreenSelectGroup()" ); int i; @@ -65,7 +62,7 @@ ScreenSelectGroup::ScreenSelectGroup() // -- dro kulix // m_arrayGroupNames will contain all relevant group names - CMap*, CArray*> + CMap*, CArray*> mapGroupToSongArray; // Will contain all relevant songs { // Let's get local! @@ -87,7 +84,7 @@ ScreenSelectGroup::ScreenSelectGroup() const CString &sCurGroupName = m_arrayGroupNames[i]; SONGMAN->GetSongsInGroup( sCurGroupName, *p_arrayGroupSongs ); - mapGroupToSongArray.SetAt(CSKEY(sCurGroupName), p_arrayGroupSongs); + mapGroupToSongArray.SetAt(GetHashForString(sCurGroupName), p_arrayGroupSongs); } { @@ -97,7 +94,7 @@ ScreenSelectGroup::ScreenSelectGroup() m_arrayGroupNames.InsertAt(0, "ALL MUSIC"); p_arrayGroupSongs->Copy( arrayAllSongs ); - mapGroupToSongArray.SetAt(CSKEY("ALL MUSIC"), p_arrayGroupSongs); + mapGroupToSongArray.SetAt(GetHashForString("ALL MUSIC"), p_arrayGroupSongs); } // Now, create a map of all songs to their support for the current style. @@ -106,8 +103,8 @@ ScreenSelectGroup::ScreenSelectGroup() mapStyleSupport.InitHashTable(arrayAllSongs.GetSize()); // The following loop is functionally identical to one used in MusicWheel - NotesType curNotesType = GAMEMAN->GetCurrentStyleDef()->m_NotesType; - for( i=0; i < arrayAllSongs.GetSize(); i++ ) + NotesType curNotesType = GAMESTATE->GetCurrentStyleDef()->m_NotesType; + for( i=0; i arraySteps; @@ -133,7 +130,7 @@ ScreenSelectGroup::ScreenSelectGroup() int si = 0; - CSKEY_TYPE curKey = CSKEY(m_arrayGroupNames.GetAt(gi)); + int curKey = GetHashForString(m_arrayGroupNames.GetAt(gi)); CArray * p_arrayGroupSongs = 0; mapGroupToSongArray.Lookup(curKey, p_arrayGroupSongs); @@ -195,19 +192,19 @@ ScreenSelectGroup::ScreenSelectGroup() ssprintf("Use %c %c to select, then press START", char(1), char(2)), false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_sprExplanation.Load( THEME->GetPathTo(GRAPHIC_SELECT_GROUP_EXPLANATION) ); m_sprExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y ); - this->AddActor( &m_sprExplanation ); + this->AddSubActor( &m_sprExplanation ); m_GroupInfoFrame.SetXY( GROUP_INFO_FRAME_X, GROUP_INFO_FRAME_Y ); - this->AddActor( &m_GroupInfoFrame ); + this->AddSubActor( &m_GroupInfoFrame ); m_sprContentsHeader.Load( THEME->GetPathTo(GRAPHIC_SELECT_GROUP_CONTENTS_HEADER) ); m_sprContentsHeader.SetVertAlign( Actor::align_top ); m_sprContentsHeader.SetXY( CONTENTS_X, CONTENTS_START_Y ); - this->AddActor( &m_sprContentsHeader ); + this->AddSubActor( &m_sprContentsHeader ); for( i=0; iAddActor( &m_textContents[i] ); + this->AddSubActor( &m_textContents[i] ); } @@ -229,7 +226,7 @@ ScreenSelectGroup::ScreenSelectGroup() m_sprGroupButton[i].Load( THEME->GetPathTo(GRAPHIC_SELECT_GROUP_BUTTON) ); m_sprGroupButton[i].SetXY( BUTTON_X, BUTTON_START_Y + BUTTON_GAP_Y*i ); - this->AddActor( &m_sprGroupButton[i] ); + this->AddSubActor( &m_sprGroupButton[i] ); m_textGroup[i].Load( THEME->GetPathTo(FONT_NORMAL) ); m_textGroup[i].SetXY( BUTTON_X, BUTTON_START_Y + BUTTON_GAP_Y*i ); @@ -240,7 +237,7 @@ ScreenSelectGroup::ScreenSelectGroup() if( i == 0 ) m_textGroup[i].TurnRainbowOn(); else m_textGroup[i].SetDiffuseColor( SONGMAN->GetGroupColor(sGroupName) ); - this->AddActor( &m_textGroup[i] ); + this->AddSubActor( &m_textGroup[i] ); } // @@ -287,7 +284,7 @@ ScreenSelectGroup::ScreenSelectGroup() CArray* p_arraySongs; const CString &sCurGroupName = m_arrayGroupNames[i]; - mapGroupToSongArray.Lookup(CSKEY(sCurGroupName), p_arraySongs); + mapGroupToSongArray.Lookup( GetHashForString(sCurGroupName), p_arraySongs); m_iNumSongsInGroup[i] = p_arraySongs->GetSize(); @@ -329,7 +326,7 @@ ScreenSelectGroup::ScreenSelectGroup() // Deallocate remaining song arrays in map { - CSKEY_TYPE csKey; + int csKey; CArray* pSongArray; POSITION Pos; @@ -342,9 +339,6 @@ ScreenSelectGroup::ScreenSelectGroup() delete pSongArray; } } - -#undef CSKEY_TYPE -#undef CSKEY } @@ -480,10 +474,10 @@ void ScreenSelectGroup::MenuStart( const PlayerNumber p ) m_soundSelect.PlayRandom(); m_bChosen = true; - SONGMAN->SetCurrentSong( NULL ); - SONGMAN->m_sPreferredGroup = m_arrayGroupNames[m_iSelection]; + GAMESTATE->m_pCurSong = NULL; + GAMESTATE->m_sPreferredGroup = m_arrayGroupNames[m_iSelection]; - if( 0 == stricmp(SONGMAN->m_sPreferredGroup, "All Music") ) + if( 0 == stricmp(GAMESTATE->m_sPreferredGroup, "All Music") ) SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_GROUP_COMMENT_ALL_MUSIC) ); else SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_GROUP_COMMENT_GENERAL) ); @@ -543,8 +537,6 @@ void ScreenSelectGroup::TweenOffScreen() void ScreenSelectGroup::TweenOnScreen() { - m_Menu.TweenOnScreenFromMenu( SM_None ); - m_sprExplanation.SetX( EXPLANATION_X-400 ); m_sprExplanation.BeginTweening( 0.5f, TWEEN_BOUNCE_END ); m_sprExplanation.SetTweenX( EXPLANATION_X ); diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 49bfba3d38..28c8894568 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -19,7 +19,7 @@ #include "RageMusic.h" #include "ScreenTitleMenu.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenGameplay.h" #include "ScreenPrompt.h" #include "ScreenPlayerOptions.h" @@ -28,6 +28,8 @@ #include "InputQueue.h" #include "ScreenStage.h" #include "AnnouncerManager.h" +#include "InputMapper.h" +#include "GameState.h" const float SONG_INFO_FRAME_X = 160; @@ -65,50 +67,50 @@ ScreenSelectMusic::ScreenSelectMusic() LOG->WriteLine( "ScreenSelectMusic::ScreenSelectMusic()" ); // for debugging - if( GAMEMAN->m_CurStyle == STYLE_NONE ) - GAMEMAN->m_CurStyle = STYLE_DANCE_SINGLE; + if( GAMESTATE->m_CurStyle == STYLE_NONE ) + GAMESTATE->m_CurStyle = STYLE_DANCE_SINGLE; int p; m_Menu.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_BACKGROUND), THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_TOP_EDGE), - ssprintf("%c or %c change music %c%c easier difficulty %c%c harder difficulty %c%c%c%c change sort", - char(1), char(2), char(3), char(3), char(4), char(4), char(3), char(4), char(3), char(4) ), + ssprintf("%c or %c change music Hold %c and %c then press START to change sort\n%c%c easier difficulty %c%c harder difficulty", + char(1), char(2), char(1), char(2), char(3), char(3), char(4), char(4) ), false, true, 60 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_SongInfoFrame.SetXY( SONG_INFO_FRAME_X, SONG_INFO_FRAME_Y ); - this->AddActor( &m_SongInfoFrame ); + this->AddSubActor( &m_SongInfoFrame ); m_sprDifficultyFrame.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_DIFFICULTY_FRAME) ); m_sprDifficultyFrame.SetXY( DIFFICULTY_X, DIFFICULTY_Y ); - this->AddActor( &m_sprDifficultyFrame ); + this->AddSubActor( &m_sprDifficultyFrame ); for( p=0; pAddActor( &m_DifficultyIcon[p] ); + this->AddSubActor( &m_DifficultyIcon[p] ); } m_GrooveRadar.SetXY( RADAR_X, RADAR_Y ); - this->AddActor( &m_GrooveRadar ); + this->AddSubActor( &m_GrooveRadar ); m_sprMeterFrame.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_METER_FRAME) ); m_sprMeterFrame.SetXY( METER_FRAME_X, METER_FRAME_Y ); - this->AddActor( &m_sprMeterFrame ); + this->AddSubActor( &m_sprMeterFrame ); for( p=0; pGetPathTo(FONT_METER) ); m_FootMeter[p].SetXY( METER_X[p], METER_Y[p] ); m_FootMeter[p].SetShadowLength( 2 ); - this->AddActor( &m_FootMeter[p] ); + this->AddSubActor( &m_FootMeter[p] ); } m_MusicWheel.SetXY( WHEEL_X, WHEEL_Y ); - this->AddActor( &m_MusicWheel ); + this->AddSubActor( &m_MusicWheel ); m_textHoldForOptions.Load( THEME->GetPathTo(FONT_STAGE) ); m_textHoldForOptions.SetXY( CENTER_X, CENTER_Y ); @@ -117,7 +119,7 @@ ScreenSelectMusic::ScreenSelectMusic() m_textHoldForOptions.SetZoomY( 0 ); m_textHoldForOptions.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); m_textHoldForOptions.SetZ( -2 ); - this->AddActor( &m_textHoldForOptions ); + this->AddSubActor( &m_textHoldForOptions ); m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) ); @@ -245,11 +247,6 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, const InputEventType HarderDifficulty( MenuI.player ); return; } - if( INPUTQUEUE->MatchesPattern(MenuI.player, NEXT_SORT_PATTERN, NEXT_SORT_PATTERN_SIZE) ) - { - m_MusicWheel.NextSort(); - return; - } Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler @@ -260,7 +257,7 @@ void ScreenSelectMusic::EasierDifficulty( const PlayerNumber p ) { LOG->WriteLine( "ScreenSelectMusic::EasierDifficulty( %d )", p ); - if( !GAMEMAN->IsPlayerEnabled(p) ) + if( !GAMESTATE->IsPlayerEnabled(p) ) return; if( m_arrayNotes.GetSize() == 0 ) return; @@ -277,7 +274,7 @@ void ScreenSelectMusic::HarderDifficulty( const PlayerNumber p ) { LOG->WriteLine( "ScreenSelectMusic::HarderDifficulty( %d )", p ); - if( !GAMEMAN->IsPlayerEnabled(p) ) + if( !GAMESTATE->IsPlayerEnabled(p) ) return; if( m_arrayNotes.GetSize() == 0 ) return; @@ -338,17 +335,31 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) void ScreenSelectMusic::MenuLeft( const PlayerNumber p, const InputEventType type ) { + if( type >= IET_SLOW_REPEAT && INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_RIGHT) ) ) + return; // ignore + m_MusicWheel.PrevMusic(); } void ScreenSelectMusic::MenuRight( const PlayerNumber p, const InputEventType type ) { + if( type >= IET_SLOW_REPEAT && INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_LEFT) ) ) + return; // ignore + m_MusicWheel.NextMusic(); } void ScreenSelectMusic::MenuStart( const PlayerNumber p ) { + if( INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_LEFT) ) && + INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_RIGHT) ) ) + { + m_MusicWheel.NextSort(); + return; + } + + // this needs to check whether valid Notes are selected! bool bResult = m_MusicWheel.Select(); @@ -369,9 +380,9 @@ void ScreenSelectMusic::MenuStart( const PlayerNumber p ) bool bIsHard = false; for( int p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - if( SONGMAN->GetCurrentNotes((PlayerNumber)p) && SONGMAN->GetCurrentNotes((PlayerNumber)p)->m_iMeter >= 9 ) + if( GAMESTATE->m_pCurNotes[p] && GAMESTATE->m_pCurNotes[p]->m_iMeter >= 9 ) bIsHard = true; } @@ -425,7 +436,7 @@ void ScreenSelectMusic::MenuBack( const PlayerNumber p ) void ScreenSelectMusic::AfterNotesChange( const PlayerNumber p ) { - if( !GAMEMAN->IsPlayerEnabled(p) ) + if( !GAMESTATE->IsPlayerEnabled(p) ) return; m_iSelection[p] = clamp( m_iSelection[p], 0, m_arrayNotes.GetSize()-1 ); // bounds clamping @@ -433,9 +444,9 @@ void ScreenSelectMusic::AfterNotesChange( const PlayerNumber p ) Notes* pNotes = m_arrayNotes.GetSize()>0 ? m_arrayNotes[m_iSelection[p]] : NULL; if( pNotes ) - PREFSMAN->m_PreferredDifficultyClass[p] = pNotes->m_DifficultyClass; + GAMESTATE->m_PreferredDifficultyClass[p] = pNotes->m_DifficultyClass; - SONGMAN->SetCurrentNotes( p, pNotes ); + GAMESTATE->m_pCurNotes[p] = pNotes; m_DifficultyIcon[p].SetFromNotes( pNotes ); m_FootMeter[p].SetFromNotes( pNotes ); @@ -446,7 +457,7 @@ void ScreenSelectMusic::AfterNotesChange( const PlayerNumber p ) void ScreenSelectMusic::AfterMusicChange() { Song* pSong = m_MusicWheel.GetSelectedSong(); - SONGMAN->SetCurrentSong( pSong ); + GAMESTATE->m_pCurSong = pSong; m_arrayNotes.RemoveAll(); @@ -464,15 +475,15 @@ void ScreenSelectMusic::AfterMusicChange() break; case TYPE_SONG: { - pSong->GetNotesThatMatch( GAMEMAN->GetCurrentStyleDef()->m_NotesType, m_arrayNotes ); + pSong->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef()->m_NotesType, m_arrayNotes ); SortNotesArrayByDifficultyClass( m_arrayNotes ); m_SongInfoFrame.SetFromSong( pSong ); for( int p=0; pIsPlayerEnabled( PlayerNumber(p) ) ) + if( !GAMESTATE->IsPlayerEnabled( PlayerNumber(p) ) ) continue; for( int i=0; im_DifficultyClass == PREFSMAN->m_PreferredDifficultyClass[p] ) + if( m_arrayNotes[i]->m_DifficultyClass == GAMESTATE->m_PreferredDifficultyClass[p] ) m_iSelection[p] = i; m_iSelection[p] = clamp( m_iSelection[p], 0, m_arrayNotes.GetSize() ) ; diff --git a/stepmania/src/ScreenSelectStyle.cpp b/stepmania/src/ScreenSelectStyle.cpp index 12b71c8ad6..e7e4a325fb 100644 --- a/stepmania/src/ScreenSelectStyle.cpp +++ b/stepmania/src/ScreenSelectStyle.cpp @@ -18,12 +18,13 @@ #include "ScreenTitleMenu.h" #include "ScreenCaution.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenSelectDifficulty.h" #include "ScreenSandbox.h" #include "GameManager.h" #include "RageLog.h" #include "AnnouncerManager.h" +#include "GameState.h" const float ICONS_START_X = SCREEN_LEFT + 60; @@ -50,13 +51,13 @@ ScreenSelectStyle::ScreenSelectStyle() // Reset the current style and game - GAMEMAN->m_CurStyle = STYLE_NONE; + GAMESTATE->m_CurStyle = STYLE_NONE; for( int s=0; sm_CurGame ) // games match + if( StyleToGame(style) == GAMESTATE->GetCurGame() ) // games match m_aPossibleStyles.Add( style ); } @@ -69,18 +70,18 @@ ScreenSelectStyle::ScreenSelectStyle() m_sprIcon[i].StopAnimating(); m_sprIcon[i].SetState( style ); m_sprIcon[i].SetXY( ICONS_START_X + ICONS_SPACING_X*i, ICON_Y ); - this->AddActor( &m_sprIcon[i] ); + this->AddSubActor( &m_sprIcon[i] ); } m_sprExplanation.Load( THEME->GetPathTo(GRAPHIC_SELECT_STYLE_EXPLANATION) ); m_sprExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y ); - this->AddActor( &m_sprExplanation ); + this->AddSubActor( &m_sprExplanation ); m_sprPreview.SetXY( PREVIEW_X, PREVIEW_Y ); - this->AddActor( &m_sprPreview ); + this->AddSubActor( &m_sprPreview ); m_sprInfo.SetXY( INFO_X, INFO_Y ); - this->AddActor( &m_sprInfo ); + this->AddSubActor( &m_sprInfo ); // Load dummy Sprites @@ -102,7 +103,7 @@ ScreenSelectStyle::ScreenSelectStyle() ssprintf("Use %c %c to select, then press START", char(1), char(2) ), false, true, 40 ); - this->AddActor( &m_Menu ); + this->AddSubActor( &m_Menu ); m_soundChange.Load( THEME->GetPathTo(SOUND_SELECT_STYLE_CHANGE) ); m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) ); @@ -232,11 +233,11 @@ void ScreenSelectStyle::MenuRight( const PlayerNumber p ) void ScreenSelectStyle::MenuStart( const PlayerNumber p ) { if( p != PLAYER_INVALID ) - GAMEMAN->m_sMasterPlayerNumber = p; - GAMEMAN->m_CurStyle = GetSelectedStyle(); + GAMESTATE->m_MasterPlayerNumber = p; + GAMESTATE->m_CurStyle = GetSelectedStyle(); AnnouncerElement ae; - switch( GAMEMAN->m_CurStyle ) + switch( GAMESTATE->m_CurStyle ) { case STYLE_DANCE_SINGLE: ae = ANNOUNCER_SELECT_STYLE_COMMENT_SINGLE; break; case STYLE_DANCE_VERSUS: ae = ANNOUNCER_SELECT_STYLE_COMMENT_VERSUS; break; diff --git a/stepmania/src/ScreenSongOptions.cpp b/stepmania/src/ScreenSongOptions.cpp index 1d81cb4421..fb34ad947e 100644 --- a/stepmania/src/ScreenSongOptions.cpp +++ b/stepmania/src/ScreenSongOptions.cpp @@ -20,13 +20,14 @@ #include "GameConstantsAndTypes.h" #include "ScreenPlayerOptions.h" #include "RageLog.h" +#include "GameState.h" OptionLineData g_SongOptionsLines[] = { { "Fail", 3, {"ARCADE","END OF SONG","OFF"} }, { "Assist", 2, {"OFF","TICK"} }, - { "Rate", 7, {"70%","80%","90%","100%","110%","120%","130%"} }, + { "Rate", 9, {"x0.5","x0.7","x0.8","x0.9","x1.0","x1.1","x1.2","x1.3","x1.5"} }, { "Bars", 2, {"OFF","ON"} }, }; const int NUM_SONG_OPTIONS_LINES = sizeof(g_SongOptionsLines)/sizeof(OptionLineData); @@ -56,37 +57,41 @@ ScreenSongOptions::ScreenSongOptions() : void ScreenSongOptions::ImportOptions() { - SongOptions &so = PREFSMAN->m_SongOptions; + SongOptions &so = GAMESTATE->m_SongOptions; m_iSelectedOption[0][SO_FAIL] = so.m_FailType; m_iSelectedOption[0][SO_ASSIST] = so.m_AssistType; - if( so.m_fMusicRate == 0.70f ) m_iSelectedOption[0][SO_RATE] = 0; - else if( so.m_fMusicRate == 0.80f ) m_iSelectedOption[0][SO_RATE] = 1; - else if( so.m_fMusicRate == 0.90f ) m_iSelectedOption[0][SO_RATE] = 2; - else if( so.m_fMusicRate == 1.00f ) m_iSelectedOption[0][SO_RATE] = 3; - else if( so.m_fMusicRate == 1.10f ) m_iSelectedOption[0][SO_RATE] = 4; - else if( so.m_fMusicRate == 1.20f ) m_iSelectedOption[0][SO_RATE] = 5; - else if( so.m_fMusicRate == 1.30f ) m_iSelectedOption[0][SO_RATE] = 6; - else m_iSelectedOption[0][SO_RATE] = 3; + if( so.m_fMusicRate == 0.5f ) m_iSelectedOption[0][SO_RATE] = 0; + else if( so.m_fMusicRate == 0.7f ) m_iSelectedOption[0][SO_RATE] = 1; + else if( so.m_fMusicRate == 0.8f ) m_iSelectedOption[0][SO_RATE] = 2; + else if( so.m_fMusicRate == 0.9f ) m_iSelectedOption[0][SO_RATE] = 3; + else if( so.m_fMusicRate == 1.0f ) m_iSelectedOption[0][SO_RATE] = 4; + else if( so.m_fMusicRate == 1.1f ) m_iSelectedOption[0][SO_RATE] = 5; + else if( so.m_fMusicRate == 1.2f ) m_iSelectedOption[0][SO_RATE] = 6; + else if( so.m_fMusicRate == 1.3f ) m_iSelectedOption[0][SO_RATE] = 7; + else if( so.m_fMusicRate == 1.5f ) m_iSelectedOption[0][SO_RATE] = 8; + else m_iSelectedOption[0][SO_RATE] = 4; } void ScreenSongOptions::ExportOptions() { - SongOptions &so = PREFSMAN->m_SongOptions; + SongOptions &so = GAMESTATE->m_SongOptions; so.m_FailType = (SongOptions::FailType)m_iSelectedOption[0][SO_FAIL]; so.m_AssistType = (SongOptions::AssistType)m_iSelectedOption[0][SO_ASSIST]; switch( m_iSelectedOption[0][SO_RATE] ) { - case 0: so.m_fMusicRate = 0.70f; break; - case 1: so.m_fMusicRate = 0.80f; break; - case 2: so.m_fMusicRate = 0.90f; break; - case 3: so.m_fMusicRate = 1.00f; break; - case 4: so.m_fMusicRate = 1.10f; break; - case 5: so.m_fMusicRate = 1.20f; break; - case 6: so.m_fMusicRate = 1.30f; break; + case 0: so.m_fMusicRate = 0.5f; break; + case 1: so.m_fMusicRate = 0.7f; break; + case 2: so.m_fMusicRate = 0.8f; break; + case 3: so.m_fMusicRate = 0.9f; break; + case 4: so.m_fMusicRate = 1.0f; break; + case 5: so.m_fMusicRate = 1.1f; break; + case 6: so.m_fMusicRate = 1.2f; break; + case 7: so.m_fMusicRate = 1.3f; break; + case 8: so.m_fMusicRate = 1.5f; break; default: ASSERT( false ); } } diff --git a/stepmania/src/ScreenStage.cpp b/stepmania/src/ScreenStage.cpp index 4419e17857..b8d5b6ad2a 100644 --- a/stepmania/src/ScreenStage.cpp +++ b/stepmania/src/ScreenStage.cpp @@ -13,7 +13,7 @@ #include "ScreenStage.h" #include "ScreenManager.h" #include "PrefsManager.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "RageLog.h" #include "GameConstantsAndTypes.h" #include "BitmapText.h" @@ -24,6 +24,8 @@ #include "SongManager.h" #include "Sprite.h" #include "AnnouncerManager.h" +#include "GameState.h" + const ScreenMessage SM_StartFadingOut = ScreenMessage(SM_User + 1); const ScreenMessage SM_DoneFadingIn = ScreenMessage(SM_User + 2); @@ -37,19 +39,25 @@ ScreenStage::ScreenStage() m_textStage.Load( THEME->GetPathTo(FONT_STAGE) ); m_textStage.TurnShadowOff(); - if( PREFSMAN->IsExtraStage() ) + if( GAMESTATE->m_PlayMode == PLAY_MODE_ONI ) + { + m_textStage.SetText( "Challenge Mode" ); + m_textStage.SetDiffuseColor( D3DXCOLOR(0.8f,0.8f,1,1) ); // light blue + SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_STAGE_CHALLENGE) ); + } + else if( GAMESTATE->IsExtraStage() ) { m_textStage.SetText( "Extra Stage" ); m_textStage.SetDiffuseColor( D3DXCOLOR(1,0.1f,0.1f,1) ); // red SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_STAGE_EXTRA) ); } - else if( PREFSMAN->IsExtraStage2() ) + else if( GAMESTATE->IsExtraStage2() ) { - m_textStage.SetText( "Extra Stage 2" ); // red + m_textStage.SetText( "Another Extra Stage" ); // red m_textStage.SetDiffuseColor( D3DXCOLOR(1,0.1f,0.1f,1) ); - SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_STAGE_EXTRA) ); + SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_STAGE_ANOTHER_EXTRA) ); } - else if( PREFSMAN->IsFinalStage() ) + else if( GAMESTATE->IsFinalStage() ) { m_textStage.SetText( "Final Stage" ); m_textStage.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); @@ -57,10 +65,10 @@ ScreenStage::ScreenStage() } else { - m_textStage.SetText( PREFSMAN->GetStageText() + " Stage" ); + m_textStage.SetText( GAMESTATE->GetStageText() + " Stage" ); m_textStage.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); - const int iStageNo = PREFSMAN->GetStageIndex()+1; + const int iStageNo = GAMESTATE->GetStageIndex()+1; switch( iStageNo ) { case 1: SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_STAGE_1) ); break; @@ -80,7 +88,7 @@ ScreenStage::ScreenStage() m_textStage.BeginTweening( 0.5f ); m_textStage.SetTweenZoom( 2 ); m_textStage.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,1) ); - this->AddActor( &m_textStage ); + this->AddSubActor( &m_textStage ); this->SendScreenMessage( SM_DoneFadingIn, 0.6f ); this->SendScreenMessage( SM_StartFadingOut, 1.2f ); diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index fb7e781ee9..a60df8beea 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -19,7 +19,7 @@ #include "GameConstantsAndTypes.h" #include "RageUtil.h" #include "StepMania.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "ScreenEditMenu.h" #include "ScreenSelectStyle.h" #include "ScreenSelectGame.h" @@ -28,7 +28,7 @@ #include "SongManager.h" #include "AnnouncerManager.h" #include "ScreenEz2SelectPlayer.h" - +#include "GameState.h" #include "GameManager.h" @@ -71,10 +71,10 @@ ScreenTitleMenu::ScreenTitleMenu() // reset game info -// GAMEMAN->m_sMasterPlayerNumber = PLAYER_INVALID; -// GAMEMAN->m_CurGame = GAME_INVALID; -// GAMEMAN->m_CurGame = GAME_INVALID; - + GAMESTATE->SwitchGame( GAMESTATE->GetCurGame() ); + GAMESTATE->Reset(); + PREFSMAN->ReadGamePrefsFromDisk(); + INPUTMAPPER->ReadMappingsFromDisk(); int i; @@ -82,7 +82,7 @@ ScreenTitleMenu::ScreenTitleMenu() m_sprBG.StretchTo( CRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT) ); m_sprBG.SetDiffuseColor( D3DXCOLOR(0.6f,0.6f,0.6f,1) ); m_sprBG.TurnShadowOff(); - this->AddActor( &m_sprBG ); + this->AddSubActor( &m_sprBG ); m_sprLogo.Load( THEME->GetPathTo(GRAPHIC_TITLE_MENU_LOGO) ); m_sprLogo.SetXY( CENTER_X, CENTER_Y ); @@ -92,7 +92,7 @@ ScreenTitleMenu::ScreenTitleMenu() m_sprLogo.BeginTweeningQueued( 0.5f, Actor::TWEEN_BOUNCE_END ); m_sprLogo.SetEffectGlowing(1, D3DXCOLOR(1,1,1,0.1f), D3DXCOLOR(1,1,1,0.3f) ); m_sprLogo.SetTweenZoom( 1 ); - this->AddActor( &m_sprLogo ); + this->AddSubActor( &m_sprLogo ); m_textHelp.Load( THEME->GetPathTo(FONT_NORMAL) ); m_textHelp.SetText( ssprintf("Use %c %c to select, then press START", char(3), char(4)) ); @@ -100,7 +100,7 @@ ScreenTitleMenu::ScreenTitleMenu() m_textHelp.SetZoom( 0.5f ); m_textHelp.SetEffectBlinking(); m_textHelp.SetShadowLength( 2 ); - this->AddActor( &m_textHelp ); + this->AddSubActor( &m_textHelp ); m_textVersion.Load( THEME->GetPathTo(FONT_NORMAL) ); @@ -109,7 +109,7 @@ ScreenTitleMenu::ScreenTitleMenu() m_textVersion.SetDiffuseColor( D3DXCOLOR(0.6f,0.6f,0.6f,1) ); // light gray m_textVersion.SetXY( SCREEN_RIGHT-16, SCREEN_BOTTOM-20 ); m_textVersion.SetZoom( 0.5f ); - this->AddActor( &m_textVersion ); + this->AddSubActor( &m_textVersion ); m_textSongs.Load( THEME->GetPathTo(FONT_NORMAL) ); @@ -118,7 +118,7 @@ ScreenTitleMenu::ScreenTitleMenu() m_textSongs.SetDiffuseColor( D3DXCOLOR(0.6f,0.6f,0.6f,1) ); // light gray m_textSongs.SetXY( SCREEN_LEFT+16, SCREEN_HEIGHT-20 ); m_textSongs.SetZoom( 0.5f ); - this->AddActor( &m_textSongs ); + this->AddSubActor( &m_textSongs ); for( i=0; i< NUM_TITLE_MENU_CHOICES; i++ ) @@ -127,14 +127,18 @@ ScreenTitleMenu::ScreenTitleMenu() m_textChoice[i].SetText( CHOICE_TEXT[i] ); m_textChoice[i].SetXY( CENTER_X, CHOICES_START_Y + i*CHOICES_GAP_Y ); m_textChoice[i].SetShadowLength( 5 ); - this->AddActor( &m_textChoice[i] ); + this->AddSubActor( &m_textChoice[i] ); } m_Fade.SetClosed(); m_Fade.OpenWipingRight( SM_DoneOpening ); - this->AddActor( &m_Fade ); + this->AddSubActor( &m_Fade ); + /* + + // Chris: + // I'm removing thos not that announcer prefs are saved per Game. // LEAVE THIS HERE! ITS ESSENTIAL // I know you're a fan of removing my code, but if this isn't here @@ -143,6 +147,11 @@ ScreenTitleMenu::ScreenTitleMenu() // so just leave it yeah? // I don't wanna fix this a 3rd TIME!! // - Andy. + + if( GAMESTATE->GetCurGame() != GAME_EZ2 ) + PREFSMAN->m_sAnnouncer = ""; + + // if (GAMEMAN->m_CurGame != GAME_EZ2) //{ // ANNOUNCER->SwitchAnnouncer( "default" ); @@ -176,15 +185,17 @@ ScreenTitleMenu::ScreenTitleMenu() static int announcercheck=0; - if (GAMEMAN->m_CurGame != GAME_EZ2 && PREFSMAN->m_sAnnouncer == "ez2" && announcercheck == 0) + if( GAMESTATE->GetCurGame() != GAME_EZ2 && PREFSMAN->m_sAnnouncer == "ez2" && announcercheck == 0) { ANNOUNCER->SwitchAnnouncer( "default" ); announcercheck = 1; } + */ SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_TITLE_MENU_GAME_NAME) ); + m_soundAttract.Load( ANNOUNCER->GetPathTo(ANNOUNCER_TITLE_MENU_ATTRACT) ); m_soundChange.Load( THEME->GetPathTo(SOUND_TITLE_MENU_CHANGE) ); m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) ); @@ -305,12 +316,12 @@ void ScreenTitleMenu::MenuDown( const PlayerNumber p ) void ScreenTitleMenu::MenuStart( const PlayerNumber p ) { - GAMEMAN->m_sMasterPlayerNumber = p; + GAMESTATE->m_MasterPlayerNumber = p; switch( m_TitleMenuChoice ) { case CHOICE_GAME_START: - if ( GAMEMAN->m_CurGame == GAME_EZ2 ) + if( GAMESTATE->GetCurGame() == GAME_EZ2 ) { m_soundSelect.PlayRandom(); m_Fade.CloseWipingRight( SM_GoToEz2 ); diff --git a/stepmania/src/ScrollBar.cpp b/stepmania/src/ScrollBar.cpp index f89fd29a1b..e91fac5df7 100644 --- a/stepmania/src/ScrollBar.cpp +++ b/stepmania/src/ScrollBar.cpp @@ -11,7 +11,7 @@ */ #include "ScrollBar.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #include "GameConstantsAndTypes.h" @@ -21,27 +21,27 @@ ScrollBar::ScrollBar() { m_sprBackground.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_SCROLLBAR) ); m_sprBackground.StopAnimating(); - m_sprBackground.SetState( 2 ); + m_sprBackground.SetState( 1 ); m_sprBackground.SetZoomY( BAR_HEIGHT/m_sprBackground.GetUnzoomedHeight() ); - this->AddActor( &m_sprBackground ); + this->AddSubActor( &m_sprBackground ); m_sprTopButton.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_SCROLLBAR) ); m_sprTopButton.StopAnimating(); m_sprTopButton.SetState( 0 ); m_sprTopButton.SetY( -BAR_HEIGHT/2 ); - this->AddActor( &m_sprTopButton ); + this->AddSubActor( &m_sprTopButton ); m_sprBottomButton.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_SCROLLBAR) ); m_sprBottomButton.StopAnimating(); - m_sprBottomButton.SetState( 3 ); + m_sprBottomButton.SetState( 2 ); m_sprBottomButton.SetY( BAR_HEIGHT/2 ); - this->AddActor( &m_sprBottomButton ); + this->AddSubActor( &m_sprBottomButton ); m_sprScrollThumb.Load( THEME->GetPathTo(GRAPHIC_SELECT_MUSIC_SCROLLBAR) ); m_sprScrollThumb.StopAnimating(); - m_sprScrollThumb.SetState( 1 ); + m_sprScrollThumb.SetState( 3 ); m_sprScrollThumb.SetY( CENTER_Y ); - this->AddActor( &m_sprScrollThumb ); + this->AddSubActor( &m_sprScrollThumb ); } void ScrollBar::SetPercentage( float fPercentageFromTop ) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 95dd41ef86..90615c11b0 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -17,9 +17,10 @@ #include "IniFile.h" #include "Song.h" #include "NoteData.h" +#include "MsdFile.h" -const int FILE_CACHE_VERSION = 43; // increment this to force a cache reload (useful when the SM file format changes) +const int FILE_CACHE_VERSION = 45; // increment this to force a cache reload (useful when the SM file format changes) int CompareBPMSegments(const void *arg1, const void *arg2) @@ -309,7 +310,7 @@ bool Song::LoadFromSongDir( CString sDir ) { if( !DoesFileExist(GetCacheFilePath()) ) goto load_without_cache; - LoadFromSMFile( GetCacheFilePath() ); // don't load NoteData + LoadFromSMFile( GetCacheFilePath() ); LOG->WriteLine( "Loading '%s' from cache file '%s'.", m_sSongDir, GetCacheFilePath() ); return true; @@ -822,105 +823,68 @@ bool Song::LoadFromSMFile( CString sPath ) m_sGroupName = sDirectoryParts[1]; - CStdioFile file; - if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Error opening SM file '%s'.", sPath ); + MsdFile msd; + bool bResult = msd.ReadFile( sPath ); - - // read the whole file into a sFileText - CString sFileText; - CString buffer; - while( file.ReadString(buffer) ) - sFileText += buffer + "\n"; - file.Close(); - - // strip comments out of sFileText - while( sFileText.Find("//") != -1 ) + for( i=0; im_NotesType == StringToNotesType(arrayValueTokens[1]) && - m_apNotes[j]->m_sDescription == arrayValueTokens[2] ) - pNewNotes = m_apNotes[j]; + Notes* pNewNotes = new Notes; + ASSERT( pNewNotes ); + m_apNotes.Add( pNewNotes ); - if( pNewNotes == NULL ) // we didn't find a match that was already loaded - { - pNewNotes = new Notes; - m_apNotes.Add( pNewNotes ); - } - - if( arrayValueTokens.GetSize() != 7 ) - throw RageException( "The song file '%s' is has %d fields in a #NOTES tag, but should have %d.", sPath, arrayValueTokens.GetSize(), 7 ); + if( iNumParams != 7 ) + throw RageException( "The song file '%s' is has %d fields in a #NOTES tag, but should have %d.", sPath, iNumParams, 7 ); pNewNotes->LoadFromSMTokens( - arrayValueTokens[1], - arrayValueTokens[2], - arrayValueTokens[3], - arrayValueTokens[4], - arrayValueTokens[5], - arrayValueTokens[6] + sParams[1], + sParams[2], + sParams[3], + sParams[4], + sParams[5], + sParams[6] ); } @@ -1103,13 +1058,13 @@ void Song::TidyUpData() { // Skip any image that we've already classified - if( HasBanner() && stricmp(GetBannerPath(), arrayImages[i])==0 ) + if( HasBanner() && stricmp(m_sBannerFile, arrayImages[i])==0 ) continue; // skip - if( HasBackground() && stricmp(GetBackgroundPath(), arrayImages[i])==0 ) + if( HasBackground() && stricmp(m_sBackgroundFile, arrayImages[i])==0 ) continue; // skip - if( HasCDTitle() && stricmp(GetCDTitlePath(), arrayImages[i])==0 ) + if( HasCDTitle() && stricmp(m_sCDTitleFile, arrayImages[i])==0 ) continue; // skip D3DXIMAGE_INFO ddii; @@ -1120,12 +1075,12 @@ void Song::TidyUpData() m_sBackgroundFile = arrayImages[i]; continue; } - if( !HasBanner() && 100 < ddii.Width && ddii.Width < 320 && 64 < ddii.Height && ddii.Height < 240 ) + if( !HasBanner() && 100 < ddii.Width && ddii.Width < 320 && 50 < ddii.Height && ddii.Height < 240 ) { m_sBannerFile = arrayImages[i]; continue; } - if( !HasCDTitle() && ddii.Width <= 100 && ddii.Height <= 64 ) + if( !HasCDTitle() && ddii.Width <= 100 && ddii.Height <= 50 ) { m_sCDTitleFile = arrayImages[i]; continue; diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index f82badbefa..7aa7a32aad 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -15,6 +15,7 @@ #include "IniFile.h" #include "RageLog.h" +#include "GameState.h" #include "PrefsManager.h" SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program @@ -23,7 +24,7 @@ SongManager* SONGMAN = NULL; // global and accessable from anywhere in our progr const CString g_sStatisticsFileName = "statistics.ini"; D3DXCOLOR GROUP_COLORS[] = { - D3DXCOLOR( 0.9f, 0.0f, 0.2f, 1 ), // red +// D3DXCOLOR( 0.9f, 0.0f, 0.2f, 1 ), // red D3DXCOLOR( 0.7f, 0.0f, 0.5f, 1 ), // pink D3DXCOLOR( 0.4f, 0.2f, 0.6f, 1 ), // purple D3DXCOLOR( 0.0f, 0.4f, 0.8f, 1 ), // sky blue @@ -34,20 +35,14 @@ D3DXCOLOR GROUP_COLORS[] = { const int NUM_GROUP_COLORS = sizeof(GROUP_COLORS) / sizeof(D3DXCOLOR); -SongManager::SongManager() +SongManager::SongManager( void(*callback)() ) { - m_pCurSong = NULL; - for( int p=0; pm_bAutoPlay ) // BUG FIX: Stats will no longer save if you're in autoplay mode - Andy. @@ -58,38 +53,12 @@ SongManager::~SongManager() } -Song* SongManager::GetCurrentSong() +void SongManager::InitSongArrayFromDisk( void(*callback)() ) { - return m_pCurSong; -} - -Notes* SongManager::GetCurrentNotes( PlayerNumber p ) -{ - return m_pCurNotes[p]; -} - -void SongManager::SetCurrentSong( Song* pSong ) -{ - m_pCurSong = pSong; -} - -void SongManager::SetCurrentNotes( PlayerNumber p, Notes* pNotes ) -{ - m_pCurNotes[p] = pNotes; -} - -GameplayStatistics SongManager::GetLatestGameplayStatistics( PlayerNumber p ) -{ - ASSERT( m_aGameplayStatistics[p].GetSize() > 0 ); - return m_aGameplayStatistics[p][ m_aGameplayStatistics[p].GetSize()-1 ]; -} - -void SongManager::InitSongArrayFromDisk() -{ - LoadStepManiaSongDir( "Songs" ); + LoadStepManiaSongDir( "Songs", callback ); for( int i=0; im_asSongFolders.GetSize(); i++ ) - LoadStepManiaSongDir( PREFSMAN->m_asSongFolders[i] ); + LoadStepManiaSongDir( PREFSMAN->m_asSongFolders[i], callback ); // compute group names CArray arraySongs; @@ -108,7 +77,7 @@ void SongManager::InitSongArrayFromDisk() LOG->WriteLine( "Found %d Songs.", m_pSongs.GetSize() ); } -void SongManager::LoadStepManiaSongDir( CString sDir ) +void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() ) { // trim off the trailing slash if any sDir.TrimRight( "/\\" ); @@ -132,8 +101,10 @@ void SongManager::LoadStepManiaSongDir( CString sDir ) GetDirListing( ssprintf("%s\\%s\\*.wav", sDir, sGroupDirName), arrayFiles ); if( arrayFiles.GetSize() > 0 ) throw RageException( - ssprintf( "The song folder '%s' must be placed inside of a group folder.\n\n" - "All song folders must be placed below a group folder. For example, 'Songs\\DDR 4th Mix\\B4U'. See the StepMania readme for more info.", + ssprintf( "The folder '%s' contains music files.\n\n" + "This probably means that you have a song outside of a group folder.\n" + "All song folders must reside in a group folder. For example, 'Songs\\DDR 4th Mix\\B4U'.\n" + "See the StepMania readme for more info.", ssprintf("%s\\%s", sDir, sGroupDirName ) ) ); @@ -162,11 +133,17 @@ void SongManager::LoadStepManiaSongDir( CString sDir ) continue; // ignore it // this is a song directory. Load a new song! + GAMESTATE->m_sLoadingMessage = ssprintf("Loading songs...\n%s\n\n%s", sGroupDirName, sSongDirName); + if( callback ) + callback(); Song* pNewSong = new Song; pNewSong->LoadFromSongDir( ssprintf("%s\\%s\\%s", sDir, sGroupDirName, sSongDirName) ); m_pSongs.Add( pNewSong ); } } + GAMESTATE->m_sLoadingMessage = "Done loading songs."; + if( callback ) + callback(); } @@ -237,7 +214,7 @@ void SongManager::FreeSongArray() void SongManager::ReloadSongArray() { - InitSongArrayFromDisk(); + InitSongArrayFromDisk( NULL ); FreeSongArray(); } @@ -254,24 +231,22 @@ void SongManager::ReadStatisticsFromDisk() // load song statistics - CMapStringToString* pKey = ini.GetKeyPointer( "Statistics" ); + IniFile::key* pKey = ini.GetKey( "Statistics" ); if( pKey ) { - for( POSITION pos = pKey->GetStartPosition(); pos != NULL; ) + for( int i=0; inames.GetSize(); i++ ) { - CString name_string, value_string; - - pKey->GetNextAssoc( pos, name_string, value_string ); + CString name = pKey->names[i]; + CString value = pKey->values[i]; // Each value has the format "SongName::StepsName=TimesPlayed::TopGrade::TopScore::MaxCombo". - char szSongDir[256]; char szNotesName[256]; int iRetVal; int i; // Parse for Song name and Notes name - iRetVal = sscanf( name_string, "%[^:]::%[^\n]", szSongDir, szNotesName ); + iRetVal = sscanf( name, "%[^:]::%[^\n]", szSongDir, szNotesName ); if( iRetVal != 2 ) continue; // this line doesn't match what is expected @@ -308,7 +283,7 @@ void SongManager::ReadStatisticsFromDisk() char szGradeLetters[10]; // longest possible string is "AAA" iRetVal = sscanf( - value_string, + value, "%d::%[^:]::%d::%d", &pNotes->m_iNumTimesPlayed, szGradeLetters, @@ -430,28 +405,13 @@ void SongManager::InitCoursesFromDisk() for( int g=0; gShortenGroupName( sGroupName ); + CArray apGroupSongs; + GetSongsInGroup( sGroupName, apGroupSongs ); - CArray apSongs; - this->GetSongsInGroup( sGroupName, apSongs ); - - - for( DifficultyClass dc=CLASS_MEDIUM; dc<=CLASS_HARD; dc=DifficultyClass(dc+1) ) // foreach DifficultyClass + for( DifficultyClass dc=CLASS_EASY; dc<=CLASS_HARD; dc=DifficultyClass(dc+1) ) // foreach DifficultyClass { Course course; - course.m_sName = sShortGroupName + " "; - switch( dc ) - { - case CLASS_EASY: course.m_sName += "Easy"; break; - case CLASS_MEDIUM: course.m_sName += "Medium"; break; - case CLASS_HARD: course.m_sName += "Hard"; break; - } - - for( int s=0; s 0 ) m_aCourses.Add( course ); diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index bf112cd7ea..269f66cf0d 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -22,31 +22,15 @@ const int MAX_SONG_QUEUE_SIZE = 400; // this has to be gigantic to fit an "endle class SongManager { public: - SongManager(); + SongManager( void(*callback)() ); ~SongManager(); - Song* m_pCurSong; - Notes* m_pCurNotes[NUM_PLAYERS]; - Course* m_pCurCourse; - CString m_sPreferredGroup; - - CArray m_aGameplayStatistics[NUM_PLAYERS]; // for passing from Dancing to Results - - CArray m_pSongs; // all songs that can be played - void InitSongArrayFromDisk(); + void InitSongArrayFromDisk( void(*callback)() ); void FreeSongArray(); void ReloadSongArray(); - - Song* GetCurrentSong(); - Notes* GetCurrentNotes( PlayerNumber p ); - void SetCurrentSong( Song* pSong ); - void SetCurrentNotes( PlayerNumber p, Notes* pNotes ); - GameplayStatistics GetLatestGameplayStatistics( PlayerNumber p ); - - void ReadStatisticsFromDisk(); void SaveStatisticsToDisk(); @@ -55,7 +39,7 @@ public: void GetGroupNames( CStringArray &AddTo ); D3DXCOLOR GetGroupColor( const CString &sGroupName ); - CString ShortenGroupName( const CString &sOrigGroupName ); + static CString ShortenGroupName( const CString &sOrigGroupName ); void GetSongsInGroup( const CString sGroupName, CArray &AddTo ); @@ -68,7 +52,7 @@ public: protected: - void LoadStepManiaSongDir( CString sDir ); + void LoadStepManiaSongDir( CString sDir, void(*callback)() ); void LoadDWISongDir( CString sDir ); CMapStringToString m_mapGroupToBannerPath; // each song group has a banner associated with it CStringArray m_arrayGroupNames; diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index ba073ef07e..0c66bca664 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -94,11 +94,8 @@ bool Sprite::LoadFromSpriteFile( CString sSpritePath, bool bForceReload, int iMi // overwriting the states that LoadFromTexture created. for( UINT i=0; im_bHighDetail ) // 640x480 - DISPLAY->TranslateLocal( -0.5f, -0.5f, 0 ); - else // 320x240 - DISPLAY->TranslateLocal( -0.5f, -0.5f, 0 ); -// DISPLAY->TranslateLocal( -1, -1, 0 ); // offset so that pixels are aligned to texels + DISPLAY->TranslateLocal( -0.5f, -0.5f, 0 ); if( m_pTexture == NULL ) return; diff --git a/stepmania/src/StdAfx.h b/stepmania/src/StdAfx.h index 2bab90d51e..c8d7287903 100644 --- a/stepmania/src/StdAfx.h +++ b/stepmania/src/StdAfx.h @@ -5,6 +5,7 @@ Desc: Include file for standard system include files. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 19adda80ba..7e0c387b7d 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -3,9 +3,10 @@ ----------------------------------------------------------------------------- File: StepMania.cpp - Desc: + Desc: Entry point for program. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ @@ -19,7 +20,8 @@ // #include "PrefsManager.h" #include "SongManager.h" -#include "ThemeManager.h" +#include "PrefsManager.h" +#include "GameState.h" #include "AnnouncerManager.h" #include "ScreenManager.h" #include "GameManager.h" @@ -42,17 +44,12 @@ #include "ScreenSandbox.h" -#include "ScreenEvaluation.h" #include "ScreenTitleMenu.h" -#include "ScreenPlayerOptions.h" -#include "ScreenMusicScroll.h" -#include "ScreenSelectMusic.h" -#include "ScreenGameplay.h" -#include "ScreenSelectDifficulty.h" +#include "ScreenLoading.h" #include "dxerr8.h" -#include +//#include //----------------------------------------------------------------------------- // Links @@ -165,6 +162,33 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) SetCurrentDirectory( szFullAppPath ); } + // + // Check for packages in the AutoInstall folder + // + CStringArray asPackagePaths; + GetDirListing( "AutoInstall\\*.smzip", asPackagePaths, false, true ); + for( int i=0; iHideConsole(); -#endif + //ShowWindow( g_hWndMain, SW_SHOW ); // Now we're ready to recieve and process Windows messages. MSG msg; @@ -245,7 +266,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) Update(); Render(); if( DISPLAY && DISPLAY->IsWindowed() ) - ::Sleep( 1 ); // give some time to other processes + ::Sleep( 0 ); // give some time to other processes } } // end while( WM_QUIT != msg.message ) @@ -276,7 +297,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) LOG->WriteLine( "\n" "//////////////////////////////////////////////////////\n" - "Exception: %s" + "Exception: %s\n" "//////////////////////////////////////////////////////\n" "\n", g_sErrorString @@ -311,8 +332,12 @@ BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { case WM_INITDIALOG: { + LOG->Flush(); + CString sMessage = g_sErrorString; + sMessage.Replace( "\n", "\r\n" ); + SendDlgItemMessage( hWnd, IDC_EDIT_ERROR, @@ -406,7 +431,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) // Don't allow the window to be resized smaller than the screen resolution. // This should snap to multiples of the Window size two! RECT rcWnd; - SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); + SetRect( &rcWnd, 0, 0, PREFSMAN->m_iDisplayResolution, PREFSMAN->GetDisplayHeight() ); DWORD dwWindowStyle = GetWindowLong( g_hWndMain, GWL_STYLE ); AdjustWindowRect( &rcWnd, dwWindowStyle, FALSE ); @@ -450,7 +475,16 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) ApplyGraphicOptions(); return 0; case IDM_CHANGEDETAIL: - PREFSMAN->m_bHighDetail = !PREFSMAN->m_bHighDetail; + if( PREFSMAN->m_iDisplayResolution != 640 ) + { + PREFSMAN->m_iDisplayResolution = 640; + PREFSMAN->m_iTextureResolution = 512; + } + else + { + PREFSMAN->m_iDisplayResolution = 400; + PREFSMAN->m_iTextureResolution = 256; + } ApplyGraphicOptions(); return 0; case IDM_EXIT: @@ -490,7 +524,7 @@ HRESULT CreateObjects( HWND hWnd ) // // Draw a splash bitmap so the user isn't looking at a black Window // - HBITMAP hSplashBitmap = (HBITMAP)LoadImage( +/* HBITMAP hSplashBitmap = (HBITMAP)LoadImage( GetModuleHandle( NULL ), TEXT("BITMAP_SPLASH"), IMAGE_BITMAP, @@ -512,7 +546,7 @@ HRESULT CreateObjects( HWND hWnd ) // Delete the bitmap DeleteObject( hSplashBitmap ); - +*/ // @@ -521,22 +555,22 @@ HRESULT CreateObjects( HWND hWnd ) srand( (unsigned)time(NULL) ); // seed number generator LOG = new RageLog(); +#ifdef _DEBUG + LOG->ShowConsole(); +#endif TIMER = new RageTimer; + GAMESTATE = new GameState; + PREFSMAN = new PrefsManager; + GAMEMAN = new GameManager; + THEME = new ThemeManager; SOUND = new RageSound( hWnd ); MUSIC = new RageSoundStream; INPUTMAN = new RageInput( hWnd ); - PREFSMAN = new PrefsManager; - DISPLAY = new RageDisplay( hWnd ); - SONGMAN = new SongManager; // this takes a long time to load - GAMEMAN = new GameManager; - THEME = new ThemeManager; ANNOUNCER = new AnnouncerManager; INPUTFILTER = new InputFilter(); INPUTMAPPER = new InputMapper(); INPUTQUEUE = new InputQueue(); - - BringWindowToTop( hWnd ); - SetForegroundWindow( hWnd ); + DISPLAY = new RageDisplay( hWnd ); // We can't do any texture loading unless the D3D device is created. // Set the display mode to make sure the D3D device is created. @@ -544,10 +578,19 @@ HRESULT CreateObjects( HWND hWnd ) TEXTUREMAN = new RageTextureManager( DISPLAY ); - // These things depend on the TextureManager, so do them last! + // These things depend on the TextureManager, so do them after! FONT = new FontManager; SCREENMAN = new ScreenManager; + SCREENMAN->SetNewScreen( new ScreenLoading ); + Update(); + Render(); + ::Sleep( 10000 ); + + SONGMAN = new SongManager( Render ); // this takes a long time to load + + BringWindowToTop( hWnd ); + SetForegroundWindow( hWnd ); SCREENMAN->SetNewScreen( new ScreenTitleMenu ); @@ -571,22 +614,23 @@ HRESULT CreateObjects( HWND hWnd ) //----------------------------------------------------------------------------- void DestroyObjects() { - SAFE_DELETE( SCREENMAN ); - SAFE_DELETE( FONT ); - SAFE_DELETE( TEXTUREMAN ); SAFE_DELETE( INPUTQUEUE ); SAFE_DELETE( INPUTMAPPER ); SAFE_DELETE( INPUTFILTER ); - SAFE_DELETE( ANNOUNCER ); - SAFE_DELETE( THEME ); - SAFE_DELETE( GAMEMAN ); SAFE_DELETE( SONGMAN ); - SAFE_DELETE( DISPLAY ); SAFE_DELETE( PREFSMAN ); + SAFE_DELETE( GAMESTATE ); + SAFE_DELETE( GAMEMAN ); + SAFE_DELETE( THEME ); + SAFE_DELETE( ANNOUNCER ); SAFE_DELETE( INPUTMAN ); SAFE_DELETE( MUSIC ); SAFE_DELETE( SOUND ); SAFE_DELETE( TIMER ); + SAFE_DELETE( SCREENMAN ); + SAFE_DELETE( FONT ); + SAFE_DELETE( TEXTUREMAN ); + SAFE_DELETE( DISPLAY ); SAFE_DELETE( LOG ); } @@ -603,13 +647,18 @@ HRESULT RestoreObjects() // Set window size RECT rcWnd; + DWORD dwWindowStyle = g_dwWindowStyle; + if( DISPLAY->IsWindowed() ) { - SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); - AdjustWindowRect( &rcWnd, g_dwWindowStyle, FALSE ); +// dwWindowStyle &= WS_THICKFRAME; +// SetWindowLong( g_hWndMain, GWL_STYLE, dwWindowStyle ); + SetRect( &rcWnd, 0, 0, PREFSMAN->m_iDisplayResolution, PREFSMAN->GetDisplayHeight() ); + AdjustWindowRect( &rcWnd, dwWindowStyle, FALSE ); } else // if fullscreen { +// SetWindowLong( g_hWndMain, GWL_STYLE, dwWindowStyle ); SetRect( &rcWnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) ); } @@ -782,61 +831,94 @@ void ApplyGraphicOptions() { InvalidateObjects(); - bool bWindowed = PREFSMAN->m_bWindowed; - CString sProfileName = PREFSMAN->m_bHighDetail ? "High Detail" : "Low Detail"; - DWORD dwWidth = PREFSMAN->m_bHighDetail ? 640 : 320; - DWORD dwHeight = PREFSMAN->m_bHighDetail ? 480 : 240; - DWORD dwDisplayBPP = PREFSMAN->m_bHighDetail ? 16 : 16; - DWORD dwTextureBPP = PREFSMAN->m_bHighDetail ? 16 : 16; - DWORD dwMaxTextureSize = PREFSMAN->m_bHighDetail ? - (PREFSMAN->m_bHighTextureDetail ? 1024 : 512) : - (PREFSMAN->m_bHighTextureDetail ? 512 : 256); + bool &bWindowed = PREFSMAN->m_bWindowed; + + int &iDisplayWidth = PREFSMAN->m_iDisplayResolution; + int iDisplayHeight = PREFSMAN->GetDisplayHeight(); + + int iDisplayBPP = 16; + + int &iTextureSize = PREFSMAN->m_iTextureResolution; + switch( iTextureSize ) + { + case 1024: break; + case 512: break; + case 256: break; + default: throw RageException( "Invalid TextureResolution '%d'", iTextureSize ); + } + + int iTextureBPP = 16; + + int &iRefreshRate = PREFSMAN->m_iRefreshRate; + switch( iRefreshRate ) + { + case 120: break; + case 100: break; + case 85: break; + case 75: break; + case 60: break; + default: throw RageException( "Invalid RefreshRate '%d'", iRefreshRate ); + } + + CString sMessage = ssprintf( "%s - %dx%d, %dx%d textures%s", + bWindowed ? "Windowed" : "FullScreen", + iDisplayWidth, + iDisplayHeight, + iTextureSize, + iTextureSize, + bWindowed ? "" : ssprintf(", %dHz", iRefreshRate) + ); // // If the requested resolution doesn't work, keep switching until we find one that does. // - if( !DISPLAY->SwitchDisplayMode(bWindowed, dwWidth, dwHeight, dwDisplayBPP) ) - { - // We failed. Try full screen with same params. - bWindowed = false; - if( !DISPLAY->SwitchDisplayMode(bWindowed, dwWidth, dwHeight, dwDisplayBPP) ) - { - // Failed again. Try 16 BPP - dwDisplayBPP = 16; - if( !DISPLAY->SwitchDisplayMode(bWindowed, dwWidth, dwHeight, dwDisplayBPP) ) - { - // Failed again. Try 640x480 - dwWidth = 640; - dwHeight = 480; - if( !DISPLAY->SwitchDisplayMode(bWindowed, dwWidth, dwHeight, dwDisplayBPP) ) - { - // Failed again. Try 320x240 - dwWidth = 320; - dwHeight = 240; - if( !DISPLAY->SwitchDisplayMode(bWindowed, dwWidth, dwHeight, dwDisplayBPP) ) - { - throw RageException( "Tried every possible display mode, and couldn't find one that works." ); - } - } - } - } - } + if( DISPLAY->SwitchDisplayMode(bWindowed, iDisplayWidth, iDisplayHeight, iDisplayBPP, iRefreshRate) ) + goto success; + + // We failed. Try full screen with same params. + iRefreshRate = 60; + if( DISPLAY->SwitchDisplayMode(bWindowed, iDisplayWidth, iDisplayHeight, iDisplayBPP, iRefreshRate) ) + goto success; + + // We failed. Try full screen with same params. + bWindowed = false; + if( DISPLAY->SwitchDisplayMode(bWindowed, iDisplayWidth, iDisplayHeight, iDisplayBPP, iRefreshRate) ) + goto success; + + // Failed again. Try 16 BPP + iDisplayBPP = 16; + if( DISPLAY->SwitchDisplayMode(bWindowed, iDisplayWidth, iDisplayHeight, iDisplayBPP, iRefreshRate) ) + goto success; + + // Failed again. Try 640x480 + iDisplayWidth = 640; + iDisplayHeight = 480; + if( DISPLAY->SwitchDisplayMode(bWindowed, iDisplayWidth, iDisplayHeight, iDisplayBPP, iRefreshRate) ) + goto success; + + // Failed again. Try 320x240 + iDisplayWidth = 320; + iDisplayHeight = 240; + if( DISPLAY->SwitchDisplayMode(bWindowed, iDisplayWidth, iDisplayHeight, iDisplayBPP, iRefreshRate) ) + goto success; + + throw RageException( "Tried every possible display mode, and couldn't find one that works." ); + +success: // // Let the texture manager know about our preferences // if( TEXTUREMAN != NULL ) - TEXTUREMAN->SetPrefs( dwMaxTextureSize, dwTextureBPP ); + TEXTUREMAN->SetPrefs( iTextureSize, iTextureBPP ); RestoreObjects(); - PREFSMAN->SavePrefsToDisk(); + PREFSMAN->SaveGlobalPrefsToDisk(); if( SCREENMAN ) - { - CString sMessage = ssprintf("%s - %s detail", bWindowed ? "Windowed" : "FullScreen", sProfileName ); SCREENMAN->SystemMessage( sMessage ); - } + } diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 48b8288aa2..2cda04c697 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -100,14 +100,6 @@ SOURCE=.\RageBitmapTexture.h # End Source File # Begin Source File -SOURCE=.\RageCRC32.cpp -# End Source File -# Begin Source File - -SOURCE=.\RageCRC32.h -# End Source File -# Begin Source File - SOURCE=.\RageDisplay.cpp # End Source File # Begin Source File @@ -354,6 +346,14 @@ SOURCE=.\IniFile.cpp SOURCE=.\IniFile.h # End Source File +# Begin Source File + +SOURCE=.\MsdFile.cpp +# End Source File +# Begin Source File + +SOURCE=.\MsdFile.h +# End Source File # End Group # Begin Group "System" @@ -804,6 +804,14 @@ SOURCE=.\Judgement.h # End Source File # Begin Source File +SOURCE=.\LifeMeter.cpp +# End Source File +# Begin Source File + +SOURCE=.\LifeMeter.h +# End Source File +# Begin Source File + SOURCE=.\LifeMeterBar.cpp # End Source File # Begin Source File @@ -812,11 +820,11 @@ SOURCE=.\LifeMeterBar.h # End Source File # Begin Source File -SOURCE=.\LifeMeterPills.cpp +SOURCE=.\LifeMeterBattery.cpp # End Source File # Begin Source File -SOURCE=.\LifeMeterPills.h +SOURCE=.\LifeMeterBattery.h # End Source File # Begin Source File @@ -836,11 +844,27 @@ SOURCE=.\NoteField.h # End Source File # Begin Source File -SOURCE=.\ScoreDisplayRolling.cpp +SOURCE=.\ScoreDisplay.cpp # End Source File # Begin Source File -SOURCE=.\ScoreDisplayRolling.h +SOURCE=.\ScoreDisplay.h +# End Source File +# Begin Source File + +SOURCE=.\ScoreDisplayNormal.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScoreDisplayNormal.h +# End Source File +# Begin Source File + +SOURCE=.\ScoreDisplayOni.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScoreDisplayOni.h # End Source File # End Group # Begin Group "Screens" @@ -936,6 +960,14 @@ SOURCE=.\ScreenGameplay.h # End Source File # Begin Source File +SOURCE=.\ScreenLoading.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScreenLoading.h +# End Source File +# Begin Source File + SOURCE=.\ScreenManager.cpp # End Source File # Begin Source File @@ -1096,6 +1128,14 @@ SOURCE=.\GameManager.h # End Source File # Begin Source File +SOURCE=.\GameState.cpp +# End Source File +# Begin Source File + +SOURCE=.\GameState.h +# End Source File +# Begin Source File + SOURCE=.\InputFilter.cpp # End Source File # Begin Source File diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index 4690a7e53e..1f0b0985f8 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -209,6 +209,12 @@ + + + + @@ -421,6 +427,12 @@ + + + + + RelativePath="LifeMeterBattery.cpp"> + RelativePath="LifeMeterBattery.h"> @@ -762,10 +774,22 @@ RelativePath="NoteField.h"> + RelativePath="ScoreDisplay.cpp"> + RelativePath="ScoreDisplay.h"> + + + + + + + + + + + + diff --git a/stepmania/src/TextBanner.cpp b/stepmania/src/TextBanner.cpp index 9e099ce7f7..073a421995 100644 --- a/stepmania/src/TextBanner.cpp +++ b/stepmania/src/TextBanner.cpp @@ -12,7 +12,7 @@ #include "RageUtil.h" #include "TextBanner.h" -#include "ThemeManager.h" +#include "PrefsManager.h" @@ -34,9 +34,9 @@ TextBanner::TextBanner() m_textSubTitle.TurnShadowOff(); m_textArtist.TurnShadowOff(); - this->AddActor( &m_textTitle ); - this->AddActor( &m_textSubTitle ); - this->AddActor( &m_textArtist ); + this->AddSubActor( &m_textTitle ); + this->AddSubActor( &m_textSubTitle ); + this->AddSubActor( &m_textArtist ); } diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index 1e398ebb8d..d2ac16bb3d 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -12,79 +12,87 @@ #include "ThemeManager.h" #include "RageLog.h" +#include "PrefsManager.h" ThemeManager* THEME = NULL; // global object accessable from anywhere in the program -const CString DEFAULT_THEME_NAME = "default"; -const CString THEME_BASE_DIR = "Themes\\"; +const CString BASE_THEME_NAME = "default"; +const CString THEMES_DIR = "Themes\\"; ThemeManager::ThemeManager() { + m_sCurThemeName = BASE_THEME_NAME; // Use te base theme for now. It's up to PrefsManager to change this. + CStringArray arrayThemeNames; GetThemeNames( arrayThemeNames ); + +#ifdef _DEBUG for( int i=0; i=0; i-- ) - { if( 0 == stricmp( AddTo[i], "cvs" ) ) AddTo.RemoveAt(i); - } +} + +bool ThemeManager::DoesThemeExist( CString sThemeName ) +{ + CStringArray asThemeNames; + GetThemeNames( asThemeNames ); + for( int i=0; iWriteLine( "TipDisplay::TipDisplay()" ); m_textTip.Load( THEME->GetPathTo(FONT_NORMAL) ); - this->AddActor( &m_textTip ); + m_textTip.SetEffectBlinking(); + m_textTip.TurnShadowOff(); + this->AddSubActor( &m_textTip ); - iLastTipShown = -1; - m_TipState = STATE_SHOWING; - m_fTimeLeftInState = 0; + m_iCurTipIndex = 0; + m_fSecsUntilSwitch = TIP_SHOW_TIME; } @@ -36,6 +37,8 @@ void TipDisplay::SetTips( CStringArray &arrayTips ) { m_arrayTips.RemoveAll(); m_arrayTips.Copy( arrayTips ); + if( m_arrayTips.GetSize() > 0 ) + m_textTip.SetText( m_arrayTips[0] ); } @@ -43,46 +46,11 @@ void TipDisplay::Update( float fDeltaTime ) { ActorFrame::Update( fDeltaTime ); - if( m_arrayTips.GetSize() == 0 ) - return; - - m_fTimeLeftInState -= fDeltaTime; - if( m_fTimeLeftInState <= 0 ) // time to switch states + m_fSecsUntilSwitch -= fDeltaTime; + if( m_fSecsUntilSwitch < 0 ) // time to switch states { - switch( m_TipState ) - { - case STATE_SHOWING: - m_TipState = STATE_FADING_OUT; - m_fTimeLeftInState = TIP_FADE_TIME; - - // fade out - m_textTip.SetZoomY( 1 ); - m_textTip.BeginTweening( TIP_FADE_TIME ); - m_textTip.SetTweenZoomY( 0 ); - break; - case STATE_FADING_OUT: - m_TipState = STATE_FADING_IN; - m_fTimeLeftInState = TIP_FADE_TIME; - - // switch the tip - int iTipToShow; - iTipToShow = iLastTipShown + 1; - if( iTipToShow > m_arrayTips.GetSize()-1 ) - iTipToShow = 0; - m_textTip.SetText( m_arrayTips[iTipToShow] ); - iLastTipShown = iTipToShow; - - // fade in - m_textTip.SetZoomY( 0 ); - m_textTip.BeginTweening( TIP_FADE_TIME ); - m_textTip.SetTweenZoomY( 1 ); - - break; - case STATE_FADING_IN: - m_TipState = STATE_SHOWING; - m_fTimeLeftInState = TIP_SHOW_TIME; - break; - - } + m_iCurTipIndex++; + m_iCurTipIndex = m_iCurTipIndex % m_arrayTips.GetSize(); + m_fSecsUntilSwitch = TIP_SHOW_TIME; } } diff --git a/stepmania/src/TipDisplay.h b/stepmania/src/TipDisplay.h index ec7903b0d5..f8dcb7e2c5 100644 --- a/stepmania/src/TipDisplay.h +++ b/stepmania/src/TipDisplay.h @@ -31,11 +31,9 @@ protected: BitmapText m_textTip; CStringArray m_arrayTips; - int iLastTipShown; + int m_iCurTipIndex; - enum TipState { STATE_FADING_IN, STATE_SHOWING, STATE_FADING_OUT }; - TipState m_TipState; - float m_fTimeLeftInState; + float m_fSecsUntilSwitch; }; #endif \ No newline at end of file diff --git a/stepmania/src/Transition.cpp b/stepmania/src/Transition.cpp index a3c13d8443..7a849ea6d8 100644 --- a/stepmania/src/Transition.cpp +++ b/stepmania/src/Transition.cpp @@ -12,7 +12,7 @@ #include "RageUtil.h" #include "Transition.h" -#include "ThemeManager.h" +#include "PrefsManager.h" Transition::Transition() diff --git a/stepmania/src/TransitionBackWipe.cpp b/stepmania/src/TransitionBackWipe.cpp index 925cf4cf9f..5a477a615c 100644 --- a/stepmania/src/TransitionBackWipe.cpp +++ b/stepmania/src/TransitionBackWipe.cpp @@ -12,7 +12,7 @@ #include "TransitionBackWipe.h" #include "RageUtil.h" -#include "ThemeManager.h" +#include "PrefsManager.h" #define RECTANGLE_WIDTH 20 diff --git a/stepmania/src/TransitionFadeWipe.cpp b/stepmania/src/TransitionFadeWipe.cpp index 88bc903e9a..93fd8011b9 100644 --- a/stepmania/src/TransitionFadeWipe.cpp +++ b/stepmania/src/TransitionFadeWipe.cpp @@ -13,7 +13,7 @@ #include "TransitionFadeWipe.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" const float FADE_RECT_WIDTH = SCREEN_WIDTH/2; diff --git a/stepmania/src/TransitionKeepAlive.cpp b/stepmania/src/TransitionKeepAlive.cpp index f62afaa0d5..3c828c9dcf 100644 --- a/stepmania/src/TransitionKeepAlive.cpp +++ b/stepmania/src/TransitionKeepAlive.cpp @@ -13,7 +13,7 @@ #include "TransitionKeepAlive.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" const float KEEP_ALIVE_FORWARD_TRANSITION_TIME = 0.8f; diff --git a/stepmania/src/TransitionStarWipe.cpp b/stepmania/src/TransitionStarWipe.cpp index c47885b5e4..32428604b3 100644 --- a/stepmania/src/TransitionStarWipe.cpp +++ b/stepmania/src/TransitionStarWipe.cpp @@ -13,7 +13,7 @@ #include "TransitionStarWipe.h" #include "GameConstantsAndTypes.h" -#include "ThemeManager.h" +#include "PrefsManager.h" TransitionStarWipe::TransitionStarWipe()