You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.4 KiB
121 lines
2.4 KiB
1 year ago
|
--remder pane
|
||
|
|
||
|
holding = nil
|
||
|
under = nil
|
||
|
|
||
|
tx = 64
|
||
|
ty = 64
|
||
|
|
||
|
function r_pane_update()
|
||
|
|
||
|
if current_pane == 3 then
|
||
|
if last_edit_pane == 1 then
|
||
|
under = get_handle_from_address(selected_address)
|
||
|
if under ~= nil then
|
||
|
tx = under.handle.position[1]
|
||
|
ty = under.handle.position[2]
|
||
|
end
|
||
|
end
|
||
|
last_edit_pane = 3
|
||
|
|
||
|
dx = 0
|
||
|
dy = 0
|
||
|
|
||
|
if (btn(0) and tx > 0) dx -= 1
|
||
|
if (btn(1) and tx < 127) dx += 1
|
||
|
if (btn(2) and ty > 0) dy -= 1
|
||
|
if (btn(3) and ty < 127) dy += 1
|
||
|
|
||
|
tx += dx
|
||
|
ty += dy
|
||
|
|
||
|
under = find_handle(record_list, tx, ty)
|
||
|
|
||
|
if holding ~= nil then
|
||
|
perform_edit(m, holding, dx, dy, true)
|
||
|
end
|
||
|
|
||
|
if not btn(4) then
|
||
|
holding = nil
|
||
|
elseif holding == nil then
|
||
|
holding = under
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|
||
|
|
||
|
// this should get run when we
|
||
|
// switch from the listing pane
|
||
|
// to the render pane, to get
|
||
|
// a handle to be targeting in
|
||
|
// the render pane.
|
||
|
function get_handle_from_address(address)
|
||
|
if holding ~= nil and deep_eq(holding.address, address) then
|
||
|
return holding
|
||
|
elseif under ~=nil and deep_eq(under.address, address) then
|
||
|
return under
|
||
|
end
|
||
|
|
||
|
for handle in all(record_list) do
|
||
|
if deep_eq(handle.address, address) then
|
||
|
return handle
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return nil
|
||
|
end
|
||
|
|
||
|
function find_handle(record_list, x, y)
|
||
|
close_one = nil
|
||
|
dist = 8
|
||
|
for h in all(record_list) do
|
||
|
if h.handle ~= nil then
|
||
|
nx = h.handle.position[1]
|
||
|
ny = h.handle.position[2]
|
||
|
|
||
|
nd = abs(nx-x) + abs(ny-y)
|
||
|
if nd < dist then
|
||
|
close_one = h
|
||
|
dist = nd
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return close_one
|
||
|
end
|
||
|
|
||
|
|
||
|
-- rendering
|
||
|
function r_pane_draw()
|
||
|
record_list = {}
|
||
|
|
||
|
-- draw the path
|
||
|
vectorate(m, {pre=nil, post=add_to_record_list})
|
||
|
|
||
|
-- draw the path handles
|
||
|
if show_path_handles then
|
||
|
for rec in all(record_list) do
|
||
|
h = rec.handle
|
||
|
|
||
|
if rec.operation[1] == "rotate" then
|
||
|
line(rec.state.position[1],
|
||
|
rec.state.position[2],
|
||
|
h.position[1], h.position[2], 13)
|
||
|
elseif rec.operation[1] == "scale" then
|
||
|
line(rec.state.position[1],
|
||
|
rec.state.position[2],
|
||
|
h.position[1], h.position[2], 13)
|
||
|
end
|
||
|
spr(h.sprite, h.position[1]-3, h.position[2]-3)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if last_edit_pane == 3 then
|
||
|
spr(0, tx-4, ty-4)
|
||
|
else
|
||
|
for r in all(record_list) do
|
||
|
if deep_eq(r.address, selected_address) then
|
||
|
spr(0, r.handle.position[1]-4, r.handle.position[2]-4)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|