From 2f57a6cb78d2c4296f8a1797a1a97ce081b031c4 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Fri, 20 Jul 2012 23:51:28 -0500 Subject: [PATCH 1/6] actually get this to compile. --- src/ActorUtil.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp index 6105d9881f..cc44b0b6ea 100644 --- a/src/ActorUtil.cpp +++ b/src/ActorUtil.cpp @@ -442,6 +442,18 @@ namespace lua_pushboolean( L, IsRegistered(SArg(1)) ); return 1; } + static int LoadAllCommands( lua_State *L ) + { + Actor *p = Luna::check( L, 1 ); + ActorUtil::LoadAllCommands( p, SArg(2) ); + return 0; + } + static int LoadAllCommandsFromName( lua_State *L ) + { + Actor *p = Luna::check( L, 1 ); + ActorUtil::LoadAllCommandsFromName( *p, SArg(2), SArg(3) ); + return 0; + } static int LoadAllCommandsAndSetXY( lua_State *L ) { Actor *p = Luna::check( L, 1 ); From 1d5f4379bc1b4e9d66e87fea4cfd6ee6eaaf51c4 Mon Sep 17 00:00:00 2001 From: Patrick McIlroy Date: Sat, 21 Jul 2012 00:39:18 -0700 Subject: [PATCH 2/6] Fix edgecases presented by bugzilla #740: fallback to .sm file if .ssc file in cache is missing --- src/Steps.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Steps.cpp b/src/Steps.cpp index 83f0ab3445..70c6edc168 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -108,7 +108,27 @@ bool Steps::GetNoteDataFromSimfile() if (extension.empty() || extension == "ssc") // remember cache files. { SSCLoader loader; - return loader.LoadNoteDataFromSimfile(stepFile, *this); + if ( ! loader.LoadNoteDataFromSimfile(stepFile, *this) ) + { + /* + HACK: 7/20/12 -- see bugzilla #740 + users who edit songs using the ever popular .sm file + that remove or tamper with the .ssc file later on + complain of blank steps in the editor after reloading. + Despite the blank steps being well justified since + the cache files contain only the SSC step file, + give the user some leeway and search for a .sm replacement + */ + SMLoader backup_loader; + RString transformedStepFile = stepFile; + transformedStepFile.Replace(".ssc", ".sm"); + + return backup_loader.LoadNoteDataFromSimfile(transformedStepFile, *this); + } + else + { + return true; + } } else if (extension == "sm") { From 2b21a91f91b253638a9779244880b0c81a438f89 Mon Sep 17 00:00:00 2001 From: Flameshadowxeroshin Date: Sun, 22 Jul 2012 11:44:45 -0500 Subject: [PATCH 3/6] Add ResetSelection binding to MusicWheel, add MusicWheel to Luadocs --- Docs/Luadoc/Lua.xml | 4 ++++ Docs/Luadoc/LuaDocumentation.xml | 8 ++++++++ src/MusicWheel.cpp | 2 ++ 3 files changed, 14 insertions(+) diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 6eaa249d63..76476fd88b 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -889,6 +889,10 @@ + + + + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 052cb597a4..6bc7b1e69f 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -2609,6 +2609,14 @@ save yourself some time, copy this for undocumented things: Loads the ModIconRow of Player pn from the Metrics in group sMetricsGroup. + + + Returns true if the MusicWheel is currently handling Roulette selection. + + + Tries to set the MusicWheel's selection based on preferred song, preferred course, and current sort order. Returns false on failure. + + Returns a command from the specified element and value. diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 04714fba25..964f73ae4c 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -1619,10 +1619,12 @@ class LunaMusicWheel: public Luna { public: static int IsRouletting( T* p, lua_State *L ){ lua_pushboolean( L, p->IsRouletting() ); return 1; } + static int ResetSelection( T* p, lua_State *L ){ lua_pushboolean( L, p->SelectSongOrCourse() ); return 1; } LunaMusicWheel() { ADD_METHOD( IsRouletting ); + ADD_METHOD( ResetSelection ); } }; From c2bc9d1ff3a6dea29702f4096062cdffcb2dbaeb Mon Sep 17 00:00:00 2001 From: Flameshadowxeroshin Date: Sun, 22 Jul 2012 12:05:19 -0500 Subject: [PATCH 4/6] if you fail to reach the top the more you break the more you drop. try it again. try it again. --- Docs/Luadoc/Lua.xml | 3 ++- Docs/Luadoc/LuaDocumentation.xml | 7 +++++-- src/MusicWheel.cpp | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 76476fd88b..a8edb5afde 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -891,7 +891,8 @@ - + + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 6bc7b1e69f..1fb73dd675 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -2613,8 +2613,11 @@ save yourself some time, copy this for undocumented things: Returns true if the MusicWheel is currently handling Roulette selection. - - Tries to set the MusicWheel's selection based on preferred song, preferred course, and current sort order. Returns false on failure. + + Selects a song. Returns false on failure. + + + Selects a course. Returns false on failure. diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 964f73ae4c..52c15b4e94 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -1619,12 +1619,25 @@ class LunaMusicWheel: public Luna { public: static int IsRouletting( T* p, lua_State *L ){ lua_pushboolean( L, p->IsRouletting() ); return 1; } - static int ResetSelection( T* p, lua_State *L ){ lua_pushboolean( L, p->SelectSongOrCourse() ); return 1; } + static int SelectSong( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); return 1; } + else { Song *pS = Luna::check( L, 1, true ); lua_pushboolean( L, p->SelectSong( pS ) ); } + return 1; + } + static int SelectCourse( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); return 1; } + else { Course *pC = Luna::check( L, 1, true ); lua_pushboolean( L, p->SelectSong( pC ) ); } + return 1; + } + LunaMusicWheel() { ADD_METHOD( IsRouletting ); - ADD_METHOD( ResetSelection ); + ADD_METHOD( SelectSong ); + ADD_METHOD( SelectCourse ); } }; From 1fc5fe100ecb6c9bd9d166f0f65d0b6a71830fd2 Mon Sep 17 00:00:00 2001 From: Flameshadowxeroshin Date: Sun, 22 Jul 2012 12:26:43 -0500 Subject: [PATCH 5/6] prepare for vyhdycokio anger --- src/MusicWheel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 52c15b4e94..48a7b07a59 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -1621,14 +1621,14 @@ public: static int IsRouletting( T* p, lua_State *L ){ lua_pushboolean( L, p->IsRouletting() ); return 1; } static int SelectSong( T* p, lua_State *L ) { - if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); return 1; } + if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); } else { Song *pS = Luna::check( L, 1, true ); lua_pushboolean( L, p->SelectSong( pS ) ); } return 1; } static int SelectCourse( T* p, lua_State *L ) { - if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); return 1; } - else { Course *pC = Luna::check( L, 1, true ); lua_pushboolean( L, p->SelectSong( pC ) ); } + if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); } + else { Course *pC = Luna::check( L, 1, true ); lua_pushboolean( L, p->SelectCourse( pC ) ); } return 1; } From 2edd2b31b5db9648be738f40ce9ce9f21ecfdbfb Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 22 Jul 2012 17:07:12 -0500 Subject: [PATCH 6/6] add TrySelectCourse so that SelectCourse can be bound without having to change its protection --- src/MusicWheel.cpp | 12 +- src/MusicWheel.h | 271 +++++++++++++++++++++++---------------------- 2 files changed, 146 insertions(+), 137 deletions(-) diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 48a7b07a59..2c5c837e2f 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -1622,13 +1622,21 @@ public: static int SelectSong( T* p, lua_State *L ) { if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); } - else { Song *pS = Luna::check( L, 1, true ); lua_pushboolean( L, p->SelectSong( pS ) ); } + else + { + Song *pS = Luna::check( L, 1, true ); + lua_pushboolean( L, p->SelectSong( pS ) ); + } return 1; } static int SelectCourse( T* p, lua_State *L ) { if( lua_isnil(L,1) ) { lua_pushboolean( L, false ); } - else { Course *pC = Luna::check( L, 1, true ); lua_pushboolean( L, p->SelectCourse( pC ) ); } + else + { + Course *pC = Luna::check( L, 1, true ); + lua_pushboolean( L, p->TrySelectCourse( pC ) ); + } return 1; } diff --git a/src/MusicWheel.h b/src/MusicWheel.h index 1d029afd07..bbe64c2b91 100644 --- a/src/MusicWheel.h +++ b/src/MusicWheel.h @@ -1,135 +1,136 @@ -/* MusicWheel - A wheel with song names used in the Select Music screen. */ - -#ifndef MUSIC_WHEEL_H -#define MUSIC_WHEEL_H - -#include "RageSound.h" -#include "GameConstantsAndTypes.h" -#include "MusicWheelItem.h" -#include "ThemeMetric.h" -#include "WheelBase.h" - -class Course; -class Song; - -struct CompareSongPointerArrayBySectionName; - -class MusicWheel : public WheelBase -{ - friend struct CompareSongPointerArrayBySectionName; - -public: - virtual ~MusicWheel(); - virtual void Load( RString sType ); - void BeginScreen(); - - bool ChangeSort( SortOrder new_so, bool allowSameSort = false ); // return true if change successful - bool NextSort(); // return true if change successful - void StartRoulette(); - void StartRandom(); - bool IsRouletting() const; - - virtual bool Select(); // return true if this selection ends the screen - WheelItemDataType GetSelectedType() { return GetCurWheelItemData(m_iSelection)->m_Type; } - Song *GetSelectedSong(); - Course *GetSelectedCourse() { return GetCurWheelItemData(m_iSelection)->m_pCourse; } - RString GetSelectedSection() { return GetCurWheelItemData(m_iSelection)->m_sText; } - - Song *GetPreferredSelectionForRandomOrPortal(); - - bool SelectSong( const Song *p ); - bool SelectSection( const RString & SectionName ); - void SetOpenSection( RString group ); - SortOrder GetSortOrder() const { return m_SortOrder; } - virtual void ChangeMusic( int dist ); /* +1 or -1 */ //CHECK THIS - void FinishChangingSorts(); - void PlayerJoined(); - // sm-ssc additions - RString JumpToNextGroup(); - RString JumpToPrevGroup(); - const MusicWheelItemData *GetCurWheelItemData( int i ) { return (const MusicWheelItemData *) m_CurWheelItemData[i]; } - -protected: - MusicWheelItem *MakeItem(); - - void GetSongList( vector &arraySongs, SortOrder so ); - bool SelectSongOrCourse(); - bool SelectCourse( const Course *p ); - bool SelectModeMenuItem(); - - virtual void UpdateSwitch(); - - vector & getWheelItemsData(SortOrder so); - void readyWheelItemsData(SortOrder so); - - RString m_sLastModeMenuItem; - SortOrder m_SortOrder; - RageSound m_soundChangeSort; - - bool WheelItemIsVisible(int n); - - ThemeMetric ROULETTE_SWITCH_SECONDS; - ThemeMetric ROULETTE_SLOW_DOWN_SWITCHES; - ThemeMetric NUM_SECTION_COLORS; - ThemeMetric SONG_REAL_EXTRA_COLOR; - ThemeMetric SORT_MENU_COLOR; - ThemeMetric SHOW_ROULETTE; - ThemeMetric SHOW_RANDOM; - ThemeMetric SHOW_PORTAL; - ThemeMetric RANDOM_PICKS_LOCKED_SONGS; - ThemeMetric MOST_PLAYED_SONGS_TO_SHOW; - ThemeMetric RECENT_SONGS_TO_SHOW; - ThemeMetric MODE_MENU_CHOICE_NAMES; - ThemeMetricMap CHOICE; - ThemeMetric1D SECTION_COLORS; - ThemeMetric SORT_ORDERS; - ThemeMetric SHOW_EASY_FLAG; - // sm-ssc additions: - ThemeMetric USE_SECTIONS_WITH_PREFERRED_GROUP; - ThemeMetric HIDE_INACTIVE_SECTIONS; - ThemeMetric REMIND_WHEEL_POSITIONS; - ThemeMetric ROULETTE_COLOR; - ThemeMetric RANDOM_COLOR; - ThemeMetric PORTAL_COLOR; - ThemeMetric EMPTY_COLOR; - vector m_viWheelPositions; - ThemeMetric CUSTOM_WHEEL_ITEM_NAMES; - ThemeMetricMap CUSTOM_CHOICES; - ThemeMetricMap CUSTOM_CHOICE_COLORS; - -private: - //use getWheelItemsData instead of touching this one - enum {INVALID,NEEDREFILTER,VALID} m_WheelItemDatasStatus[NUM_SortOrder]; - vector m__WheelItemDatas[NUM_SortOrder]; - vector m__UnFilteredWheelItemDatas[NUM_SortOrder]; - - void BuildWheelItemDatas( vector &arrayWheelItems, SortOrder so ); - void FilterWheelItemDatas(vector &aUnFilteredDatas, vector &aFilteredData, SortOrder so ); -}; - -#endif - -/* - * (c) 2001-2004 Chris Danford, Chris Gomez, Glenn Maynard - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ +/* MusicWheel - A wheel with song names used in the Select Music screen. */ + +#ifndef MUSIC_WHEEL_H +#define MUSIC_WHEEL_H + +#include "RageSound.h" +#include "GameConstantsAndTypes.h" +#include "MusicWheelItem.h" +#include "ThemeMetric.h" +#include "WheelBase.h" + +class Course; +class Song; + +struct CompareSongPointerArrayBySectionName; + +class MusicWheel : public WheelBase +{ + friend struct CompareSongPointerArrayBySectionName; + +public: + virtual ~MusicWheel(); + virtual void Load( RString sType ); + void BeginScreen(); + + bool ChangeSort( SortOrder new_so, bool allowSameSort = false ); // return true if change successful + bool NextSort(); // return true if change successful + void StartRoulette(); + void StartRandom(); + bool IsRouletting() const; + + virtual bool Select(); // return true if this selection ends the screen + WheelItemDataType GetSelectedType() { return GetCurWheelItemData(m_iSelection)->m_Type; } + Song *GetSelectedSong(); + Course *GetSelectedCourse() { return GetCurWheelItemData(m_iSelection)->m_pCourse; } + RString GetSelectedSection() { return GetCurWheelItemData(m_iSelection)->m_sText; } + + Song *GetPreferredSelectionForRandomOrPortal(); + + bool SelectSong( const Song *p ); + bool TrySelectCourse( const Course *p ){ return TrySelectCourse(p); } + bool SelectSection( const RString & SectionName ); + void SetOpenSection( RString group ); + SortOrder GetSortOrder() const { return m_SortOrder; } + virtual void ChangeMusic( int dist ); /* +1 or -1 */ //CHECK THIS + void FinishChangingSorts(); + void PlayerJoined(); + // sm-ssc additions + RString JumpToNextGroup(); + RString JumpToPrevGroup(); + const MusicWheelItemData *GetCurWheelItemData( int i ) { return (const MusicWheelItemData *) m_CurWheelItemData[i]; } + +protected: + MusicWheelItem *MakeItem(); + + void GetSongList( vector &arraySongs, SortOrder so ); + bool SelectSongOrCourse(); + bool SelectCourse( const Course *p ); + bool SelectModeMenuItem(); + + virtual void UpdateSwitch(); + + vector & getWheelItemsData(SortOrder so); + void readyWheelItemsData(SortOrder so); + + RString m_sLastModeMenuItem; + SortOrder m_SortOrder; + RageSound m_soundChangeSort; + + bool WheelItemIsVisible(int n); + + ThemeMetric ROULETTE_SWITCH_SECONDS; + ThemeMetric ROULETTE_SLOW_DOWN_SWITCHES; + ThemeMetric NUM_SECTION_COLORS; + ThemeMetric SONG_REAL_EXTRA_COLOR; + ThemeMetric SORT_MENU_COLOR; + ThemeMetric SHOW_ROULETTE; + ThemeMetric SHOW_RANDOM; + ThemeMetric SHOW_PORTAL; + ThemeMetric RANDOM_PICKS_LOCKED_SONGS; + ThemeMetric MOST_PLAYED_SONGS_TO_SHOW; + ThemeMetric RECENT_SONGS_TO_SHOW; + ThemeMetric MODE_MENU_CHOICE_NAMES; + ThemeMetricMap CHOICE; + ThemeMetric1D SECTION_COLORS; + ThemeMetric SORT_ORDERS; + ThemeMetric SHOW_EASY_FLAG; + // sm-ssc additions: + ThemeMetric USE_SECTIONS_WITH_PREFERRED_GROUP; + ThemeMetric HIDE_INACTIVE_SECTIONS; + ThemeMetric REMIND_WHEEL_POSITIONS; + ThemeMetric ROULETTE_COLOR; + ThemeMetric RANDOM_COLOR; + ThemeMetric PORTAL_COLOR; + ThemeMetric EMPTY_COLOR; + vector m_viWheelPositions; + ThemeMetric CUSTOM_WHEEL_ITEM_NAMES; + ThemeMetricMap CUSTOM_CHOICES; + ThemeMetricMap CUSTOM_CHOICE_COLORS; + +private: + //use getWheelItemsData instead of touching this one + enum {INVALID,NEEDREFILTER,VALID} m_WheelItemDatasStatus[NUM_SortOrder]; + vector m__WheelItemDatas[NUM_SortOrder]; + vector m__UnFilteredWheelItemDatas[NUM_SortOrder]; + + void BuildWheelItemDatas( vector &arrayWheelItems, SortOrder so ); + void FilterWheelItemDatas(vector &aUnFilteredDatas, vector &aFilteredData, SortOrder so ); +}; + +#endif + +/* + * (c) 2001-2004 Chris Danford, Chris Gomez, Glenn Maynard + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */