From a471a70e1e4e8bcac1ac2ecbc64397d28d742516 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Tue, 8 Jul 2003 18:50:24 +0000 Subject: [PATCH] updated unlock screen - now it can be configured to be MAX2-style (shows the numbers 1-30) --- stepmania/src/ScreenUnlock.cpp | 48 +++++++++++++++++++++++++++++----- stepmania/src/ScreenUnlock.h | 4 +++ stepmania/src/UnlockSystem.cpp | 43 +++++------------------------- stepmania/src/UnlockSystem.h | 18 +++++++------ 4 files changed, 61 insertions(+), 52 deletions(-) diff --git a/stepmania/src/ScreenUnlock.cpp b/stepmania/src/ScreenUnlock.cpp index adf9ea92f1..d2a8bf12a7 100644 --- a/stepmania/src/ScreenUnlock.cpp +++ b/stepmania/src/ScreenUnlock.cpp @@ -1,3 +1,15 @@ +/* +----------------------------------------------------------------------------- + Class: ScreenUnlock + + Desc: See header. + + Copyright (c) 2003 by the person(s) listed below. All rights reserved. + curewater +----------------------------------------------------------------------------- +*/ + + #include "global.h" #include "PrefsManager.h" #include "ScreenUnlock.h" @@ -6,22 +18,44 @@ #include "RageLog.h" #include "UnlockSystem.h" - - - ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") { LOG->Trace("ScreenUnlock::ScreenUnlock()"); PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") ); PointsUntilNextUnlock.SetHorizAlign( Actor::align_left ); - CString sDP = ssprintf( "%f", GAMESTATE->m_pUnlockingSys->NumPointsUntilNextUnlock() ); - - // Remove the decimal + CString sDP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->NumPointsUntilNextUnlock() ); + + for(int i=1; i <= THEME->GetMetricI("ScreenUnlock", "NumUnlocks"); i++) + { + // new unlock graphic + char filename[30]; + + sprintf(filename, "UnlockGraphic%d", i); + Unlocks[i].Load( THEME->GetPathToG(filename) ); + + sprintf(filename, "Unlock%d", i); + PointsUntilNextUnlock.SetXY( + THEME->GetMetricI("ScreenUnlock",ssprintf("Unlock%dX", i)), + THEME->GetMetricI("ScreenUnlock",ssprintf("Unlock%dX", i)) ); + + Unlocks[i].SetName( ssprintf("Unlock%d",i) ); + + UtilSetXY( Unlocks[i], "ScreenUnlock" ); + + if (!GAMESTATE->m_pUnlockingSys->SongIsLocked + (THEME->GetMetric + ("ScreenUnlock", ssprintf + ("Unlock%dSong", i)))) + this->AddChild(&Unlocks[i]); + + } + + /* Remove the decimal if( sDP.Find(".",1) > 0 ) { sDP = sDP.Left(sDP.Find(".",1)); - } + } no longer necessary since its an int*/ // No negative numbers if( sDP.Left(1) == "-" ) diff --git a/stepmania/src/ScreenUnlock.h b/stepmania/src/ScreenUnlock.h index fc7599c893..b7bcdd73f2 100644 --- a/stepmania/src/ScreenUnlock.h +++ b/stepmania/src/ScreenUnlock.h @@ -6,12 +6,15 @@ Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford + curewater ----------------------------------------------------------------------------- */ #include "ScreenAttract.h" #include "GameConstantsAndTypes.h" // for NUM_RANKING_LINES #include "Style.h" +#include "ActorUtil.h" +#define NUM_UNLOCKS 30 class Course; @@ -22,4 +25,5 @@ public: ScreenUnlock(); protected: BitmapText PointsUntilNextUnlock; + Sprite Unlocks[NUM_UNLOCKS]; // support 30 unlocks right now }; diff --git a/stepmania/src/UnlockSystem.cpp b/stepmania/src/UnlockSystem.cpp index 4ba5dab332..c6f4a25f78 100644 --- a/stepmania/src/UnlockSystem.cpp +++ b/stepmania/src/UnlockSystem.cpp @@ -6,6 +6,7 @@ Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved. Kevin Slaughter + curewater ----------------------------------------------------------------------------- */ @@ -21,8 +22,6 @@ using namespace std; #include "stdio.h" -// #define POINTS_ACCUMULATED_BEFORE_LAST_ROUND // Load from file here - UnlockSystem::UnlockSystem() { } @@ -32,6 +31,7 @@ bool UnlockSystem::SongIsLocked( CString sSongName ) { sSongName.MakeUpper(); //Avoid case-sensitive problems + // searches for song in unlock list for(unsigned i = 0; i < m_SongEntries.size(); i++) if (m_SongEntries[i].m_sSongName == sSongName) return m_SongEntries[i].isLocked; @@ -50,40 +50,6 @@ bool UnlockSystem::SongIsRoulette( CString sSongName ) return false; } -/* These don't appear to be used. If you need them, I'd suggest making them - * members. They also need return types. */ -#if 0 -operator == (const SongEntry &a, const SongEntry &b) -{ - return a.m_sSongName == b.m_sSongName; -} - -operator != (const SongEntry &a, const SongEntry &b) -{ - return a.m_sSongName != b.m_sSongName; -} - -operator >= (const SongEntry &a, const SongEntry &b) -{ - return a.m_sSongName >= b.m_sSongName; -} - -operator <= (const SongEntry &a, const SongEntry &b) -{ - return a.m_sSongName <= b.m_sSongName; -} - -operator > (const SongEntry &a, const SongEntry &b) -{ - return a.m_sSongName > b.m_sSongName; -} - -operator < (const SongEntry &a, const SongEntry &b) -{ - return a.m_sSongName <= b.m_sSongName; -} -#endif - SongEntry::SongEntry() { m_fDancePointsRequired = 0; @@ -108,7 +74,7 @@ bool UnlockSystem::ParseRow(CString text, CString &type, float &qty, CString &songname) { int pos = -1; - int end; + int end = text.GetLength(); // sets a value in case | does not exist char unlock_type[4]; char qty_text[20]; @@ -128,6 +94,9 @@ bool UnlockSystem::ParseRow(CString text, CString &type, float &qty, * I havn't looked at this code to see if it's a problem, but I don't want * to simply silence the warning without being sure. (Can this just be * a standard INI--does it actually need to be another file format?) -glenn */ + + // glenn: ok, i set it at the beginning. + songname = text.Right(text.GetLength() - 1 - end); sscanf(text, "%s %s|", unlock_type, qty_text); diff --git a/stepmania/src/UnlockSystem.h b/stepmania/src/UnlockSystem.h index 0373b58a0a..ad246db22f 100644 --- a/stepmania/src/UnlockSystem.h +++ b/stepmania/src/UnlockSystem.h @@ -1,16 +1,16 @@ #ifndef UNLOCK_SYSTEM_H #define UNLOCK_SYSTEM_H -#include "Grade.h" - +#include "grade.h" /* ----------------------------------------------------------------------------- Class: UnlockSystem - Desc: See header. + Desc: The unlock system for Stepmania. Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved. Kevin Slaughter + curewater ----------------------------------------------------------------------------- */ enum UnlockTypes { UNLOCK_AP, UNLOCK_DP, UNLOCK_SP, @@ -23,7 +23,8 @@ struct SongEntry for a lot easier compatibility since a lot of people's song folders are named differantly, song names tend to be the same in the file.*/ - float m_fDancePointsRequired; // Amount of Dance Points needed to unlock this song + + float m_fDancePointsRequired; // Ways to unlock/lock songs. float m_fArcadePointsRequired; float m_fSongPointsRequired; float m_fExtraStagesCleared; @@ -32,14 +33,15 @@ struct SongEntry float m_fToastysSeen; int m_iRouletteSeed; - bool isLocked; + bool isLocked; // cached locked tag SongEntry(); + // if song is selectable vai two means bool SelectableWheel(); bool SelectableRoulette(); - bool updateLocked(); + bool updateLocked(); //updates isLocked flag }; @@ -51,9 +53,9 @@ public: bool SongIsLocked( CString sSongName ); bool SongIsRoulette( CString sSongName ); bool LoadFromDATFile( CString sPath ); -// bool m_bAllSongsAreUnlocked; // Quick way to check if all songs are unlocked vector m_SongEntries; // All locked songs are stored here + // functions that add to values, which don't really work. float UnlockAddAP(Grade credit); float UnlockAddDP(float credit); float UnlockAddSP(Grade credit); @@ -64,7 +66,7 @@ public: bool UnlockRouletteSeed(int seed); private: - void SortSongEntriesArray(); + void SortSongEntriesArray(); // sorts unlocks bool ParseRow(CString text, CString &type, float &qty, CString &songname); };