From c9718db4b64bb77128e60f55fca3451693b11aad Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 29 Jul 2005 22:59:11 +0000 Subject: [PATCH] add lua bindings --- stepmania/src/CourseContentsList.cpp | 31 ++++++++++++++++++++++++++++ stepmania/src/CourseContentsList.h | 5 +++++ stepmania/src/CourseEntryDisplay.cpp | 6 +++--- stepmania/src/CourseEntryDisplay.h | 11 +++++----- stepmania/src/FadingBanner.cpp | 15 ++++++++++++++ stepmania/src/PaneDisplay.cpp | 23 +++++++++++++++++++++ stepmania/src/PaneDisplay.h | 4 ++++ 7 files changed, 87 insertions(+), 8 deletions(-) diff --git a/stepmania/src/CourseContentsList.cpp b/stepmania/src/CourseContentsList.cpp index fcf646b70a..d10d7858bd 100644 --- a/stepmania/src/CourseContentsList.cpp +++ b/stepmania/src/CourseContentsList.cpp @@ -13,10 +13,13 @@ #include "Style.h" #include "RageTexture.h" #include "CourseEntryDisplay.h" +#include "ActorUtil.h" const int MAX_VISIBLE_ITEMS = 5; const int MAX_ITEMS = MAX_VISIBLE_ITEMS+2; +REGISTER_ACTOR_CLASS( CourseContentsList ) + CourseContentsList::CourseContentsList() { for( int i=0; i +{ +public: + LunaCourseContentsList() { LUA->Register( Register ); } + + static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(); return 0; } + + static void Register(lua_State *L) + { + ADD_METHOD( SetFromGameState ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( CourseContentsList, ActorScroller ) +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/CourseContentsList.h b/stepmania/src/CourseContentsList.h index 8fbeb1e2ed..3d0c2c5467 100644 --- a/stepmania/src/CourseContentsList.h +++ b/stepmania/src/CourseContentsList.h @@ -11,12 +11,17 @@ class CourseContentsList : public ActorScroller public: CourseContentsList(); ~CourseContentsList(); + virtual Actor *Copy() const; void Load(); + void LoadFromNode( const CString& sDir, const XNode* pNode ); void SetFromGameState(); void TweenInAfterChangedCourse(); + // Lua + void PushSelf( lua_State *L ); + protected: Quad m_quad; diff --git a/stepmania/src/CourseEntryDisplay.cpp b/stepmania/src/CourseEntryDisplay.cpp index 780dd8a444..5080f5f678 100644 --- a/stepmania/src/CourseEntryDisplay.cpp +++ b/stepmania/src/CourseEntryDisplay.cpp @@ -13,11 +13,11 @@ #include "Style.h" #include "ActorUtil.h" -#define SEPARATE_COURSE_METERS THEME->GetMetricB(m_sName,"SeparateCourseMeters") -#define TEXT_BANNER_TYPE THEME->GetMetric (m_sName,"TextBannerType") - void CourseEntryDisplay::Load() { + SEPARATE_COURSE_METERS .Load( "CourseEntryDisplay", "SeparateCourseMeters" ); + TEXT_BANNER_TYPE .Load( "CourseEntryDisplay", "TextBannerType" ); + m_sprFrame.SetName( "Bar" ); m_sprFrame.Load( THEME->GetPathG("CourseEntryDisplay","bar") ); SET_XY_AND_ON_COMMAND( &m_sprFrame ); diff --git a/stepmania/src/CourseEntryDisplay.h b/stepmania/src/CourseEntryDisplay.h index f669be1532..314f97248d 100644 --- a/stepmania/src/CourseEntryDisplay.h +++ b/stepmania/src/CourseEntryDisplay.h @@ -3,15 +3,13 @@ #ifndef COURSE_ENTRY_DISPLAY_H #define COURSE_ENTRY_DISPLAY_H +#include "ActorFrame.h" #include "BitmapText.h" #include "TextBanner.h" -#include "ActorFrame.h" #include "Sprite.h" -#include "GameConstantsAndTypes.h" -class Course; -class Song; -class Steps; +#include "PlayerNumber.h" struct TrailEntry; +#include "ThemeMetric.h" class CourseEntryDisplay : public ActorFrame { @@ -29,6 +27,9 @@ private: BitmapText m_textFoot[NUM_PLAYERS]; BitmapText m_textDifficultyNumber[NUM_PLAYERS]; BitmapText m_textModifiers; + + ThemeMetric SEPARATE_COURSE_METERS; + ThemeMetric TEXT_BANNER_TYPE; }; #endif diff --git a/stepmania/src/FadingBanner.cpp b/stepmania/src/FadingBanner.cpp index 0a2dff0635..9f671d7cb0 100644 --- a/stepmania/src/FadingBanner.cpp +++ b/stepmania/src/FadingBanner.cpp @@ -184,6 +184,14 @@ void FadingBanner::LoadFromSongGroup( CString sSongGroup ) void FadingBanner::LoadFromCourse( const Course* pCourse ) { + if( pCourse == NULL ) + { + LoadFallback(); + return; + } + + /* Don't call HasBanner. That'll do disk access and cause the music wheel + * to skip. */ LoadFromCachedBanner( pCourse->m_sBannerPath ); } @@ -221,11 +229,18 @@ public: else { Song *pS = Luna::check(L,1); p->LoadFromSong( pS ); } return 0; } + static int LoadFromCourse( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) { p->LoadFromCourse( NULL ); } + else { Course *pC = Luna::check(L,1); p->LoadFromCourse( pC ); } + return 0; + } static void Register(lua_State *L) { ADD_METHOD( ScaleToClipped ) ADD_METHOD( LoadFromSong ) + ADD_METHOD( LoadFromCourse ) Luna::Register( L ); } }; diff --git a/stepmania/src/PaneDisplay.cpp b/stepmania/src/PaneDisplay.cpp index 47360db5ac..aead7a78c1 100644 --- a/stepmania/src/PaneDisplay.cpp +++ b/stepmania/src/PaneDisplay.cpp @@ -49,6 +49,8 @@ static const Content_t g_Contents[NUM_PANE_CONTENTS] = { "CourseRolls", PANE_COURSE_MACHINE_SCORES, NEED_COURSE } }; +REGISTER_ACTOR_CLASS( PaneDisplay ) + PaneDisplay::PaneDisplay() { m_CurPane = PANE_INVALID; @@ -323,6 +325,27 @@ void PaneDisplay::SetFocus( PaneTypes NewPane ) m_CurPane = NewPane; } + +// lua start +#include "LuaBinding.h" + +class LunaPaneDisplay: public Luna +{ +public: + LunaPaneDisplay() { LUA->Register( Register ); } + + static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(SORT_PREFERRED); return 0; } + + static void Register(lua_State *L) + { + ADD_METHOD( SetFromGameState ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( PaneDisplay, ActorFrame ) +// lua end + /* * (c) 2003 Glenn Maynard * All rights reserved. diff --git a/stepmania/src/PaneDisplay.h b/stepmania/src/PaneDisplay.h index 09835e650b..b8d5d96fc6 100644 --- a/stepmania/src/PaneDisplay.h +++ b/stepmania/src/PaneDisplay.h @@ -49,10 +49,14 @@ class PaneDisplay: public ActorFrame { public: PaneDisplay(); + virtual Actor *Copy() const; void Load( const CString &sClass, PlayerNumber pn ); void SetFromGameState( SortOrder so ); + // Lua + void PushSelf( lua_State *L ); + private: void SetFocus( PaneTypes NewPane ); PaneTypes GetPane() const;