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
|
||||
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)
|
||||
elseif Keybind:checkDown(Keybind.generic.rclick) then
|
||||
elseif Keybind:checkDown(Keybind.editor.tile_remove) then
|
||||
setTile(vertical,horizontal,0)
|
||||
end
|
||||
reloadLevelTiles()
|
||||
else
|
||||
if Keybind:checkDown(Keybind.generic.lclick) then
|
||||
if Keybind:checkDown(Keybind.editor.entity_select) then
|
||||
deselectSpawns()
|
||||
selectSpawns(mouse_x,mouse_y)
|
||||
end
|
||||
if Keybind:checkDown(Keybind.generic.rclick) then
|
||||
if Keybind:checkDown(Keybind.editor.entity_move) then
|
||||
moveSpawns(mouse_x,mouse_y)
|
||||
end
|
||||
if Prompt.active_prompt == nil then
|
||||
if Keybind:checkDown({keys={"t"}}) then
|
||||
if Keybind:checkDown(Keybind.editor.entity_modify_archetype) then
|
||||
promptSpawnArchetype()
|
||||
elseif Keybind:checkDown({keys={"d"}}) then
|
||||
elseif Keybind:checkDown(Keybind.editor.entity_modify_data) then
|
||||
promptSpawnArgs()
|
||||
end
|
||||
end
|
||||
|
@ -104,12 +104,12 @@ function Entity:kill()
|
||||
self.light:kill()
|
||||
end
|
||||
if self.id ~= nil then
|
||||
table.remove(LoadedObjects.Entities,self.id)
|
||||
for _, e in pairs(LoadedObjects.Entities) do
|
||||
if e.id > self.id then
|
||||
e.id = e.id - 1
|
||||
end
|
||||
end
|
||||
table.remove(LoadedObjects.Entities,self.id)
|
||||
end
|
||||
self = nil
|
||||
end
|
||||
|
@ -123,7 +123,12 @@ function Keybind:default()
|
||||
Keybind.editor.down = { keys = {"down", "s"}}
|
||||
Keybind.editor.palette_change = { keys = {"f1"}}
|
||||
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
|
||||
Keybind.generic.lclick = { keys = {1}}
|
||||
Keybind.generic.rclick = { keys = {2}}
|
||||
|
@ -26,12 +26,12 @@ end
|
||||
|
||||
function Light:kill()
|
||||
if self.id ~= nil then
|
||||
table.remove(LoadedObjects.Lights,self.id)
|
||||
for _, e in pairs(LoadedObjects.Lights) do
|
||||
if e.id > self.id then
|
||||
e.id = e.id - 1
|
||||
end
|
||||
end
|
||||
table.remove(LoadedObjects.Lights,self.id)
|
||||
end
|
||||
self = nil
|
||||
end
|
||||
|
@ -76,25 +76,35 @@ function promptSpawnArchetype()
|
||||
local f = loadstring("return "..prompt.input)
|
||||
if f ~= nil then
|
||||
local succ, arch = pcall(f)
|
||||
print(succ, arch)
|
||||
print("archetype changed --",succ)
|
||||
print("from: ", spawn.archetype.type)
|
||||
if not succ
|
||||
or type(arch) ~= "table"
|
||||
or type(arch.type) ~= "string"
|
||||
then
|
||||
arch = spawn.archetype
|
||||
end
|
||||
print(succ, arch)
|
||||
print("to: ", arch.type)
|
||||
spawn.archetype = arch
|
||||
else
|
||||
print("invalid input for prompt "..prompt.name)
|
||||
end
|
||||
end,
|
||||
})
|
||||
prompt.pos.x = spawn.args[1] - Camera.pos.x - offset_x
|
||||
prompt.pos.y = spawn.args[2] - Camera.pos.y - offset_y
|
||||
prompt.pos.x = (spawn.args[1]-4)*game.scale - Camera.pos.x - offset_x
|
||||
prompt.pos.y = (spawn.args[2]-20)*game.scale - Camera.pos.y - offset_y
|
||||
|
||||
prompt:activate()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function checkArgsAreInvalid(args)
|
||||
for _, arg in pairs(args) do
|
||||
if arg == nil then return true end
|
||||
end
|
||||
end
|
||||
|
||||
function promptSpawnArgs()
|
||||
if Prompt.active_prompt then
|
||||
Prompt.active_prompt.canceled = true
|
||||
@ -111,18 +121,25 @@ function promptSpawnArgs()
|
||||
name = "args",
|
||||
input = text,
|
||||
func = function(prompt)
|
||||
|
||||
local f = loadstring("return {"..prompt.input.."}")
|
||||
|
||||
if f == nil then
|
||||
spawn.args = arch
|
||||
if f ~= nil then
|
||||
local succ, args = pcall(f)
|
||||
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
|
||||
spawn.args = f()
|
||||
print("invalid input for prompt "..prompt.name)
|
||||
end
|
||||
end,
|
||||
})
|
||||
prompt.pos.x = spawn.args[1] - Camera.pos.x - offset_x
|
||||
prompt.pos.y = spawn.args[2] - Camera.pos.y - offset_y
|
||||
prompt.pos.x = (spawn.args[1]-4)*game.scale - Camera.pos.x - offset_x
|
||||
prompt.pos.y = (spawn.args[2]-4)*game.scale - Camera.pos.y - offset_y
|
||||
prompt:activate()
|
||||
end
|
||||
end
|
||||
|
@ -20,7 +20,8 @@ Prompt = {
|
||||
name = "input",
|
||||
canceled = false,
|
||||
closing = false,
|
||||
|
||||
color = {1,1,1,1},
|
||||
background_color = {0,0,0,1},
|
||||
active_prompt = nil,
|
||||
}
|
||||
|
||||
@ -52,7 +53,28 @@ function Prompt:textinput(text)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
function Prompt:activate()
|
||||
|
Loading…
Reference in New Issue
Block a user