05-17-2009, 09:31 AM
|
#1 | |||
|
REAL STEPPING ROOTS '09
|
Post rating: rate
hi I just made up this framework for a custom MemoryCardDisplay.
Comments should explain most of it. If it's not clear/you didn't know, to broadcast a message, use MESSAGEMAN:Broadcast("messageName") and to send params, pass in a table as the second parameter MESSAGEMAN:Broadcast("messageName",{ Param1 = "a", Param2 = true }) Code:
--[[
a custom MemoryCardDisplay | AJ @ KKI Labs
The basic idea is by capturing the messages sent about memory cards, as
well as being able to query the memory card state, one can make a custom
MemoryCardDisplay that isn't limited to being a Sprite.
I have included some example code that I would use if I were to flesh this
out fully. It is commented out since you may wish to implement
things differently. Feel free to use this. Interesting things await.
]]
local Player = ...;
assert(Player)
local MemCardDisplay = Def.ActorFrame{};
--[[ begin heavy lifting code ]]
-- parts list:
-- (1) list of states
local cardStates = {
'MemoryCardState_ready',
'MemoryCardState_checking',
'MemoryCardState_late',
'MemoryCardState_error',
'MemoryCardState_removed',
'MemoryCardState_none'
};
-- (1) knowledge of MEMCARDMAN:GetCardState(Player);
-- (2) knowledge of messages
-- Message_StorageDevicesChanged
-- (MessageID)(Message_CardRemovedP 1+p); // so 1 or 2
-- the gameplan
-- Message_StorageDevicesChanged is our reset function. It may as well be
-- treated as the init function as well, for safety. Might get lucky.
local lastSeenState = 'MemoryCardState_Invalid';
MemCardDisplay[#MemCardDisplay+1] = Def.Actor{
Name="Controller";
UpdateCommand=function(self)
local newMcs = MEMCARDMAN:GetCardState(Player);
if lastSeenState ~= newMcs then
-- if you have a generic command you want to do when the state
-- is changed, place it here.
-- specific instances are checked below:
--[[
for i=1,#cardStates do
if newMcs == cardStates[i] then
-- swap states here.
-- if this were me, it'd be:
--MESSAGEMAN:Broadcast("CardStateOn",{ State = newMcs });
end;
-- this part is optional but recommended if using my method.
if lastSeenState == cardStates[i] then
--MESSAGEMAN:Broadcast("CardStateOff",{ State = newMcs });
end;
end
]]
-- StepMania's MemoryCardDisplay just sets the visible values
-- of the different sprites.
-- if this were completely implemented by me, I would broadcast
-- a message with two parameters, on and off. Ideally, these would
-- be the names of the Actors/ActorFrames/whatever, and they would
-- have two MessageCommands:
-- CardStateOnMessageCommand({State}) -- called when CardState is turned on
-- CardStateOffMessageCommand({State}) -- called when CardState is turned off
-- and finally update the lastSeenState.
lastSeenState = newMcs;
end;
end;
StorageDevicesChangedMessageCommand=function(self)
-- init code
end;
CardRemovedP1MessageCommand=function(self)
if Player == PLAYER_1 then
-- cleanup, play animation
--MESSAGEMAN:Broadcast("CardStateOff",{ State = newMcs });
end;
end;
CardRemovedP2MessageCommand=function(self)
if Player == PLAYER_2 then
-- cleanup, play animation
--MESSAGEMAN:Broadcast("CardStateOff",{ State = newMcs });
end;
end;
};
--[[ end heavy lifting code ]]
return MemCardDisplay;
__________________
Event mode exists for a reason. Use it. ![]() We're doing it for fun, we're doing it because we can, we're doing it because we're SSC. Follow @kki_ssc on Twitter for KKI Labs/spinal shark collective news as it breaks! |
|||
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Custom user name | akstylish | Chit-chat | 22 | 02-11-2009 02:15 PM |
| Custom mods | Reiser | Theme/Noteskin Help/Questions/Requests | 6 | 08-09-2008 12:53 AM |
| Custom I/O-module | henke37 | StepMania Wish list | 0 | 07-06-2007 12:41 PM |
| CUSTOM SONGS | jeffrey1790 | General questions | 3 | 05-30-2007 01:39 AM |
| End of custom song... | StepmaniaFreak | Song and Course questions | 1 | 05-28-2007 05:00 AM |
|
|
All times are GMT. The time now is 12:55 PM.
|