Compare commits
No commits in common. "b680bc74912e1ecf95e009bf9955242729dd1b32" and "c48d93d567232aa6ca87224a2407b41cf0766190" have entirely different histories.
b680bc7491
...
c48d93d567
@ -67,22 +67,18 @@ function _draw()
|
|||||||
mode:draw()
|
mode:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if t[mname] is a thing,
|
-- for each object in t, invoke
|
||||||
-- invoke it as a method. else,
|
-- t:mname(), converting mname
|
||||||
-- try each object in t
|
-- from string to method name.
|
||||||
function outer_or_each_opt(t, mname)
|
-- if there is no method by that
|
||||||
local fun = t[mname]
|
-- name, quietly skip it.
|
||||||
if fun then
|
function subeach_opt(t, mname)
|
||||||
fun(t)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
foreach(t, function(o)
|
foreach(t, function(o)
|
||||||
local f = o[mname]
|
local f = o[mname]
|
||||||
if(f) f(o)
|
if(f) f(o)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- generate standard "overlay"
|
-- generate standard "overlay"
|
||||||
-- constructor for type tt.
|
-- constructor for type tt.
|
||||||
-- if more is defined, generated
|
-- if more is defined, generated
|
||||||
@ -109,117 +105,6 @@ function mknew(tt, more)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-->8
|
|
||||||
-- window manager
|
|
||||||
|
|
||||||
-------------------------------
|
|
||||||
-- view
|
|
||||||
-------------------------------
|
|
||||||
-- composits drawable items.
|
|
||||||
-- add items to .views to
|
|
||||||
-- composit them. x and y are
|
|
||||||
-- relative reverse camera
|
|
||||||
-- offsets. drawable items will
|
|
||||||
-- observe appropriate incoming
|
|
||||||
-- camera and clip state.
|
|
||||||
-- clipping respects existing
|
|
||||||
-- clipping so stacked views
|
|
||||||
-- intersect.
|
|
||||||
-------------------------------
|
|
||||||
view = {
|
|
||||||
x=0,
|
|
||||||
y=0,
|
|
||||||
w=128,
|
|
||||||
h=128,
|
|
||||||
}
|
|
||||||
mknew(view, function(x)
|
|
||||||
if (not x.views) x.views = {}
|
|
||||||
end)
|
|
||||||
|
|
||||||
function view.of(subviews)
|
|
||||||
return view.new{views=subviews}
|
|
||||||
end
|
|
||||||
|
|
||||||
function view:update()
|
|
||||||
outer_or_each_opt(self.views, "update")
|
|
||||||
end
|
|
||||||
|
|
||||||
function view:draw()
|
|
||||||
local oldcam, oldclip = $0x5f28, $0x5f20
|
|
||||||
poke2(0x5f28, %0x5f28-self.x)
|
|
||||||
poke2(0x5f2a, %0x5f2a-self.y)
|
|
||||||
clip(-%0x5f28, -%0x5f2a, self.w, self.h, true)
|
|
||||||
outer_or_each_opt(self.views, "draw")
|
|
||||||
poke4(0x5f20, oldclip)
|
|
||||||
poke4(0x5f28, oldcam)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- draws opaque rectangles.
|
|
||||||
-- default bg is equivalent to
|
|
||||||
-- clip-aware cls.
|
|
||||||
-- restores prior fill palette.
|
|
||||||
bg = {
|
|
||||||
x=0,y=0,w=128,h=128,fp=0,c=0
|
|
||||||
}
|
|
||||||
mknew(bg)
|
|
||||||
|
|
||||||
function bg:draw()
|
|
||||||
local oldfp=fillp(self.fp)
|
|
||||||
rectfill(self.x,self.y,self.x+self.w,self.y+self.h,self.c)
|
|
||||||
fillp(oldfp)
|
|
||||||
end
|
|
||||||
|
|
||||||
-------------------------------
|
|
||||||
-- animator
|
|
||||||
-------------------------------
|
|
||||||
-- animator is a drawable item
|
|
||||||
-- that manages a linked list of
|
|
||||||
-- temporary drawables. a
|
|
||||||
-- temporary drawable is dropped
|
|
||||||
-- when its :update returns
|
|
||||||
-- a non-false value.
|
|
||||||
-------------------------------
|
|
||||||
animator = {}
|
|
||||||
mknew(animator)
|
|
||||||
|
|
||||||
function animator:update()
|
|
||||||
local p,n=self, self.next
|
|
||||||
while n do
|
|
||||||
if n.item:update() then
|
|
||||||
local nn = n.next
|
|
||||||
if (not nn) self.tail = p
|
|
||||||
p.next = n.next
|
|
||||||
else
|
|
||||||
p = n
|
|
||||||
end
|
|
||||||
n = p.next
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function animator:draw()
|
|
||||||
local n = self.next
|
|
||||||
while n do
|
|
||||||
n.item:draw()
|
|
||||||
n = n.next
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add a new drawable under all
|
|
||||||
-- existing other items.
|
|
||||||
-- (it draws first)
|
|
||||||
function animator:push_under(i)
|
|
||||||
self.next={next=self.next, item=i}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add a new drawable over all
|
|
||||||
-- existing other items.
|
|
||||||
-- (it draws last)
|
|
||||||
function animator:push_over(i)
|
|
||||||
local target, node = self.tail or self, {item=i}
|
|
||||||
target.next=node
|
|
||||||
self.tail=node
|
|
||||||
end
|
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- title
|
-- title
|
||||||
-- (currently a placeholder)
|
-- (currently a placeholder)
|
||||||
@ -306,6 +191,120 @@ function title:draw()
|
|||||||
print("panel extreme", 1, 1, self.fcol)
|
print("panel extreme", 1, 1, self.fcol)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-->8
|
||||||
|
-- window manager
|
||||||
|
|
||||||
|
-------------------------------
|
||||||
|
-- view
|
||||||
|
-------------------------------
|
||||||
|
-- composits drawable items.
|
||||||
|
-- add items to .views to
|
||||||
|
-- composit them. x and y are
|
||||||
|
-- relative reverse camera
|
||||||
|
-- offsets. drawable items will
|
||||||
|
-- observe appropriate incoming
|
||||||
|
-- camera and clip state.
|
||||||
|
-- clipping respects existing
|
||||||
|
-- clipping so stacked views
|
||||||
|
-- intersect.
|
||||||
|
-------------------------------
|
||||||
|
view = {
|
||||||
|
x=0,
|
||||||
|
y=0,
|
||||||
|
w=128,
|
||||||
|
h=128,
|
||||||
|
}
|
||||||
|
mknew(view, function(x)
|
||||||
|
if (not x.views) x.views = {}
|
||||||
|
end)
|
||||||
|
|
||||||
|
function view.of(subviews)
|
||||||
|
return view.new{views=subviews}
|
||||||
|
end
|
||||||
|
|
||||||
|
function view:update()
|
||||||
|
subeach_opt(self.views, "update")
|
||||||
|
end
|
||||||
|
|
||||||
|
function view:draw()
|
||||||
|
local oldcam, oldclip = $0x5f28, $0x5f20
|
||||||
|
poke2(0x5f28, %0x5f28-self.x)
|
||||||
|
poke2(0x5f2a, %0x5f2a-self.y)
|
||||||
|
clip(-%0x5f28, -%0x5f2a, self.w, self.h, true)
|
||||||
|
subeach_opt(self.views, "draw")
|
||||||
|
poke4(0x5f20, oldclip)
|
||||||
|
poke4(0x5f28, oldcam)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- draws opaque rectangles.
|
||||||
|
-- default bg is equivalent to
|
||||||
|
-- clip-aware cls.
|
||||||
|
-- restores prior fill palette.
|
||||||
|
bg = {
|
||||||
|
x=0,y=0,w=128,h=128,fp=0,c=0
|
||||||
|
}
|
||||||
|
mknew(bg)
|
||||||
|
|
||||||
|
function bg:draw()
|
||||||
|
local oldfp=fillp(self.fp)
|
||||||
|
rectfill(self.x,self.y,self.x+self.w,self.y+self.h,self.c)
|
||||||
|
fillp(oldfp)
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------
|
||||||
|
-- animator
|
||||||
|
-------------------------------
|
||||||
|
-- animator is a drawable item
|
||||||
|
-- that manages a linked list of
|
||||||
|
-- temporary drawables. a
|
||||||
|
-- temporary drawable is dropped
|
||||||
|
-- when its :update returns
|
||||||
|
-- a non-false value.
|
||||||
|
-------------------------------
|
||||||
|
animator = {}
|
||||||
|
mknew(animator)
|
||||||
|
|
||||||
|
function animator:update()
|
||||||
|
local p,n=self, self.next
|
||||||
|
while n do
|
||||||
|
if n.item:update() then
|
||||||
|
local nn = n.next
|
||||||
|
if (not nn) self.tail = p
|
||||||
|
p.next = n.next
|
||||||
|
else
|
||||||
|
p = n
|
||||||
|
end
|
||||||
|
n = p.next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function animator:draw()
|
||||||
|
local n = self.next
|
||||||
|
while n do
|
||||||
|
n.item:draw()
|
||||||
|
n = n.next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- add a new drawable under all
|
||||||
|
-- existing other items.
|
||||||
|
-- (it draws first)
|
||||||
|
function animator:push_under(i)
|
||||||
|
self.next={next=self.next, item=i}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- add a new drawable over all
|
||||||
|
-- existing other items.
|
||||||
|
-- (it draws last)
|
||||||
|
function animator:push_over(i)
|
||||||
|
local target, node = self.tail or self, {item=i}
|
||||||
|
target.next=node
|
||||||
|
self.tail=node
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-->8
|
||||||
|
-- board
|
||||||
|
|
||||||
__gfx__
|
__gfx__
|
||||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
Loading…
Reference in New Issue
Block a user