Added new unlock system, disabled by default
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
//Test file for Miryo's new Unlock system. Songs are matched by name, not folder name
|
||||
[DP]500|Gamelan de Couple
|
||||
[DP]7500|Exotic Ethnic
|
||||
[DP]10000|Maxx Unlimited
|
||||
@@ -1708,6 +1708,7 @@ MarvelousTiming=Enable or disable marvelous judgement.
|
||||
HiddenSongs=Some songs are only playable during Oni courses and::with roulette. Leave this &oq;OFF&cq; to always display all songs.
|
||||
PickExtraStage=Instead of a set extra stage, this allows::the player to choose which song to play.::Difficulty and options are still locked.
|
||||
SoloSingles=Turn this option &oq;ON&cq; to enable Solo-Style::for 4-panel single play.
|
||||
UnlockSystem=Enable or disable unlock system.
|
||||
|
||||
[ScreenBackgroundOptions]
|
||||
HelpText=&UP; &DOWN; to change line &LEFT; &RIGHT; to select between options::START to accept changes BACK to discard changes
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "Style.h"
|
||||
#include "Grade.h"
|
||||
#include "StageStats.h"
|
||||
#include "UnlockSystem.h"
|
||||
|
||||
class Song;
|
||||
class Notes;
|
||||
@@ -41,6 +42,7 @@ public:
|
||||
//
|
||||
// Main State Info
|
||||
//
|
||||
UnlockSystem UnlockingSys;
|
||||
Game m_CurGame;
|
||||
Style m_CurStyle;
|
||||
bool m_bPlayersCanJoin; // true if it's not too late for a player to join - this only has an effect on the credits message
|
||||
|
||||
@@ -274,7 +274,15 @@ void MusicWheel::GetSongList(vector<Song*> &arraySongs, SongSortOrder so, CStrin
|
||||
pSong->GetNotes( arraySteps, GAMESTATE->GetCurrentStyleDef()->m_NotesType, DIFFICULTY_INVALID, -1, -1, "", PREFSMAN->m_bAutogenMissingTypes );
|
||||
|
||||
if( !arraySteps.empty() )
|
||||
{
|
||||
// If we're using unlocks, check it here to prevent from being shown
|
||||
if( PREFSMAN->m_bUseUnlockSystem )
|
||||
{
|
||||
pSong->m_bIsLocked = GAMESTATE->UnlockingSys.SongIsLocked( pSong->m_sMainTitle );
|
||||
if( pSong->m_bIsLocked ) { continue; }
|
||||
}
|
||||
arraySongs.push_back( pSong );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,8 @@ PrefsManager::PrefsManager()
|
||||
m_bBreakComboToGetItem = false;
|
||||
m_bShowDancingCharacters = false;
|
||||
m_BannerCacheType = preload_none;
|
||||
m_fDancePointsAccumulated = 0;
|
||||
m_bUseUnlockSystem = false;
|
||||
|
||||
/* DDR Extreme-style extra stage support.
|
||||
* Default off so people used to the current behavior (or those with extra
|
||||
@@ -196,6 +198,8 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame )
|
||||
ini.GetValueB( "Options", "BreakComboToGetItem", m_bBreakComboToGetItem );
|
||||
ini.GetValueB( "Options", "ShowDancingCharacters", m_bShowDancingCharacters );
|
||||
ini.GetValueI( "Options", "BannerCacheType", (int&)m_BannerCacheType );
|
||||
ini.GetValueF( "Misc", "DancePointsAccumulated", m_fDancePointsAccumulated );
|
||||
ini.GetValueB( "Misc", "UseUnlockSystem", m_bUseUnlockSystem );
|
||||
|
||||
m_asAdditionalSongFolders.clear();
|
||||
CString sAdditionalSongFolders;
|
||||
@@ -279,6 +283,8 @@ void PrefsManager::SaveGlobalPrefsToDisk()
|
||||
ini.SetValueB( "Options", "BreakComboToGetItem", m_bBreakComboToGetItem );
|
||||
ini.SetValueB( "Options", "ShowDancingCharacters", m_bShowDancingCharacters );
|
||||
ini.SetValueI( "Options", "BannerCacheType", m_BannerCacheType );
|
||||
ini.SetValueF( "Misc", "DancePointsAccumulated", m_fDancePointsAccumulated );
|
||||
ini.SetValueB( "Misc", "UseUnlockSystem", m_bUseUnlockSystem );
|
||||
|
||||
|
||||
/* Only write these if they aren't the default. This ensures that we can change
|
||||
|
||||
@@ -76,6 +76,8 @@ public:
|
||||
CString m_sDefaultModifiers;
|
||||
bool m_bBreakComboToGetItem;
|
||||
bool m_bShowDancingCharacters;
|
||||
float m_fDancePointsAccumulated;
|
||||
bool m_bUseUnlockSystem;
|
||||
|
||||
/* 0 = no; 1 = yes; -1 = auto (do whatever is appropriate for the arch). */
|
||||
int m_iBoostAppPriority;
|
||||
|
||||
@@ -195,8 +195,12 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl
|
||||
case stage:
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( GAMESTATE->IsHumanPlayer(p) )
|
||||
{
|
||||
GAMESTATE->m_pCurNotes[p]->AddScore( (PlayerNumber)p, grade[p], stageStats.fScore[p], bNewRecord[p] );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case summary:
|
||||
@@ -208,10 +212,12 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl
|
||||
|
||||
RankingCategory cat[NUM_PLAYERS];
|
||||
int iRankingIndex[NUM_PLAYERS];
|
||||
float fTotalDP;
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
float fAverageMeter = stageStats.iMeter[p] / (float)PREFSMAN->m_iNumArcadeStages;
|
||||
cat[p] = AverageMeterToRankingCategory( fAverageMeter );
|
||||
fTotalDP += stageStats.iActualDancePoints[p];
|
||||
}
|
||||
|
||||
SONGMAN->AddScores( nt, bIsHumanPlayer, cat, stageStats.fScore, iRankingIndex );
|
||||
@@ -219,6 +225,13 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl
|
||||
COPY( GAMESTATE->m_RankingCategory, cat );
|
||||
COPY( GAMESTATE->m_iRankingIndex, iRankingIndex );
|
||||
GAMESTATE->m_RankingNotesType = nt;
|
||||
|
||||
// If unlocking is enabled, save the dance points
|
||||
if( PREFSMAN->m_bUseUnlockSystem )
|
||||
{
|
||||
PREFSMAN->m_fDancePointsAccumulated += fTotalDP;
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case course:
|
||||
|
||||
@@ -63,6 +63,7 @@ protected:
|
||||
GradeDisplay m_Grades[NUM_PLAYERS];
|
||||
|
||||
// points area
|
||||
bool m_bNewSongsUnlocked;
|
||||
Sprite m_sprPercentFrame[NUM_PLAYERS];
|
||||
BitmapText m_textPercentWhole[NUM_PLAYERS];
|
||||
BitmapText m_textPercentRemainder[NUM_PLAYERS];
|
||||
|
||||
@@ -31,6 +31,7 @@ enum {
|
||||
GO_EASTER_EGGS,
|
||||
GO_MARVELOUS,
|
||||
GO_PICK_EXTRA_STAGE,
|
||||
GO_UNLOCK_SYSTEM,
|
||||
NUM_GAMEPLAY_OPTIONS_LINES
|
||||
};
|
||||
|
||||
@@ -40,7 +41,8 @@ OptionRow g_GameplayOptionsLines[NUM_GAMEPLAY_OPTIONS_LINES] = {
|
||||
OptionRow( "Hidden\nSongs", "OFF","ON" ),
|
||||
OptionRow( "Easter\nEggs", "OFF","ON" ),
|
||||
OptionRow( "Marvelous\nTiming", "OFF","ON" ),
|
||||
OptionRow( "Pick Extra\nStage", "OFF","ON" )
|
||||
OptionRow( "Pick Extra\nStage", "OFF","ON" ),
|
||||
OptionRow( "Unlock\nSystem", "OFF","ON" )
|
||||
};
|
||||
|
||||
ScreenGameplayOptions::ScreenGameplayOptions() :
|
||||
@@ -66,6 +68,7 @@ void ScreenGameplayOptions::ImportOptions()
|
||||
m_iSelectedOption[0][GO_EASTER_EGGS] = PREFSMAN->m_bEasterEggs ? 1:0;
|
||||
m_iSelectedOption[0][GO_MARVELOUS] = PREFSMAN->m_bMarvelousTiming ? 1:0;
|
||||
m_iSelectedOption[0][GO_PICK_EXTRA_STAGE] = PREFSMAN->m_bPickExtraStage? 1:0;
|
||||
m_iSelectedOption[0][GO_UNLOCK_SYSTEM] = PREFSMAN->m_bUseUnlockSystem? 1:0;
|
||||
}
|
||||
|
||||
void ScreenGameplayOptions::ExportOptions()
|
||||
@@ -76,6 +79,7 @@ void ScreenGameplayOptions::ExportOptions()
|
||||
PREFSMAN->m_bEasterEggs = m_iSelectedOption[0][GO_EASTER_EGGS] == 1;
|
||||
PREFSMAN->m_bMarvelousTiming = m_iSelectedOption[0][GO_MARVELOUS] == 1;
|
||||
PREFSMAN->m_bPickExtraStage = m_iSelectedOption[0][GO_PICK_EXTRA_STAGE] == 1;
|
||||
PREFSMAN->m_bUseUnlockSystem = m_iSelectedOption[0][GO_UNLOCK_SYSTEM] == 1;
|
||||
}
|
||||
|
||||
void ScreenGameplayOptions::GoToPrevState()
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "global.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenUnlock.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "GameState.h"
|
||||
#include "RageLog.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->UnlockingSys.NumPointsUntilNextUnlock() );
|
||||
|
||||
// Remove the decimal
|
||||
if( sDP.Find(".",1) > 0 )
|
||||
{
|
||||
sDP = sDP.Left(sDP.Find(".",1));
|
||||
}
|
||||
|
||||
// No negative numbers
|
||||
if( sDP.Left(1) == "-" )
|
||||
{
|
||||
sDP = "*";
|
||||
};
|
||||
|
||||
PointsUntilNextUnlock.SetText( sDP );
|
||||
PointsUntilNextUnlock.SetZoom( 3 );
|
||||
PointsUntilNextUnlock.SetXY( 10, 370 );
|
||||
this->AddChild( &PointsUntilNextUnlock );
|
||||
}
|
||||
@@ -8,15 +8,18 @@
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "ScreenAttract.h"
|
||||
#include "GameConstantsAndTypes.h" // for NUM_RANKING_LINES
|
||||
#include "Style.h"
|
||||
|
||||
|
||||
class Course;
|
||||
|
||||
|
||||
class ScreenUnlock : public ScreenAttract
|
||||
{
|
||||
public:
|
||||
ScreenUnlock() : ScreenAttract("ScreenUnlock") { };
|
||||
ScreenUnlock();
|
||||
protected:
|
||||
BitmapText PointsUntilNextUnlock;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ void SortBackgroundChangesArray( vector<BackgroundChange> &arrayBackgroundChange
|
||||
//////////////////////////////
|
||||
Song::Song()
|
||||
{
|
||||
m_bIsLocked = false;
|
||||
m_bChangedSinceSave = false;
|
||||
m_fBeat0OffsetInSeconds = 0;
|
||||
m_fMusicSampleStartSeconds = -1;
|
||||
|
||||
@@ -347,6 +347,9 @@ int main(int argc, char* argv[])
|
||||
"(Advanced: To allow use of the software renderer, set 'AllowSoftwareRenderer=1' "
|
||||
"in StepMania.ini)" );
|
||||
|
||||
/* Load the unlocks into memory */
|
||||
GAMESTATE->UnlockingSys.LoadFromDATFile("Data/Unlocks.dat");
|
||||
|
||||
/* Run the main loop. */
|
||||
GameLoop();
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: UnlockSystem
|
||||
|
||||
Desc: See header.
|
||||
|
||||
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
||||
Kevin Slaughter
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageException.h"
|
||||
#include "RageUtil.h"
|
||||
#include "UnlockSystem.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
#define POINTS_ACCUMULATED_BEFORE_LAST_ROUND // Load from file here
|
||||
|
||||
UnlockSystem::UnlockSystem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool UnlockSystem::SongIsLocked( CString sSongName )
|
||||
{
|
||||
sSongName.MakeUpper(); //Avoid case-sensitive problems
|
||||
for( unsigned i=0; i<m_SongEntries.size(); i++ )
|
||||
{
|
||||
if( sSongName == m_SongEntries[i].m_sSongName )
|
||||
{
|
||||
if( PREFSMAN->m_fDancePointsAccumulated >= m_SongEntries[i].m_fDancePointsRequired ) { LOG->Trace(" *This song is UNLOCKED"); return false; }
|
||||
else { LOG->Trace(" *This song is LOCKED"); return true; };
|
||||
}
|
||||
else { continue; };
|
||||
}
|
||||
|
||||
LOG->Trace( " *This song is UNLOCKED (wasn't locked in the first place)" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int CompareSongEntries(const SongEntry &se1, const SongEntry &se2)
|
||||
{
|
||||
return se1.m_fDancePointsRequired < se2.m_fDancePointsRequired;
|
||||
}
|
||||
void UnlockSystem::SortSongEntriesArray()
|
||||
{
|
||||
sort( m_SongEntries.begin(), m_SongEntries.end(), CompareSongEntries );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool UnlockSystem::LoadFromDATFile( CString sPath )
|
||||
{
|
||||
LOG->Trace( "\n\n\n\nUnlockSystem::LoadFromDATFile(%s)", sPath.c_str() );
|
||||
|
||||
ifstream input(sPath);
|
||||
if(input.bad())
|
||||
{
|
||||
LOG->Warn( "Error opening file '%s' for reading.", sPath.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
string line;
|
||||
m_SongEntries.clear();
|
||||
|
||||
while(input.good() && getline(input, line))
|
||||
{
|
||||
if(!line.compare(0, 2, "//")) //Check for comments
|
||||
continue;
|
||||
|
||||
/* "[data1] data2". Ignore whitespace at the beginning of the line. */
|
||||
static Regex x("^ *\\[([^]]+)\\] *(.*)$");
|
||||
|
||||
vector<CString> matches;
|
||||
if(!x.Compare(line, matches))
|
||||
continue;
|
||||
|
||||
CString &sValueName = matches[0];
|
||||
CString &sValueData = matches[1];
|
||||
StripCrnl(sValueData);
|
||||
|
||||
// Handle our data
|
||||
if( 0==stricmp(sValueName,"DP") ) // This means the DancePoints value is coming up
|
||||
{
|
||||
float DP;
|
||||
CString SongName;
|
||||
DP = (float)atof( sValueData.Left(sValueData.Find("|",1)) );
|
||||
SongName = (CString)sValueData.Right( sValueData.GetLength() - (sValueData.Find("|",1)+1) );
|
||||
SongName.MakeUpper(); // Avoid case-sensitive problems
|
||||
|
||||
SongEntry SE;
|
||||
SE.m_fDancePointsRequired = DP;
|
||||
SE.m_sSongName = SongName.c_str();
|
||||
m_SongEntries.push_back( SE );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
float UnlockSystem::NumPointsUntilNextUnlock()
|
||||
{
|
||||
float fSmallestPoints;
|
||||
fSmallestPoints = m_SongEntries[0].m_fDancePointsRequired;
|
||||
for( unsigned a=0; a<m_SongEntries.size(); a++ )
|
||||
{
|
||||
if( m_SongEntries[a].m_fDancePointsRequired >= fSmallestPoints )
|
||||
{
|
||||
fSmallestPoints = m_SongEntries[a].m_fDancePointsRequired;
|
||||
}
|
||||
}
|
||||
|
||||
float fResults = (fSmallestPoints - PREFSMAN->m_fDancePointsAccumulated);
|
||||
return fResults;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef UNLOCK_SYSTEM_H
|
||||
#define UNLOCK_SYSTEM_H
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: UnlockSystem
|
||||
|
||||
Desc: See header.
|
||||
|
||||
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
||||
Kevin Slaughter
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
struct SongEntry
|
||||
{
|
||||
float m_fDancePointsRequired; // Ammount of Dance Points needed to unlock this song
|
||||
CString m_sSongName; /* Name of the song in the DWI/SM file itself.. This allows
|
||||
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.*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
class UnlockSystem
|
||||
{
|
||||
public:
|
||||
UnlockSystem();
|
||||
float NumPointsUntilNextUnlock();
|
||||
bool SongIsLocked( CString sSongName );
|
||||
bool LoadFromDATFile( CString sPath );
|
||||
bool m_bAllSongsAreUnlocked; // Quick way to check if all songs are unlocked
|
||||
vector<SongEntry> m_SongEntries; // All locked songs are stored here
|
||||
|
||||
private:
|
||||
void SortSongEntriesArray();
|
||||
};
|
||||
#endif
|
||||
@@ -163,6 +163,7 @@ public:
|
||||
bool HasMovieBackground() const;
|
||||
bool HasBGChanges() const;
|
||||
bool HasLyrics() const;
|
||||
bool m_bIsLocked;
|
||||
|
||||
vector<BPMSegment> m_BPMSegments; // this must be sorted before gameplay
|
||||
vector<StopSegment> m_StopSegments; // this must be sorted before gameplay
|
||||
|
||||
Reference in New Issue
Block a user