prompt box style, entity prompts improvement, killing entities and particles improvement
This commit is contained in:
parent
8c8e4808ad
commit
96b1e750e4
@ -210,24 +210,24 @@ function doEditorEdit()
|
|||||||
and love.keyboard.isDown("lctrl") ~= true
|
and love.keyboard.isDown("lctrl") ~= true
|
||||||
then
|
then
|
||||||
if selecting_tile ~= nil then
|
if selecting_tile ~= nil then
|
||||||
if Keybind:checkDown(Keybind.generic.lclick) then
|
if Keybind:checkDown(Keybind.editor.tile_set) then
|
||||||
setTile(vertical,horizontal,selecting_tile)
|
setTile(vertical,horizontal,selecting_tile)
|
||||||
elseif Keybind:checkDown(Keybind.generic.rclick) then
|
elseif Keybind:checkDown(Keybind.editor.tile_remove) then
|
||||||
setTile(vertical,horizontal,0)
|
setTile(vertical,horizontal,0)
|
||||||
end
|
end
|
||||||
reloadLevelTiles()
|
reloadLevelTiles()
|
||||||
else
|
else
|
||||||
if Keybind:checkDown(Keybind.generic.lclick) then
|
if Keybind:checkDown(Keybind.editor.entity_select) then
|
||||||
deselectSpawns()
|
deselectSpawns()
|
||||||
selectSpawns(mouse_x,mouse_y)
|
selectSpawns(mouse_x,mouse_y)
|
||||||
end
|
end
|
||||||
if Keybind:checkDown(Keybind.generic.rclick) then
|
if Keybind:checkDown(Keybind.editor.entity_move) then
|
||||||
moveSpawns(mouse_x,mouse_y)
|
moveSpawns(mouse_x,mouse_y)
|
||||||
end
|
end
|
||||||
if Prompt.active_prompt == nil then
|
if Prompt.active_prompt == nil then
|
||||||
if Keybind:checkDown({keys={"t"}}) then
|
if Keybind:checkDown(Keybind.editor.entity_modify_archetype) then
|
||||||
promptSpawnArchetype()
|
promptSpawnArchetype()
|
||||||
elseif Keybind:checkDown({keys={"d"}}) then
|
elseif Keybind:checkDown(Keybind.editor.entity_modify_data) then
|
||||||
promptSpawnArgs()
|
promptSpawnArgs()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -104,12 +104,12 @@ function Entity:kill()
|
|||||||
self.light:kill()
|
self.light:kill()
|
||||||
end
|
end
|
||||||
if self.id ~= nil then
|
if self.id ~= nil then
|
||||||
|
table.remove(LoadedObjects.Entities,self.id)
|
||||||
for _, e in pairs(LoadedObjects.Entities) do
|
for _, e in pairs(LoadedObjects.Entities) do
|
||||||
if e.id > self.id then
|
if e.id > self.id then
|
||||||
e.id = e.id - 1
|
e.id = e.id - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.remove(LoadedObjects.Entities,self.id)
|
|
||||||
end
|
end
|
||||||
self = nil
|
self = nil
|
||||||
end
|
end
|
||||||
|
@ -123,7 +123,12 @@ function Keybind:default()
|
|||||||
Keybind.editor.down = { keys = {"down", "s"}}
|
Keybind.editor.down = { keys = {"down", "s"}}
|
||||||
Keybind.editor.palette_change = { keys = {"f1"}}
|
Keybind.editor.palette_change = { keys = {"f1"}}
|
||||||
Keybind.editor.save = { keys = {"f3"}}
|
Keybind.editor.save = { keys = {"f3"}}
|
||||||
|
Keybind.editor.tile_set = { keys = {1}}
|
||||||
|
Keybind.editor.tile_remove = { keys = {2}}
|
||||||
|
Keybind.editor.entity_select = { keys = {1}}
|
||||||
|
Keybind.editor.entity_move = { keys = {2}}
|
||||||
|
Keybind.editor.entity_modify_archetype = { keys = {"t"}}
|
||||||
|
Keybind.editor.entity_modify_data = { keys = {"d"}}
|
||||||
-- Generic
|
-- Generic
|
||||||
Keybind.generic.lclick = { keys = {1}}
|
Keybind.generic.lclick = { keys = {1}}
|
||||||
Keybind.generic.rclick = { keys = {2}}
|
Keybind.generic.rclick = { keys = {2}}
|
||||||
|
@ -26,12 +26,12 @@ end
|
|||||||
|
|
||||||
function Light:kill()
|
function Light:kill()
|
||||||
if self.id ~= nil then
|
if self.id ~= nil then
|
||||||
|
table.remove(LoadedObjects.Lights,self.id)
|
||||||
for _, e in pairs(LoadedObjects.Lights) do
|
for _, e in pairs(LoadedObjects.Lights) do
|
||||||
if e.id > self.id then
|
if e.id > self.id then
|
||||||
e.id = e.id - 1
|
e.id = e.id - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.remove(LoadedObjects.Lights,self.id)
|
|
||||||
end
|
end
|
||||||
self = nil
|
self = nil
|
||||||
end
|
end
|
||||||
|
@ -76,25 +76,35 @@ function promptSpawnArchetype()
|
|||||||
local f = loadstring("return "..prompt.input)
|
local f = loadstring("return "..prompt.input)
|
||||||
if f ~= nil then
|
if f ~= nil then
|
||||||
local succ, arch = pcall(f)
|
local succ, arch = pcall(f)
|
||||||
print(succ, arch)
|
print("archetype changed --",succ)
|
||||||
|
print("from: ", spawn.archetype.type)
|
||||||
if not succ
|
if not succ
|
||||||
or type(arch) ~= "table"
|
or type(arch) ~= "table"
|
||||||
or type(arch.type) ~= "string"
|
or type(arch.type) ~= "string"
|
||||||
then
|
then
|
||||||
arch = spawn.archetype
|
arch = spawn.archetype
|
||||||
end
|
end
|
||||||
print(succ, arch)
|
print("to: ", arch.type)
|
||||||
spawn.archetype = arch
|
spawn.archetype = arch
|
||||||
|
else
|
||||||
|
print("invalid input for prompt "..prompt.name)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
prompt.pos.x = spawn.args[1] - Camera.pos.x - offset_x
|
prompt.pos.x = (spawn.args[1]-4)*game.scale - Camera.pos.x - offset_x
|
||||||
prompt.pos.y = spawn.args[2] - Camera.pos.y - offset_y
|
prompt.pos.y = (spawn.args[2]-20)*game.scale - Camera.pos.y - offset_y
|
||||||
|
|
||||||
prompt:activate()
|
prompt:activate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function checkArgsAreInvalid(args)
|
||||||
|
for _, arg in pairs(args) do
|
||||||
|
if arg == nil then return true end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function promptSpawnArgs()
|
function promptSpawnArgs()
|
||||||
if Prompt.active_prompt then
|
if Prompt.active_prompt then
|
||||||
Prompt.active_prompt.canceled = true
|
Prompt.active_prompt.canceled = true
|
||||||
@ -111,18 +121,25 @@ function promptSpawnArgs()
|
|||||||
name = "args",
|
name = "args",
|
||||||
input = text,
|
input = text,
|
||||||
func = function(prompt)
|
func = function(prompt)
|
||||||
|
|
||||||
local f = loadstring("return {"..prompt.input.."}")
|
local f = loadstring("return {"..prompt.input.."}")
|
||||||
|
if f ~= nil then
|
||||||
if f == nil then
|
local succ, args = pcall(f)
|
||||||
spawn.args = arch
|
print("args changed --",succ)
|
||||||
|
print("from: ", unpack(args))
|
||||||
|
if not succ
|
||||||
|
or checkArgsAreInvalid(args)
|
||||||
|
then
|
||||||
|
args = spawn.args
|
||||||
|
end
|
||||||
|
print("to: ", unpack(args))
|
||||||
|
spawn.args = args
|
||||||
else
|
else
|
||||||
spawn.args = f()
|
print("invalid input for prompt "..prompt.name)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
prompt.pos.x = spawn.args[1] - Camera.pos.x - offset_x
|
prompt.pos.x = (spawn.args[1]-4)*game.scale - Camera.pos.x - offset_x
|
||||||
prompt.pos.y = spawn.args[2] - Camera.pos.y - offset_y
|
prompt.pos.y = (spawn.args[2]-4)*game.scale - Camera.pos.y - offset_y
|
||||||
prompt:activate()
|
prompt:activate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -20,7 +20,8 @@ Prompt = {
|
|||||||
name = "input",
|
name = "input",
|
||||||
canceled = false,
|
canceled = false,
|
||||||
closing = false,
|
closing = false,
|
||||||
|
color = {1,1,1,1},
|
||||||
|
background_color = {0,0,0,1},
|
||||||
active_prompt = nil,
|
active_prompt = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,28 @@ function Prompt:textinput(text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Prompt:draw()
|
function Prompt:draw()
|
||||||
love.graphics.print(self.name .. ": " .. self.input, self.pos.x, self.pos.y)
|
local c1, c2, c3, a = love.graphics.getColor()
|
||||||
|
local text = self.name .. ": " .. self.input
|
||||||
|
local width = locale_font:getWidth(text)
|
||||||
|
local height = locale_font:getHeight(text)
|
||||||
|
local margin = 10
|
||||||
|
love.graphics.setColor(unpack(self.color))
|
||||||
|
love.graphics.rectangle("fill",
|
||||||
|
self.pos.x-margin-1,
|
||||||
|
self.pos.y-1,
|
||||||
|
width+margin*2+2,
|
||||||
|
height+margin+2
|
||||||
|
)
|
||||||
|
love.graphics.setColor(unpack(self.background_color))
|
||||||
|
love.graphics.rectangle("fill",
|
||||||
|
self.pos.x-margin,
|
||||||
|
self.pos.y,
|
||||||
|
width+margin*2,
|
||||||
|
height+margin
|
||||||
|
)
|
||||||
|
love.graphics.setColor(unpack(self.color))
|
||||||
|
love.graphics.print(text, self.pos.x, self.pos.y)
|
||||||
|
love.graphics.setColor(c1,c2,c3,a)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Prompt:activate()
|
function Prompt:activate()
|
||||||
|
Loading…
Reference in New Issue
Block a user