Merge pull request #206 from kyzentun/InputCallbacks

This seems solid in my testing, I've converted Consensual to use it instead of CodeMessageCommand.
This commit is contained in:
kyzentun
2014-07-03 23:15:03 -06:00
9 changed files with 204 additions and 1 deletions
+7
View File
@@ -1293,11 +1293,13 @@
<Class base='BitmapText' name='ScoreDisplayAliveTime'/>
<Class base='BitmapText' name='ScoreDisplayCalories'/>
<Class base='ActorFrame' name='Screen'>
<Function name='AddInputCallback'/>
<Function name='GetNextScreenName'/>
<Function name='GetPrevScreenName'/>
<Function name='GetScreenType'/>
<Function name='Metric'/>
<Function name='PostScreenMessage'/>
<Function name='RemoveInputCallback'/>
<Function name='String'/>
<Function name='lockinput'/>
</Class>
@@ -2032,6 +2034,11 @@
<EnumValue name='&apos;HorizAlign_Center&apos;' value='1'/>
<EnumValue name='&apos;HorizAlign_Right&apos;' value='2'/>
</Enum>
<Enum name='InputEventType'>
<EnumValue name='&apos;InputEventType_FirstPress&apos;' value= '0'/>
<EnumValue name='&apos;InputEventType_Repeat&apos;' value= '1'/>
<EnumValue name='&apos;InputEventType_Release&apos;' value= '2'/>
</Enum>
<Enum name='JudgmentLine'>
<EnumValue name='&apos;JudgmentLine_W1&apos;' value='0'/>
<EnumValue name='&apos;JudgmentLine_W2&apos;' value='1'/>
+27
View File
@@ -3672,6 +3672,30 @@ save yourself some time, copy this for undocumented things:
</Function>
</Class>
<Class name='Screen'>
<Function name='AddInputCallback' return='void' arguments='function callback'>
This adds the lua function "callback" to the list of functions the screen will pass input to. Whenever an input event occurs, callback will be passed a table with the details of the event. callback must return a bool to indicate whether the event was handled. If callback returns true, the event will not be passed any further.<br/>
This should not be used to provide text input because that would not handle localization or different keyboard layouts.<br/>
The screen and the callbacks will both be passed input events, so be aware of what input the current screen responds to and consider the effects.<br/>
Details of the table containing the event data:<br/>
{<br/>
DeviceInput= { -- The raw details of the event.<br/>
device= string, -- The type of device. The first half of the string will be "Device_", the second half will be from InputDeviceNames in RageInputDevice.cpp.<br/>
button= string, -- The button that was pressed. the first half of the string will be "DeviceButton_", the second half will be from InitNames in RageInputDevice.cpp.<br/>
level= float, -- A floating point value for analog input.<br/>
z= float, -- Mousewheel input.<br/>
down= bool, -- Whether the button is down. This is level with a threshold and debouncing applied.<br/>
ago= float, -- How long ago this input occurred, in seconds.<br/>
is_joystick= bool, -- True if the device is a joystick.<br/>
is_mouse= bool -- True if the device is a mouse.<br/>
},<br/>
controller= string, -- The game controller this event was mapped to. "GameController_1" or "GameController_2", or nil if the event wasn't mapped to either controller.
button= string, -- The semi-raw button that was pressed. This is what the button was mapped to by the keymap settings, but without the conversions that occur when OnlyDedicatedMenuButtons is true. Will be empty if the button was not mapped.<br/>
type= string, -- The type of event. "InputEventType_FirstPress", "InputEventType_Repeat", or "InputEventType_Release".<br/>
GameButton= string, -- The cooked button that was pressed. This is button with mapping that occurs when OnlyDedicatedMenuButtons is true applied. This is nil for unmapped buttons.<br/>
PlayerNumber= PlayerNumber, -- The player that the controller is mapped to, or nil.<br/>
MultiPlayer= string, -- Unknown purpose.<br/>
}
</Function>
<Function name='GetNextScreenName' return='string' arguments=''>
Returns the name of the next Screen.
</Function>
@@ -3690,6 +3714,9 @@ save yourself some time, copy this for undocumented things:
<Function name='PostScreenMessage' return='void' arguments='string sScreenMsg, float fDelay'>
Posts a message with the text <code>sScreenMsg</code> to the Screen after <code>fDelay</code> seconds.
</Function>
<Function name='RemoveInputCallback' return='void' arguments='function callback'>
This removes the callback from the list.
</Function>
<Function name='String' theme='_fallback' return='string' arguments='string sName'>
[02 Other.lua] Gets a string from the current Screen in the current language.
</Function>