Add Pack Offset and Group Banners to pack.ini, Remove debug logging

This commit is contained in:
Crash Cringle
2025-03-03 23:25:32 -08:00
committed by teejusb
parent 5e6f3378a8
commit 798201cce4
9 changed files with 60 additions and 107 deletions
-17
View File
@@ -756,18 +756,9 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
for( unsigned i=0; i< arraySongs.size(); i++ )
{
Song* pSong = arraySongs[i];
LOG->Trace("SORT_GROUP PREPACK");
Pack* pPack = pSong->GetPack();
if( bUseSections )
{
// Print out everything about the pack and song
LOG->Trace("Sort Title: %s", pPack->m_sSortTitle);
LOG->Trace("Group Name: %s", pPack->m_sGroupName);
LOG->Trace("Has PackIni: %s", pPack->m_bHasPackIni ? "true" : "false");
LOG->Trace("Display Title: %s", pPack->m_sDisplayTitle);
LOG->Trace("Song Title: %s", pSong->GetDisplayFullTitle());
LOG->Trace("Group Name from Song: %s", pSong->m_sGroupName.c_str());
LOG->Trace("Offset: %d", pPack->m_iSyncOffset);
RString sThisSection = pSong->GetPack()->m_sSortTitle;
if (pPack->m_bHasPackIni) {
LOG->Trace("HE GOT DA INI");
@@ -778,28 +769,22 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
int iSectionCount = 0;
// Count songs in this section
unsigned j;
LOG->Trace("SORT_GROUP AYA21YA: %s", sThisSection.c_str());
for( j=i; j < arraySongs.size(); j++ )
{
if( SongUtil::GetSectionNameFromSongAndSort( arraySongs[j], so ) != sThisSection )
break;
}
LOG->Trace("SORT_GROUP AYA22YA: %s", sThisSection.c_str());
iSectionCount = j-i;
// new section, make a section item
// todo: preferred sort section color handling? -aj
RageColor colorSection = (so==SORT_GROUP) ? SONGMAN->GetSongGroupColor(sThisSection) : SECTION_COLORS.GetValue(iSectionColorIndex);
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
LOG->Trace("SORT_GROUP BEFORE: %s", sThisSection.c_str());
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, nullptr, sThisSection, nullptr, pPack, colorSection, iSectionCount) );
sLastSection = sThisSection;
LOG->Trace("SORT_GROUP AFTER: %s", sLastSection.c_str());
}
}
LOG->Trace("SORT_GROUP AYAYA: %s", sLastSection.c_str());
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, nullptr, pPack, SONGMAN->GetSongColor(pSong), 0) );
LOG->Trace("SORT_GROUP Pushed back Successfully: %s", sLastSection.c_str());
}
break;
@@ -851,7 +836,6 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
if( SHOW_RANDOM && bFoundAnySong )
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Random, nullptr, "", nullptr, nullptr, RANDOM_COLOR, 0) );
LOG->Trace("CRINGLEBINGLE3");
if( SHOW_PORTAL && bFoundAnySong )
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Portal, nullptr, "", nullptr, nullptr, PORTAL_COLOR, 0) );
@@ -987,7 +971,6 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
{
RageColor c = SECTION_COLORS.GetValue(iSectionColorIndex);
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
LOG->Trace("CRINGLEBINGLE7");
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, nullptr, sThisSection, nullptr, nullptr, c, 0) );
sLastSection = sThisSection;
}
+4 -17
View File
@@ -209,7 +209,6 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int
{
DEFAULT_FAIL( pWID->m_Type );
case WheelItemDataType_Song:
LOG->Trace( "MusicWheelItem::LoadFromWheelItemData() - Song" );
type = MusicWheelItemType_Song;
m_TextBanner.SetFromSong( pWID->m_pSong );
@@ -223,33 +222,22 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int
break;
case WheelItemDataType_Section:
{
LOG->Trace( "MusicWheelItem::LoadFromWheelItemData() - Section" );
if ( pWID->m_pPack == nullptr ) {
LOG->Trace( "MusicWheelItem::LoadFromWheelItemData() - Section with no pack" );
sDisplayName = SONGMAN->ShortenGroupName(pWID->m_sText);
}
else {
if ( pWID->m_pPack->m_sDisplayTitle == "" ) {
LOG->Trace( "MusicWheelItem::LoadFromWheelItemData() - Section with no display title" );
}
// Log everything about the wheel
LOG->Trace( "Pack Display Title: %s", pWID->m_pPack->m_sDisplayTitle.c_str() );
LOG->Trace( "Pack Sort Title: %s", pWID->m_pPack->m_sSortTitle.c_str() );
LOG->Trace( "Pack Group Name: %s", pWID->m_pPack->m_sGroupName.c_str() );
LOG->Trace( "Pack Has PackIni: %s", pWID->m_pPack->m_bHasPackIni ? "true" : "false" );
sDisplayName = SONGMAN->ShortenGroupName(pWID->m_pPack->m_sDisplayTitle);
LOG->Trace( "Pack Display Title Shortened: %s", sDisplayName.c_str() );
if ( pWID->m_pPack->m_sSeries.empty() )
sDisplayName = SONGMAN->ShortenGroupName(pWID->m_sText);
else
sDisplayName = SONGMAN->ShortenGroupName("["+pWID->m_pPack->m_sSeries+"] "+pWID->m_pPack->m_sDisplayTitle);
}
if( GAMESTATE->sExpandedSectionName == pWID->m_sText )
type = MusicWheelItemType_SectionExpanded;
else
type = MusicWheelItemType_SectionCollapsed;
LOG->Trace( "MusicWheelItem::LoadFromWheelItemData() - SectionDone1: %s", sDisplayName.c_str() );
m_pTextSectionCount->SetText( ssprintf("%d",pWID->m_iSectionCount) );
m_pTextSectionCount->SetVisible( true );
LOG->Trace( "MusicWheelItem::LoadFromWheelItemData() - SectionDone: %s", sDisplayName.c_str() );
}
break;
case WheelItemDataType_Course:
@@ -260,7 +248,6 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int
m_WheelNotifyIcon.SetVisible( true );
break;
case WheelItemDataType_Sort:
LOG->Trace( "MusicWheelItem::LoadFromWheelItemData() - Sort" );
sDisplayName = pWID->m_sLabel;
// hack to get mode items working. -freem
if( pWID->m_pAction->m_pm != PlayMode_Invalid )
+6 -37
View File
@@ -1195,45 +1195,14 @@ void Profile::LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot)
RageTimer song_load_start_time;
song_load_start_time.Touch();
FILEMAN->GetDirListing(songs_folder + "/*", song_folders, true, true);
// Check for pack.ini
RString sGroupIniPath = songs_folder + "/pack.ini";
RString sDisplayTitle;
RString SortTitle;
RString TranslitTitle;
RString Series;
int iOffset = 0;
Pack pack;
if( FILEMAN->DoesFileExist( sGroupIniPath ) )
{
IniFile ini;
ini.ReadFile( sGroupIniPath );
ini.GetValue( "Group", "DisplayTitle", sDisplayTitle );
if (sDisplayTitle.empty())
sDisplayTitle = "Custom Songs";
ini.GetValue( "Group", "SortTitle", SortTitle );
if (SortTitle.empty())
SortTitle = sDisplayTitle;
ini.GetValue( "Group", "TranslitTitle", TranslitTitle );
if (TranslitTitle.empty())
TranslitTitle = sDisplayTitle;
ini.GetValue( "Group", "Series", Series );
ini.GetValue( "Group", "Offset", iOffset );
} else {
sDisplayTitle = "Custom Songs";
SortTitle = "Custom Songs";
TranslitTitle ="";
Series = "";
iOffset = 0;
}
pack.m_sDisplayTitle = sDisplayTitle;
pack.m_sSortTitle = SortTitle;
pack.m_sTranslitTitle = TranslitTitle;
pack.m_sSeries = Series;
pack.m_iSyncOffset = iOffset;
pack.m_sDisplayTitle = m_sDisplayName;
pack.m_sSortTitle = m_sDisplayName;
pack.m_sTranslitTitle = m_sDisplayName;
pack.m_sSeries = "";
pack.m_iSyncOffset = 0;
pack.m_sPath = songs_folder;
pack.m_sGroupName = "Custom Songs";
pack.m_sGroupName = m_sDisplayName;
StripCvsAndSvn(song_folders);
StripMacResourceForks(song_folders);
+2 -1
View File
@@ -73,9 +73,10 @@ struct Pack
RString m_sGroupName;
RString m_sTranslitTitle;
RString m_sSeries;
int m_iSyncOffset;
float m_iSyncOffset;
bool m_bHasPackIni;
int iTotalSongs;
RString m_sBannerPath;
};
/** @brief Holds all music metadata and steps for one song. */
+37 -20
View File
@@ -277,15 +277,21 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName, Pack pack )
if( j != m_sSongGroupNames.size() )
return; // the group is already added
RString sBannerPath;
// Look for a group banner in this group folder
std::vector<RString> arrayGroupBanners;
// First check if there is a banner provided in pack.ini
if( pack.m_sBannerPath != "" )
{
GetDirListing( sDir+sGroupDirName+"/"+pack.m_sBannerPath, arrayGroupBanners );
}
GetDirListing( sDir+sGroupDirName+"/*.png", arrayGroupBanners );
GetDirListing( sDir+sGroupDirName+"/*.jpg", arrayGroupBanners );
GetDirListing( sDir+sGroupDirName+"/*.jpeg", arrayGroupBanners );
GetDirListing( sDir+sGroupDirName+"/*.gif", arrayGroupBanners );
GetDirListing( sDir+sGroupDirName+"/*.bmp", arrayGroupBanners );
RString sBannerPath;
if( !arrayGroupBanners.empty() )
sBannerPath = sDir+sGroupDirName+"/"+arrayGroupBanners[0] ;
else
@@ -335,6 +341,7 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName, Pack pack )
*/
m_sSongGroupNames.push_back( sGroupDirName );
m_sSongGroupBannerPaths.push_back( sBannerPath );
if (m_mapGroupToPack.find(sGroupDirName) == m_mapGroupToPack.end())
{
m_mapGroupToPack[sGroupDirName] = pack;
@@ -345,18 +352,12 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName, Pack pack )
// Add the pack to its series if the pack has one and if the series exists
// if( pack.m_sSeries != "" )
// {
// if (m_mapSeries.find(pack.m_sSeries) == m_mapSeries.end())
// {
// m_mapSeries[pack.m_sSeries] = std::vector<Pack*>();
// m_mapSeries[pack.m_sSeries].push_back(pack);
// } else {
// m_mapSeries[pack.m_sSeries]->packs.push_back(pack);
// }
// }
if( pack.m_sSeries != "" )
{
std::vector<Pack*>& series = m_mapSeries[pack.m_sSeries];
if( std::find(series.begin(), series.end(), &pack) == series.end() )
series.push_back(&pack);
}
//m_sSongGroupBackgroundPaths.push_back( sBackgroundPath );
}
@@ -444,7 +445,8 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
RString SortTitle = sGroupDirName;
RString TranslitTitle = sGroupDirName;
RString Series = "";
int iOffset = 0;
RString bannerPath = "";
float fOffset = 0;
Pack pack;
if( FILEMAN->DoesFileExist( sGroupIniPath ) && arraySongDirs.size() > 0 )
@@ -455,6 +457,7 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
ini.GetValue( "Group", "DisplayTitle", sDisplayTitle );
if (sDisplayTitle.empty())
sDisplayTitle = group_base_name;
ini.GetValue( "Group", "Banner", bannerPath );
ini.GetValue( "Group", "SortTitle", SortTitle );
if (SortTitle.empty())
SortTitle = sDisplayTitle;
@@ -462,24 +465,21 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
if (TranslitTitle.empty())
TranslitTitle = sDisplayTitle;
ini.GetValue( "Group", "Series", Series );
ini.GetValue( "Group", "SyncOffsetMs", iOffset );
ini.GetValue( "Group", "SyncOffsetMs", fOffset );
LOG->Trace("Loaded pack.ini for \"%s\"", (sDir+sGroupDirName).c_str() );
// LOG THE RECEIVED INFO
LOG->Trace("DisplayTitle: %s", sDisplayTitle.c_str());
LOG->Trace("SortTitle: %s", SortTitle.c_str());
pack.m_bHasPackIni = true;
} else {
LOG->Trace("No pack.ini found for \"%s\"", (sDir+sGroupDirName).c_str() );
LOG-> Trace("Using default values for pack.ini");
LOG-> Trace("DisplayTitle: %s", sDisplayTitle.c_str());
LOG-> Trace("SortTitle: %s", SortTitle.c_str());
pack.m_bHasPackIni = false;
}
pack.m_sDisplayTitle = sDisplayTitle;
pack.m_sSortTitle = SortTitle;
pack.m_sTranslitTitle = TranslitTitle;
pack.m_sSeries = Series;
pack.m_iSyncOffset = iOffset;
pack.m_iSyncOffset = fOffset;
pack.m_sBannerPath = bannerPath;
pack.m_sPath = sDir + sGroupDirName;
pack.m_sGroupName = group_base_name;
@@ -517,6 +517,23 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
delete pNewSong;
continue;
}
// Apply Pack Offset if applicable
if( pack.m_iSyncOffset != 0 )
{
LOG->Trace("Applying pack offset of %i ms to \"%s\"", pack.m_iSyncOffset, pNewSong->GetSongDir().c_str() );
pNewSong->m_SongTiming.m_fBeat0PackOffsetInSeconds = pack.m_iSyncOffset;
const std::vector<Steps*>& vpSteps = pNewSong->GetAllSteps();
for (Steps *s : vpSteps)
{
// Empty TimingData means it's inherited
// from the song and is already changed.
if( s->m_Timing.empty() )
continue;
s->m_Timing.m_fBeat0PackOffsetInSeconds = pack.m_iSyncOffset;
}
}
AddSongToList(pNewSong);
index_entry.push_back( pNewSong );
+1
View File
@@ -246,6 +246,7 @@ protected:
std::vector<RString> m_sSongGroupNames;
std::vector<RString> m_sSongGroupBannerPaths; // each song group may have a banner associated with it
//vector<RString> m_sSongGroupBackgroundPaths; // each song group may have a background associated with it (very rarely)
std::map<RString, Pack> m_mapGroupToPack;
std::map<RString, std::vector<Pack*>> m_mapSeries;
-9
View File
@@ -608,18 +608,9 @@ int SongUtil::CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
static int CompareSongPointersByGroupAndTitle( const Song *pSong1, const Song *pSong2 )
{
LOG->Trace("SongUtil::CompareSongPointersByGroupAndTitle: %s %s", pSong1->m_sSongName.c_str(), pSong2->m_sSongName.c_str());
// Check if the sort title exists
const RString &sGroup1 = pSong1->GetPack()->m_sSortTitle;
const RString &sGroup2 = pSong2->GetPack()->m_sSortTitle;
LOG->Trace(pSong1->GetDisplayMainTitle().c_str());
LOG->Trace(sGroup1.c_str());
LOG->Trace(sGroup2.c_str());
LOG->Trace(pSong2->GetPack()->m_sGroupName.c_str());
LOG->Trace(pSong2->GetPack()->m_sDisplayTitle.c_str());
// Log whether bHasPackIni is true or false
LOG->Trace("bHasPackIni: %s", pSong1->GetPack()->m_bHasPackIni ? "true" : "false");
LOG->Trace("EUREKA!!! %s %s", sGroup1.c_str(), sGroup2.c_str());
if( sGroup1 < sGroup2 )
return true;
+6 -5
View File
@@ -18,7 +18,7 @@ static const int INVALID_INDEX = -1;
TimingSegment* GetSegmentAtRow( int iNoteRow, TimingSegmentType tst );
TimingData::TimingData(float fOffset) : m_fBeat0OffsetInSeconds(fOffset)
TimingData::TimingData(float fOffset) : m_fBeat0OffsetInSeconds(fOffset), m_fBeat0PackOffsetInSeconds(0.0f)
{
}
@@ -28,6 +28,7 @@ void TimingData::Copy( const TimingData& cpy )
Clear();
m_fBeat0OffsetInSeconds = cpy.m_fBeat0OffsetInSeconds;
m_fBeat0PackOffsetInSeconds = cpy.m_fBeat0PackOffsetInSeconds;
m_sFile = cpy.m_sFile;
FOREACH_TimingSegmentType( tst )
@@ -102,14 +103,14 @@ void TimingData::PrepareLookup()
curr_segment < total_segments; curr_segment+= segments_per_lookup)
{
GetBeatStarts beat_start;
beat_start.last_time= -m_fBeat0OffsetInSeconds;
beat_start.last_time= -m_fBeat0OffsetInSeconds - m_fBeat0PackOffsetInSeconds;
GetBeatArgs args;
args.elapsed_time= FLT_MAX;
GetBeatInternal(beat_start, args, curr_segment);
m_beat_start_lookup.push_back(lookup_item_t(args.elapsed_time, beat_start));
GetBeatStarts time_start;
time_start.last_time= -m_fBeat0OffsetInSeconds;
time_start.last_time= -m_fBeat0OffsetInSeconds - m_fBeat0PackOffsetInSeconds;
m_time_start_lookup.push_back(lookup_item_t(NoteRowToBeat(time_start.last_row), time_start));
}
// If there are less than two entries, then FindEntryInLookup in lookup
@@ -916,7 +917,7 @@ void TimingData::GetBeatInternal(GetBeatStarts& start, GetBeatArgs& args,
void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset(GetBeatArgs& args) const
{
GetBeatStarts start;
start.last_time= -m_fBeat0OffsetInSeconds;
start.last_time= -m_fBeat0OffsetInSeconds - m_fBeat0PackOffsetInSeconds;
beat_start_lookup_t::const_iterator looked_up_start=
FindEntryInLookup(m_beat_start_lookup, args.elapsed_time);
if(looked_up_start != m_beat_start_lookup.end())
@@ -1001,7 +1002,7 @@ float TimingData::GetElapsedTimeFromBeat( float fBeat ) const
float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
{
GetBeatStarts start;
start.last_time= -m_fBeat0OffsetInSeconds;
start.last_time= -m_fBeat0OffsetInSeconds - m_fBeat0PackOffsetInSeconds;
beat_start_lookup_t::const_iterator looked_up_start=
FindEntryInLookup(m_time_start_lookup, fBeat);
if(looked_up_start != m_time_start_lookup.end())
+4 -1
View File
@@ -64,7 +64,7 @@ public:
/**
* @brief Sets up initial timing data with a defined offset.
* @param fOffset the offset from the 0th beat. */
TimingData( float fOffset = 0 );
TimingData( float fOffset = 0);
~TimingData();
void Copy( const TimingData &other );
@@ -460,6 +460,9 @@ public:
/** @brief The initial offset of a song. */
float m_fBeat0OffsetInSeconds;
/** @brief The offset applied to the song's entire pack */
float m_fBeat0PackOffsetInSeconds;
// XXX: this breaks encapsulation. get rid of it ASAP
std::vector<RString> ToVectorString(TimingSegmentType tst, int dec = 6) const;
protected: