add ScreenSelectMaster:GetSelectionIndex() Lua binding.
Example usage:
LoadFont("Common normal")..{
InitCommand=cmd(xy,SCREEN_RIGHT-32,SCREEN_BOTTOM-32;shadowlength,0;horizalign,right);
OnCommand=cmd(playcommand,"Set");
SetCommand=function(self)
local selIdx = SCREENMAN:GetTopScreen():GetSelectionIndex(GAMESTATE:GetMasterPlayerNumber());
self:settext(selIdx);
end;
MenuSelectionChangedMessageCommand=cmd(playcommand,"Set");
};
This commit is contained in:
+31
-10
@@ -814,7 +814,7 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, MenuDir dir, int iNew
|
||||
|
||||
if( SHOW_ICON )
|
||||
{
|
||||
/* XXX: If !SharedPreviewAndCursor, this is incorrect. (Nothing uses
|
||||
/* XXX: If !SharedPreviewAndCursor, this is incorrect. (Nothing uses
|
||||
* both icon focus and !SharedPreviewAndCursor right now.)
|
||||
* What is SharedPreviewAndCursor? -- Steve */
|
||||
bool bOldStillHasFocus = false;
|
||||
@@ -1119,15 +1119,15 @@ void ScreenSelectMaster::MenuStart( const InputEventPlus &input )
|
||||
this->PostScreenMessage( SM_BeginFadingOut, fSecs );// tell our owner it's time to move on
|
||||
}
|
||||
|
||||
/* We want all items to always run OnCommand and either GainFocus or LoseFocus on
|
||||
* tween-in. If we only run OnCommand, then it has to contain a copy of either
|
||||
* GainFocus or LoseFocus, which implies that the default setting is hard-coded
|
||||
* in the theme. Always run both.
|
||||
* However, the actual tween-in is OnCommand; we don't always want to actually run
|
||||
* through the Gain/LoseFocus tweens during initial tween-in. So, we run the focus
|
||||
* command first, do a FinishTweening to pop it in place, and then run OnCommand.
|
||||
* This means that the focus command should be position neutral; eg. only use "addx",
|
||||
* not "x". */
|
||||
/* We want all items to always run OnCommand and either GainFocus or LoseFocus
|
||||
* on tween-in. If we only run OnCommand, then it has to contain a copy of
|
||||
* either GainFocus or LoseFocus, which implies that the default setting is
|
||||
* hard-coded in the theme. Always run both.
|
||||
* However, the actual tween-in is OnCommand; we don't always want to actually
|
||||
* run through the Gain/LoseFocus tweens during initial tween-in. So, we run
|
||||
* the focus command first, do a FinishTweening to pop it in place, and then
|
||||
* run OnCommand. This means that the focus command should be position neutral;
|
||||
* eg. only use "addx", not "x". */
|
||||
void ScreenSelectMaster::TweenOnScreen()
|
||||
{
|
||||
vector<PlayerNumber> vpns;
|
||||
@@ -1273,6 +1273,27 @@ float ScreenSelectMaster::GetCursorY( PlayerNumber pn )
|
||||
return spr->GetDestY() + CURSOR_OFFSET_Y_FROM_ICON.GetValue(pn);
|
||||
}
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
class LunaScreenSelectMaster: public Luna<ScreenSelectMaster>
|
||||
{
|
||||
public:
|
||||
static int GetSelectionIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->GetSelectionIndexOfPlayer(Enum::Check<PlayerNumber>(L, 1)) ); return 1; }
|
||||
// should I even bother adding this? -aj
|
||||
// would have to make a public function to get this in ssmaster.h:
|
||||
// m_aGameCommands[i].m_sName
|
||||
// static int SelectionIndexToChoiceName( T* p, lua_State *L ){ return 1; }
|
||||
|
||||
LunaScreenSelectMaster()
|
||||
{
|
||||
ADD_METHOD( GetSelectionIndex );
|
||||
}
|
||||
};
|
||||
|
||||
LUA_REGISTER_DERIVED_CLASS( ScreenSelectMaster, ScreenWithMenuElements )
|
||||
// lua end
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -39,6 +39,12 @@ public:
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
virtual bool AllowLateJoin() const { return true; }
|
||||
|
||||
// sm-ssc additions:
|
||||
int GetSelectionIndexOfPlayer(PlayerNumber pn){ return GetSelectionIndex(pn); }
|
||||
|
||||
// Lua
|
||||
virtual void PushSelf( lua_State *L );
|
||||
|
||||
protected:
|
||||
enum Page { PAGE_1, PAGE_2, NUM_Page }; // on PAGE_2, cursors are locked together
|
||||
static PlayerNumber GetSharedPlayer();
|
||||
@@ -75,7 +81,6 @@ protected:
|
||||
map<int,int> m_mapCurrentChoiceToNextChoice[NUM_MenuDir];
|
||||
map<int,int> m_mapCurrentChoiceToNextChoiceB[NUM_MenuDir]; // if using two lists
|
||||
|
||||
|
||||
virtual int GetSelectionIndex( PlayerNumber pn );
|
||||
virtual void UpdateSelectableChoices();
|
||||
bool AnyOptionsArePlayable() const;
|
||||
@@ -93,16 +98,14 @@ protected:
|
||||
AutoActor m_sprMore[NUM_Page];
|
||||
// icon is the shared, per-choice piece
|
||||
vector<AutoActor> m_vsprIcon;
|
||||
vector<AutoActor> m_vsprIconB; // used if the user wants two lists
|
||||
vector<AutoActor> m_vsprIconB; // used if a themer wants two lists
|
||||
|
||||
// preview is per-player, per-choice piece
|
||||
vector<AutoActor> m_vsprScroll[NUM_PLAYERS];
|
||||
vector<AutoActor> m_vsprScrollB[NUM_PLAYERS]; // used if the user wants two lists
|
||||
|
||||
vector<AutoActor> m_vsprScrollB[NUM_PLAYERS]; // used if a themer wants two lists
|
||||
|
||||
ActorScroller m_Scroller[NUM_PLAYERS];
|
||||
ActorScroller m_ScrollerB[NUM_PLAYERS]; // used if the user wants two lists
|
||||
|
||||
ActorScroller m_ScrollerB[NUM_PLAYERS]; // used if a themer wants two lists
|
||||
|
||||
// cursor is the per-player, shared by all choices
|
||||
AutoActor m_sprCursor[NUM_PLAYERS];
|
||||
|
||||
Reference in New Issue
Block a user