add lua bindings

This commit is contained in:
Chris Danford
2005-07-29 22:59:11 +00:00
parent 5d35c1dc18
commit c9718db4b6
7 changed files with 87 additions and 8 deletions
+31
View File
@@ -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<MAX_ITEMS; i++ )
@@ -40,6 +43,13 @@ void CourseContentsList::Load()
}
}
void CourseContentsList::LoadFromNode( const CString& sDir, const XNode* pNode )
{
ActorScroller::LoadFromNode( sDir, pNode );
Load();
}
void CourseContentsList::SetFromGameState()
{
RemoveAllChildren();
@@ -109,6 +119,27 @@ void CourseContentsList::TweenInAfterChangedCourse()
*/
}
// lua start
#include "LuaBinding.h"
class LunaCourseContentsList: public Luna<CourseContentsList>
{
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<T>::Register( L );
}
};
LUA_REGISTER_DERIVED_CLASS( CourseContentsList, ActorScroller )
// lua end
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
+5
View File
@@ -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;
+3 -3
View File
@@ -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 );
+6 -5
View File
@@ -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<bool> SEPARATE_COURSE_METERS;
ThemeMetric<CString> TEXT_BANNER_TYPE;
};
#endif
+15
View File
@@ -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<Song>::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<Course>::check(L,1); p->LoadFromCourse( pC ); }
return 0;
}
static void Register(lua_State *L)
{
ADD_METHOD( ScaleToClipped )
ADD_METHOD( LoadFromSong )
ADD_METHOD( LoadFromCourse )
Luna<T>::Register( L );
}
};
+23
View File
@@ -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<PaneDisplay>
{
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<T>::Register( L );
}
};
LUA_REGISTER_DERIVED_CLASS( PaneDisplay, ActorFrame )
// lua end
/*
* (c) 2003 Glenn Maynard
* All rights reserved.
+4
View File
@@ -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;