- [FIX] msgbox arreglat i redissenyat

- [FIX] Quan està el menu fora s'inhabiliten els shortcuts en l'editor
- [NEW] Menu nou funcionant
This commit is contained in:
2026-03-11 10:21:21 +01:00
parent de873a7a25
commit 40c3dcd6d0
4 changed files with 172 additions and 127 deletions

View File

@@ -125,68 +125,67 @@ editor = {
draw.surf(k.visual.x, k.visual.y, k.visual.w, k.visual.h, mx, my, k.visual.w, k.visual.h, editor.flip)
end
end
end
if key.press(key.ESCAPE) then
--editor.quit()
menu.toggle()
elseif key.press(key.RIGHT) and rooms.pos.x < 20*7 then
rooms.pos.x = rooms.pos.x + 20
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.LEFT) and rooms.pos.x > 0 then
rooms.pos.x = rooms.pos.x - 20
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.DOWN) and rooms.pos.y < 13*7 then
rooms.pos.y = rooms.pos.y + 13
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.UP) and rooms.pos.y > 0 then
rooms.pos.y = rooms.pos.y - 13
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.TAB) or key.press(key.ESCAPE) then
if editor.layer==LAYER_BACKGROUND or editor.layer==LAYER_FOREGROUND then
editor.tilepicker.show()
else
editor.itempicker.show()
end
elseif key.press(key.P) then
sprites.hero.pos.x = tx*8-4
sprites.hero.pos.y = ty*8-9
elseif key.press(key.F9) then
editor.play()
elseif key.press(key.F11) then
reload_textures()
end
if editor.layer==LAYER_ITEMS then
if key.press(key.F) then
if editor.item_selected then
editor.flip = not editor.flip
elseif editor.item_hovered then
local sprite = sprites.list[editor.item_hovered]
sprite.flipped = not sprite.flipped
map.surf(rooms.surf_items)
local tile = map.tile(sprite.pos.x//8, sprite.pos.y//8)
if tile > 0x7f then tile = tile & 0x7f else tile = tile | 0x80 end
map.tile(sprite.pos.x//8, sprite.pos.y//8, tile)
editor.modified = true
end
end
if editor.item_hovered and key.press(key.DELETE) then
local sprite = sprites.list[editor.item_hovered]
map.surf(rooms.surf_items)
map.tile(sprite.pos.x//8,sprite.pos.y//8,0)
sprites.remove(sprite)
end
end
end
view.origin(0,0)
draw.text(rooms.pos.x//20,1,96,28)
draw.text(rooms.pos.y//13,5,96,28)
if key.press(key.ESCAPE) then
--editor.quit()
menu.toggle()
elseif key.press(key.RIGHT) and rooms.pos.x < 20*7 then
rooms.pos.x = rooms.pos.x + 20
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.LEFT) and rooms.pos.x > 0 then
rooms.pos.x = rooms.pos.x - 20
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.DOWN) and rooms.pos.y < 13*7 then
rooms.pos.y = rooms.pos.y + 13
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.UP) and rooms.pos.y > 0 then
rooms.pos.y = rooms.pos.y - 13
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.TAB) or key.press(key.ESCAPE) then
if editor.layer==LAYER_BACKGROUND or editor.layer==LAYER_FOREGROUND then
editor.tilepicker.show()
else
editor.itempicker.show()
end
elseif key.press(key.P) then
sprites.hero.pos.x = tx*8-4
sprites.hero.pos.y = ty*8-9
elseif key.press(key.F9) then
editor.play()
elseif key.press(key.F11) then
reload_textures()
end
if editor.layer==LAYER_ITEMS then
if key.press(key.F) then
if editor.item_selected then
editor.flip = not editor.flip
elseif editor.item_hovered then
local sprite = sprites.list[editor.item_hovered]
sprite.flipped = not sprite.flipped
map.surf(rooms.surf_items)
local tile = map.tile(sprite.pos.x//8, sprite.pos.y//8)
if tile > 0x7f then tile = tile & 0x7f else tile = tile | 0x80 end
map.tile(sprite.pos.x//8, sprite.pos.y//8, tile)
editor.modified = true
end
end
if editor.item_hovered and key.press(key.DELETE) then
local sprite = sprites.list[editor.item_hovered]
map.surf(rooms.surf_items)
map.tile(sprite.pos.x//8,sprite.pos.y//8,0)
sprites.remove(sprite)
end
end
-- Pintar el menú (el marcador serà en el modul game.lua)
--score.draw()
menu.draw()
@@ -237,12 +236,12 @@ editor = {
quit=function()
if editor.modified then
msgbox.show("IE MEN!",
{"Hi ha canvis sense guardar.", "Vols guardar-los abans d'eixir?"},
msgbox.show("SAVE CHANGES BEFORE CLOSING?",
{"YOU HAVE UNSAVED CHANGES. IF YOU EXIT", "WITHOUT SAVING, CHANGES WILL BE LOST."},
{
{"Cancel", app.pop},
{"No", sys.quit},
{"Yes", function() rooms.save() sys.quit() end}
{"CANCEL", app.pop},
{" EXIT ", sys.quit},
{" SAVE ", function() rooms.save() sys.quit() end}
} )
else
sys.quit()