From fc2108e85d6ad986f027dcb346e0f4f9d89fb52f Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 22 Feb 2003 01:58:56 +0000 Subject: [PATCH] fixed EditMenu "Create from Autogen" weirdness cleaned up some unnecessary header dependencies --- stepmania/src/EditMenu.cpp | 5 +- stepmania/src/EditMenu.h | 2 +- stepmania/src/GameDef.h | 1 - stepmania/src/GameState.cpp | 1 + stepmania/src/GrayArrow.h | 7 +-- stepmania/src/MusicWheelItem.cpp | 1 + stepmania/src/Notes.cpp | 80 ++++++++++++-------------- stepmania/src/Notes.h | 16 ++---- stepmania/src/Player.h | 1 - stepmania/src/Screen.h | 1 - stepmania/src/ScreenEdit.cpp | 14 ++++- stepmania/src/ScreenEditMenu.cpp | 17 +++--- stepmania/src/ScreenEz2SelectMusic.cpp | 6 +- stepmania/src/ScreenManager.cpp | 1 + stepmania/src/ScreenManager.h | 12 ++-- stepmania/src/ScreenSelectMusic.cpp | 1 + stepmania/src/StyleDef.h | 1 - 17 files changed, 83 insertions(+), 84 deletions(-) diff --git a/stepmania/src/EditMenu.cpp b/stepmania/src/EditMenu.cpp index d72f520476..ab7eb9c138 100644 --- a/stepmania/src/EditMenu.cpp +++ b/stepmania/src/EditMenu.cpp @@ -131,10 +131,9 @@ EditMenu::~EditMenu() } -void EditMenu::Refresh() +void EditMenu::RefreshNotes() { - ChangeToRow( (Row)0 ); - OnRowValueChanged( (Row)0 ); + OnRowValueChanged( ROW_SONG ); } void EditMenu::DrawPrimitives() diff --git a/stepmania/src/EditMenu.h b/stepmania/src/EditMenu.h index d58fb651da..14824cc5e3 100644 --- a/stepmania/src/EditMenu.h +++ b/stepmania/src/EditMenu.h @@ -85,7 +85,7 @@ public: return s[a]; } - void Refresh(); + void RefreshNotes(); CString GetSelectedGroup() { return m_sGroups[m_iSelection[ROW_GROUP]]; } diff --git a/stepmania/src/GameDef.h b/stepmania/src/GameDef.h index acc6056466..89b0bd8e5f 100644 --- a/stepmania/src/GameDef.h +++ b/stepmania/src/GameDef.h @@ -11,7 +11,6 @@ ----------------------------------------------------------------------------- */ -#include "Notes.h" #include "GameInput.h" #include "MenuInput.h" #include "GameConstantsAndTypes.h" diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index dfd9ef1043..34752fa757 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -21,6 +21,7 @@ #include "ThemeManager.h" #include "RageUtil.h" #include "SongManager.h" +#include "Notes.h" #include "NoteSkinManager.h" diff --git a/stepmania/src/GrayArrow.h b/stepmania/src/GrayArrow.h index 9cb39f5a39..491a8b5038 100644 --- a/stepmania/src/GrayArrow.h +++ b/stepmania/src/GrayArrow.h @@ -1,3 +1,5 @@ +#ifndef _GrayArrow_H_ +#define _GrayArrow_H_ /* ----------------------------------------------------------------------------- Class: GrayArrow @@ -11,12 +13,7 @@ */ -#ifndef _GrayArrow_H_ -#define _GrayArrow_H_ - - #include "Sprite.h" -#include "Notes.h" class GrayArrow : public Sprite { diff --git a/stepmania/src/MusicWheelItem.cpp b/stepmania/src/MusicWheelItem.cpp index 7ae060fc7b..3fd2ca075e 100644 --- a/stepmania/src/MusicWheelItem.cpp +++ b/stepmania/src/MusicWheelItem.cpp @@ -24,6 +24,7 @@ #include "GameState.h" #include #include "ThemeManager.h" +#include "Notes.h" // WheelItem stuff diff --git a/stepmania/src/Notes.cpp b/stepmania/src/Notes.cpp index 8d332e0b0a..f101fc8128 100644 --- a/stepmania/src/Notes.cpp +++ b/stepmania/src/Notes.cpp @@ -140,43 +140,6 @@ void Notes::TidyUpData() } } - -////////////////////////////////////////////// -// -////////////////////////////////////////////// - -bool CompareNotesPointersByRadarValues(const Notes* pNotes1, const Notes* pNotes2) -{ - float fScore1 = 0; - float fScore2 = 0; - - for( int r=0; rGetRadarValues()[r]; - fScore2 += pNotes2->GetRadarValues()[r]; - } - - return fScore1 < fScore2; -} - -bool CompareNotesPointersByMeter(const Notes *pNotes1, const Notes* pNotes2) -{ - return pNotes1->GetMeter() < pNotes2->GetMeter(); -} - -bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2) -{ - return pNotes1->GetDifficulty() < pNotes2->GetDifficulty(); -} - -void SortNotesArrayByDifficulty( vector &arraySteps ) -{ - /* Sort in reverse order of priority. */ - stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByRadarValues ); - stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByMeter ); - stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByDifficulty ); -} - void Notes::Decompress() const { if(notes) return; @@ -246,12 +209,6 @@ void Notes::AutogenFrom( Notes *parent_, NotesType ntTo ) m_NotesType = ntTo; } -void Notes::BakeAutoGen() -{ - Decompress(); - parent = NULL; -} - void Notes::CopyFrom( Notes* pSource, NotesType ntTo ) // pSource does not have to be of the same NotesType! { m_NotesType = ntTo; @@ -333,3 +290,40 @@ void Notes::AddScore( PlayerNumber pn, Grade grade, float fScore, bool& bNewReco m_MemCardScores[MEMORY_CARD_MACHINE].grade = grade; } } + + +// +// Sorting stuff +// + +bool CompareNotesPointersByRadarValues(const Notes* pNotes1, const Notes* pNotes2) +{ + float fScore1 = 0; + float fScore2 = 0; + + for( int r=0; rGetRadarValues()[r]; + fScore2 += pNotes2->GetRadarValues()[r]; + } + + return fScore1 < fScore2; +} + +bool CompareNotesPointersByMeter(const Notes *pNotes1, const Notes* pNotes2) +{ + return pNotes1->GetMeter() < pNotes2->GetMeter(); +} + +bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2) +{ + return pNotes1->GetDifficulty() < pNotes2->GetDifficulty(); +} + +void SortNotesArrayByDifficulty( vector &arraySteps ) +{ + /* Sort in reverse order of priority. */ + stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByRadarValues ); + stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByMeter ); + stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByDifficulty ); +} \ No newline at end of file diff --git a/stepmania/src/Notes.h b/stepmania/src/Notes.h index 5e180818f7..5f45225378 100644 --- a/stepmania/src/Notes.h +++ b/stepmania/src/Notes.h @@ -23,10 +23,14 @@ public: Notes(); ~Notes(); - void Decompress() const; + // initializers + void AutogenFrom( Notes *parent, NotesType ntTo ); + void CopyFrom( Notes* pSource, NotesType ntTo ); + void CreateBlank( NotesType ntTo ); -public: void Compress() const; + void Decompress() const; + void DeAutogen(); /* If this Notes is autogenerated, make it a real Notes. */ CString GetDescription() const { return Real()->m_sDescription; } Difficulty GetDifficulty() const { return Real()->m_Difficulty; } @@ -46,12 +50,6 @@ public: void SetSMNoteData( const CString &out ); CString GetSMNoteData() const; - // initializers - void AutogenFrom( Notes *parent, NotesType ntTo ); - void BakeAutoGen(); // makes into an AutoGen Notes into a regular Notes - void CopyFrom( Notes* pSource, NotesType ntTo ); - void CreateBlank( NotesType ntTo ); - // High scores struct MemCardScore @@ -85,8 +83,6 @@ protected: int m_iMeter; // difficulty rating from 1-10 float m_fRadarValues[NUM_RADAR_CATEGORIES]; // between 0.0-1.2 starting from 12-o'clock rotating clockwise - /* If this Notes is autogenerated, make it a real Notes. */ - void DeAutogen(); }; bool CompareNotesPointersByRadarValues(const Notes* pNotes1, const Notes* pNotes2); diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 2a5f87345a..d0fb935e84 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -13,7 +13,6 @@ */ #include "PrefsManager.h" // for GameplayStatistics -#include "Notes.h" #include "Sprite.h" #include "BitmapText.h" diff --git a/stepmania/src/Screen.h b/stepmania/src/Screen.h index 360c78bb8d..64f4513d7e 100644 --- a/stepmania/src/Screen.h +++ b/stepmania/src/Screen.h @@ -11,7 +11,6 @@ ----------------------------------------------------------------------------- */ -#include "RageInputDevice.h" #include "ActorFrame.h" #include "ScreenMessage.h" #include "InputFilter.h" diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 3e7ee08224..7369710780 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -27,7 +27,7 @@ #include "SDL_keysym.h" // for SDLKeys #include "ScreenMiniMenu.h" #include "NoteSkinManager.h" - +#include "Notes.h" #include @@ -104,6 +104,8 @@ MiniMenuDefinition g_KeyboardShortcuts = { "Home/End: jump to first/last beat", false, 1, 0, {""} }, { "Ctrl + Up/Down: Change zoom", false, 1, 0, {""} }, { "Shift + Up/Down: Drag area marker", false, 1, 0, {""} }, + { "P: Play selection", false, 1, 0, {""} }, + { "Ctrl + P: Play whole song", false, 1, 0, {""} }, { "F7/F8: Decrease/increase BPM at cur beat", false, 1, 0, {""} }, { "F9/F10: Decrease/increase stop at cur beat", false, 1, 0, {""} }, { "F11/F12: Decrease/increase music offset", false, 1, 0, {""} }, @@ -896,6 +898,16 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } } break; + case SDLK_p: + { + if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD,SDLK_LCTRL)) || + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD,SDLK_RCTRL)) ) + HandleMainMenuChoice( play_whole_song, NULL ); + else + if( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ) + HandleAreaMenuChoice( play, NULL ); + } + break; } } diff --git a/stepmania/src/ScreenEditMenu.cpp b/stepmania/src/ScreenEditMenu.cpp index e84340b877..1f63df8a7f 100644 --- a/stepmania/src/ScreenEditMenu.cpp +++ b/stepmania/src/ScreenEditMenu.cpp @@ -21,6 +21,7 @@ #include "GameState.h" #include "RageSoundManager.h" #include "ThemeManager.h" +#include "Notes.h" // @@ -93,7 +94,7 @@ void ScreenEditMenu::HandleScreenMessage( const ScreenMessage SM ) switch( SM ) { case SM_RefreshSelector: - m_Selector.Refresh(); + m_Selector.RefreshNotes(); break; case SM_GoToPrevScreen: SCREENMAN->SetNewScreen( "ScreenTitleMenu" ); @@ -174,8 +175,8 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) break; case EditMenu::ACTION_DELETE: ASSERT( pNotes ); - SCREENMAN->Prompt( SM_RefreshSelector, "These notes will be lost permanently.\nContinue with delete?", true, false, DeleteCurNotes ); - m_Selector.Refresh(); + SCREENMAN->Prompt( SM_RefreshSelector, "These notes will be lost permanently.\n\nContinue with delete?", true, false, DeleteCurNotes ); + m_Selector.RefreshNotes(); return; case EditMenu::ACTION_COPY: ASSERT( !pNotes ); @@ -190,7 +191,7 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) SCREENMAN->SystemMessage( "Notes created from copy." ); m_soundCreate.PlayRandom(); - m_Selector.Refresh(); + m_Selector.RefreshNotes(); pSong->Save(); } return; @@ -202,13 +203,13 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) // Song allocates all of the other Notes. Notes* pNewNotes = new Notes; pNewNotes->AutogenFrom( pSourceNotes, nt ); - pNewNotes->BakeAutoGen(); - pNewNotes->SetDifficulty( dc ); + pNewNotes->DeAutogen(); + pNewNotes->SetDifficulty( dc ); // override difficulty with the user's choice pSong->AddNotes( pNewNotes ); SCREENMAN->SystemMessage( "Notes created from AutoGen." ); m_soundCreate.PlayRandom(); - m_Selector.Refresh(); + m_Selector.RefreshNotes(); pSong->Save(); } return; @@ -225,7 +226,7 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) SCREENMAN->SystemMessage( "Blank Notes created." ); m_soundCreate.PlayRandom(); - m_Selector.Refresh(); + m_Selector.RefreshNotes(); pSong->Save(); } return; diff --git a/stepmania/src/ScreenEz2SelectMusic.cpp b/stepmania/src/ScreenEz2SelectMusic.cpp index 7d3c034d16..b6a7ddbbe2 100644 --- a/stepmania/src/ScreenEz2SelectMusic.cpp +++ b/stepmania/src/ScreenEz2SelectMusic.cpp @@ -11,13 +11,9 @@ ----------------------------------------------------------------------------- */ -#include "global.h" - #include "ScreenEz2SelectMusic.h" - #include "RageDisplay.h" #include - #include "SDL.h" #include "SDL_opengl.h" #include "ScreenManager.h" @@ -29,6 +25,8 @@ #include "StyleDef.h" #include "InputMapper.h" #include "CodeDetector.h" +#include "Notes.h" + #define SCROLLING_LIST_X THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListX") #define SCROLLING_LIST_Y THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListY") diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index f43a354e10..67512c7cea 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -21,6 +21,7 @@ #include "RageTimer.h" #include "ThemeManager.h" #include "RageDisplay.h" +#include "Screen.h" ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program diff --git a/stepmania/src/ScreenManager.h b/stepmania/src/ScreenManager.h index b67aa9b4dc..4273a7eefd 100644 --- a/stepmania/src/ScreenManager.h +++ b/stepmania/src/ScreenManager.h @@ -13,15 +13,17 @@ #include "RageInputDevice.h" -#include "song.h" -#include "Notes.h" -#include "Screen.h" #include "BitmapText.h" #include "Quad.h" - - +#include "ScreenMessage.h" +#include "InputFilter.h" +#include "GameInput.h" +#include "MenuInput.h" +#include "StyleInput.h" +class Screen; struct MiniMenuDefinition; + class ScreenManager { public: diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 668946e0a0..e1073c502b 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -29,6 +29,7 @@ #include #include "GameConstantsAndTypes.h" #include "ThemeManager.h" +#include "Notes.h" #define BANNER_FRAME_X THEME->GetMetricF("ScreenSelectMusic","BannerFrameX") diff --git a/stepmania/src/StyleDef.h b/stepmania/src/StyleDef.h index 9a2fab770a..652680d30d 100644 --- a/stepmania/src/StyleDef.h +++ b/stepmania/src/StyleDef.h @@ -21,7 +21,6 @@ ----------------------------------------------------------------------------- */ -#include "Notes.h" #include "StyleInput.h" #include "GameInput.h" #include "Game.h"