Added keybinding for reloading songs on SSM, and lua function for doing it from lua. Added NeverCacheList preference for WIP groups that should never be cached. Rewrote TimingData::CopyRange in preparation for using it to copy/paste timing data from the selected area in edit mode.

This commit is contained in:
Kyzentun
2015-03-31 15:20:37 -06:00
parent 0e66d625e6
commit 2b4cabfb57
9 changed files with 86 additions and 20 deletions
+8
View File
@@ -4,6 +4,14 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
________________________________________________________________________________
2015/03/30
----------
* [Select Music] Ctrl+Shift+R mapped to reload the current song. [kyzentun]
* [Song] ReloadFromSongDir lua function exposed. [kyzentun]
* [Preferences] NeverCacheList preference added. It's a comma separated
list of group names, if a song is in one of the named groups, it is never
cached. [kyzentun]
2015/03/27
----------
* [Select Music] Ability to delete the current song by pressing Ctrl+Backspace added. [Wallacoloo]
+1
View File
@@ -193,6 +193,7 @@ PrefsManager::PrefsManager() :
//m_BackgroundCache ( "BackgroundCache", BGCACHE_LOW_RES_PRELOAD ),
m_bFastLoad ( "FastLoad", true ),
m_bFastLoadAdditionalSongs ( "FastLoadAdditionalSongs", true ),
m_NeverCacheList("NeverCacheList", ""),
m_bOnlyDedicatedMenuButtons ( "OnlyDedicatedMenuButtons", false ),
m_bMenuTimer ( "MenuTimer", false ),
+1
View File
@@ -185,6 +185,7 @@ public:
//Preference<BackgroundCacheMode> m_BackgroundCache;
Preference<bool> m_bFastLoad;
Preference<bool> m_bFastLoadAdditionalSongs;
Preference<RString> m_NeverCacheList;
Preference<bool> m_bOnlyDedicatedMenuButtons;
Preference<bool> m_bMenuTimer;
+16 -1
View File
@@ -441,10 +441,25 @@ bool ScreenSelectMusic::Input( const InputEventPlus &input )
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RCTRL));
bool holding_shift=
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT));
wchar_t c = INPUTMAN->DeviceInputToChar(input.DeviceI,false);
MakeUpper( &c, 1 );
if( bHoldingCtrl && ( c >= 'A' ) && ( c <= 'Z' ) )
if(holding_shift && bHoldingCtrl && c == 'R' && m_MusicWheel.IsSettled())
{
// Reload the currently selected song. -Kyz
Song* to_reload= m_MusicWheel.GetSelectedSong();
if(to_reload)
{
to_reload->ReloadFromSongDir();
AfterMusicChange();
return true;
}
}
else if( bHoldingCtrl && ( c >= 'A' ) && ( c <= 'Z' ) )
{
// Only allow changing the sort order if the wheel is not locked
// and we're not in course mode. -aj
+28
View File
@@ -17,8 +17,10 @@
#include "Sprite.h"
#include "RageFileManager.h"
#include "RageSurface.h"
#include "RageTextureManager.h"
#include "NoteDataUtil.h"
#include "SongUtil.h"
#include "SongManager.h"
#include "StepsUtil.h"
#include "Foreach.h"
#include "BackgroundUtil.h"
@@ -455,6 +457,28 @@ bool Song::ReloadFromSongDir( RString sDir )
}
AddAutoGenNotes();
// Reload any images associated with the song. -Kyz
vector<RString> to_reload;
to_reload.reserve(7);
to_reload.push_back(m_sBannerFile);
to_reload.push_back(m_sJacketFile);
to_reload.push_back(m_sCDFile);
to_reload.push_back(m_sDiscFile);
to_reload.push_back(m_sBackgroundFile);
to_reload.push_back(m_sCDTitleFile);
to_reload.push_back(m_sPreviewVidFile);
for(vector<RString>::iterator file= to_reload.begin(); file != to_reload.end(); ++file)
{
RageTextureID id(*file);
if(TEXTUREMAN->IsTextureRegistered(id))
{
RageTexture* tex= TEXTUREMAN->LoadTexture(id);
if(tex)
{
tex->Reload();
}
}
}
return true;
}
@@ -1224,6 +1248,10 @@ bool Song::SaveToJsonFile( RString sPath )
bool Song::SaveToCacheFile()
{
if(SONGMAN->IsGroupNeverCached(m_sGroupName))
{
return true;
}
SONGINDEX->AddCacheIndex(m_sSongDir, GetHashForDirectory(m_sSongDir));
const RString sPath = GetCacheFilePath();
return SaveToSSCFile(sPath, true);
+12
View File
@@ -91,6 +91,13 @@ SongManager::~SongManager()
void SongManager::InitAll( LoadingWindow *ld )
{
vector<RString> never_cache;
split(PREFSMAN->m_NeverCacheList, ",", never_cache);
for(vector<RString>::iterator group= never_cache.begin();
group != never_cache.end(); ++group)
{
m_GroupsToNeverCache.insert(*group);
}
InitSongsFromDisk( ld );
InitCoursesFromDisk( ld );
InitAutogenCourses();
@@ -469,6 +476,11 @@ void SongManager::UnlistSong(Song *song)
}
}
bool SongManager::IsGroupNeverCached(const RString& group) const
{
return m_GroupsToNeverCache.find(group) != m_GroupsToNeverCache.end();
}
RString SongManager::GetSongGroupBannerPath( RString sSongGroup ) const
{
for( unsigned i = 0; i < m_sSongGroupNames.size(); ++i )
+3
View File
@@ -68,6 +68,8 @@ public:
void Reload( bool bAllowFastLoad, LoadingWindow *ld=NULL ); // songs, courses, groups - everything.
void PreloadSongImages();
bool IsGroupNeverCached(const RString& group) const;
RString GetSongGroupBannerPath( RString sSongGroup ) const;
//RString GetSongGroupBackgroundPath( RString sSongGroup ) const;
void GetSongGroupNames( vector<RString> &AddTo ) const;
@@ -182,6 +184,7 @@ protected:
/** @brief All of the songs that can be played. */
vector<Song*> m_pSongs;
map<RString, Song*> m_SongsByDir;
set<RString> m_GroupsToNeverCache;
/** @brief Hold pointers to all the songs that have been deleted from disk but must at least be kept temporarily alive for smooth audio transitions. */
vector<Song*> m_pDeletedSongs;
/** @brief The most popular songs ranked by number of plays. */
+16 -18
View File
@@ -164,31 +164,29 @@ bool TimingData::empty() const
return true;
}
TimingData TimingData::CopyRange(int startRow, int endRow) const
void TimingData::CopyRange(int start_row, int end_row,
TimingSegmentType copy_type, int dest_row, TimingData& dest) const
{
TimingData ret;
FOREACH_TimingSegmentType( tst )
int row_offset= dest_row - start_row;
FOREACH_TimingSegmentType(seg_type)
{
const vector<TimingSegment*> &vSegs = GetTimingSegments(tst);
for (unsigned i = 0; i < vSegs.size(); i++)
if(seg_type == copy_type || copy_type == TimingSegmentType_Invalid)
{
const TimingSegment *seg = vSegs[i];
int row = seg->GetRow();
if (row >= startRow && row < endRow)
const vector<TimingSegment*>& segs= GetTimingSegments(seg_type);
for(size_t i= 0; i < segs.size(); ++i)
{
TimingSegment *cpy = seg->Copy();
// offset rows as though startRow were beat 0.
cpy->SetRow(seg->GetRow() - startRow);
ret.AddSegment(cpy);
if(segs[i]->GetRow() >= start_row && segs[i]->GetRow() <= end_row)
{
TimingSegment* copy= segs[i]->Copy();
copy->SetRow(segs[i]->GetRow() + row_offset);
dest.AddSegment(copy);
// TimingSegment::Copy creates a new segment with new, and
// AddSegment copies it again, so delete the temp. -Kyz
delete copy;
}
}
}
}
return ret;
}
void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut, float highest ) const
+1 -1
View File
@@ -149,7 +149,7 @@ public:
bool empty() const;
TimingData CopyRange(int startRow, int endRow) const;
void CopyRange(int start_row, int end_row, TimingSegmentType copy_type, int dest_row, TimingData& dest) const;
/**
* @brief Gets the actual BPM of the song,
* while respecting a limit.