From 18f7dea5f9c4667d03da4eaee480a5d1d9d1214c Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 27 Feb 2011 18:36:05 -0600 Subject: [PATCH] [PlayerState] The old GetPlayerOptions() binding is now GetPlayerOptionsString(). There is a new GetPlayerOptions() binding that gets the PlayerOptions object, which has a GetNoteSkin() binding (and hopefully more in the future). --- Docs/Changelog_sm-ssc.txt | 6 ++++++ src/PlayerOptions.cpp | 18 ++++++++++++++++++ src/PlayerOptions.h | 5 ++++- src/PlayerState.cpp | 12 ++++++++++-- src/PlayerState.h | 6 +++++- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Docs/Changelog_sm-ssc.txt b/Docs/Changelog_sm-ssc.txt index 9f28860874..37608ac651 100644 --- a/Docs/Changelog_sm-ssc.txt +++ b/Docs/Changelog_sm-ssc.txt @@ -13,6 +13,12 @@ _____________________________________________________________________________ sm-ssc v1.2.3 | 2011022? -------------------------------------------------------------------------------- +20110227 +-------- +* [PlayerState] The old GetPlayerOptions() binding is now GetPlayerOptionsString(). + There is a new GetPlayerOptions() binding that gets the PlayerOptions object, + which has a GetNoteSkin() binding (and hopefully more in the future). [AJ] + 20110226 -------- * [ScreenOptionsToggleSongs] The structure of this screen has now changed. diff --git a/src/PlayerOptions.cpp b/src/PlayerOptions.cpp index 87352f4233..d55d068249 100644 --- a/src/PlayerOptions.cpp +++ b/src/PlayerOptions.cpp @@ -823,6 +823,24 @@ void PlayerOptions::ResetPrefs( ResetPrefsType type ) #undef CPY } +// lua start +#include "LuaBinding.h" + +/** @brief Allow Lua to have access to PlayerOptions. */ +class LunaPlayerOptions: public Luna +{ +public: + DEFINE_METHOD( GetNoteSkin, m_sNoteSkin ) + + LunaPlayerOptions() + { + ADD_METHOD( GetNoteSkin ); + } +}; + +LUA_REGISTER_CLASS( PlayerOptions ) +// lua end + /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/src/PlayerOptions.h b/src/PlayerOptions.h index f6df9e2eff..b7a9ee7957 100644 --- a/src/PlayerOptions.h +++ b/src/PlayerOptions.h @@ -5,6 +5,7 @@ class Course; class Song; class Steps; class Trail; +struct lua_State; #include "GameConstantsAndTypes.h" #include "PlayerNumber.h" @@ -32,6 +33,9 @@ public: void ChooseRandomModifiers(); bool ContainsTransformOrTurn() const; + // Lua + void PushSelf( lua_State *L ); + bool operator==( const PlayerOptions &other ) const; bool operator!=( const PlayerOptions &other ) const { return !operator==(other); } @@ -188,7 +192,6 @@ public: void SetOneScroll( Scroll s ); void ToggleOneTurn( Turn t ); - // return true if any mods being used will make the song(s) easier bool IsEasierForSongAndSteps( Song* pSong, Steps* pSteps, PlayerNumber pn ) const; bool IsEasierForCourseAndTrail( Course* pCourse, Trail* pTrail ) const; diff --git a/src/PlayerState.cpp b/src/PlayerState.cpp index aa512ecbaf..2525c60872 100644 --- a/src/PlayerState.cpp +++ b/src/PlayerState.cpp @@ -210,8 +210,8 @@ public: static int GetPlayerOptions( T* p, lua_State *L ) { ModsLevel m = Enum::Check( L, 1 ); - RString s = p->m_PlayerOptions.Get(m).GetString(); - LuaHelpers::Push( L, s ); + PlayerOptions po = p->m_PlayerOptions.Get(m); + po.PushSelf(L); return 1; } static int GetPlayerOptionsArray( T* p, lua_State *L ) @@ -222,6 +222,13 @@ public: LuaHelpers::CreateTableFromArray( s, L ); return 1; } + static int GetPlayerOptionsString( T* p, lua_State *L ) + { + ModsLevel m = Enum::Check( L, 1 ); + RString s = p->m_PlayerOptions.Get(m).GetString(); + LuaHelpers::Push( L, s ); + return 1; + } DEFINE_METHOD( GetHealthState, m_HealthState ); LunaPlayerState() @@ -231,6 +238,7 @@ public: ADD_METHOD( SetPlayerOptions ); ADD_METHOD( GetPlayerOptions ); ADD_METHOD( GetPlayerOptionsArray ); + ADD_METHOD( GetPlayerOptionsString ); ADD_METHOD( GetHealthState ); } }; diff --git a/src/PlayerState.h b/src/PlayerState.h index e023bb7df0..06bd6acb35 100644 --- a/src/PlayerState.h +++ b/src/PlayerState.h @@ -31,7 +31,11 @@ public: * in PlayerState and callers should not use PlayerNumber to index into * GameState. */ PlayerNumber m_PlayerNumber; - + /** + * @brief The MultiPlayer number assigned to this Player, typically 1-32. + * + * This is only used if GAMESTATE->m_bMultiplayer is true. + */ MultiPlayer m_mp; /**