Skip to content

Instantly share code, notes, and snippets.

@hanubeki
Last active April 11, 2020 11:52
Show Gist options
  • Save hanubeki/15905cfe3d85b5ca40c97ad0b69f76bc to your computer and use it in GitHub Desktop.
Save hanubeki/15905cfe3d85b5ca40c97ad0b69f76bc to your computer and use it in GitHub Desktop.
MusicWheelの楽曲とフォーカス状態が書き換わった回数をカウントするテスト
local count = 0
return Def.ActorFrame {
LoadActor("_MusicWheelItem Song NormalPart"),
Def.ActorFrame {
LoadFont("Common Normal") .. {
Text = "",
InitCommand = function(self)
self:x(200):strokecolor({0,0,0,1})
end,
UpdateChildMessageCommand = function(self, params)
local parent = self:GetParent()
if params.id ~= parent.Params.id then return end
-- local r = parent.Params.id
local tx = params.Song and params.Song:GetSongDir() or ""
self:settext((params.HasFocus and "HasFocus" or "DoesntHave") .. "\n" .. tx)
SCREENMAN:SystemMessage("UpdateChildMessage: " .. count)
end
},
UpdatedMessageCommand = function(self, params)
local parent = self:GetParent()
if params.id ~= parent.Params.id then return end
self.Params = {id = parent.Params.id}
SCREENMAN:SystemMessage("UpdatedMessage: " .. count)
MESSAGEMAN:Broadcast("UpdateChild", params)
end
},
SetCommand = function(self, params)
if not self.Params then
-- [ja] どうやらInitCommandで初期化するのは駄目らしい
self.Params = {id = math.random(), Song = nil, HadFocus = nil}
end
if params and params.HasFocus ~= nil and params.Song and (params.Song ~= self.Params.Song or params.HasFocus ~= self.Params.HadFocus) then
-- [ja] SongかHasFocusが書き換わったときにBroadcast送信
self.Params.Song = params.Song
self.Params.HadFocus = params.HasFocus
params.id = self.Params.id
count = count + 1
SCREENMAN:SystemMessage("Set: " .. count)
MESSAGEMAN:Broadcast("Updated", params)
end
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment