Skip to content
Snippets Groups Projects
Commit e45d9382 authored by dg's avatar dg
Browse files

fix dialog when runing

git-svn-id: http://svn.net-core.org/repos/t-engine4@512 51575b47-30f0-44d4-a5cc-537603b46e54
parent e747ee64
No related branches found
No related tags found
No related merge requests found
......@@ -100,12 +100,9 @@ function _M:drawDialog(s)
end
function _M:keyCommands(t, b)
self.old_key = game.key
game.key = engine.KeyBind.new()
if t then game.key:addCommands(t) end
if b then game.key:addBinds(b) end
game.key:setCurrent()
self.key = game.key
self.key = engine.KeyBind.new()
if t then self.key:addCommands(t) end
if b then self.key:addBinds(b) end
end
function _M:mouseZones(t)
......@@ -117,13 +114,12 @@ function _M:mouseZones(t)
end
end
self.old_mouse = game.mouse
game.mouse = engine.Mouse.new()
game.mouse:registerZones(t)
game.mouse:setCurrent()
self.mouse = engine.Mouse.new()
self.mouse:registerZones(t)
end
function _M:unload()
--[[
if self.old_key then
game.key = self.old_key
game.key:setCurrent()
......@@ -132,6 +128,7 @@ function _M:unload()
game.mouse = self.old_mouse
game.mouse:setCurrent()
end
]]
end
function _M:drawWBorder(s, x, y, w)
......
......@@ -129,6 +129,8 @@ end
function _M:registerDialog(d)
table.insert(self.dialogs, d)
self.dialogs[d] = #self.dialogs
if d.key then d.key:setCurrent() end
if d.mouse then d.mouse:setCurrent() end
end
--- Undisplay a dialog, removing its own keyhandler if needed
......@@ -137,6 +139,12 @@ function _M:unregisterDialog(d)
table.remove(self.dialogs, self.dialogs[d])
self.dialogs[d] = nil
d:unload()
-- Update positions
for i, id in ipairs(self.dialogs) do self.dialogs[id] = i end
local last = self.dialogs[#self.dialogs] or self
if last.key then last.key:setCurrent() end
if last.mouse then last.mouse:setCurrent() end
end
--- The C core gives us command line arguments
......
......@@ -40,7 +40,7 @@ end
--- Setups as the current game keyhandler
function _M:setCurrent()
core.key.set_current_handler(self)
if game then game.key = self end
-- if game then game.key = self end
_M.current = self
end
......
......@@ -50,7 +50,7 @@ end
--- Setups as the current game keyhandler
function _M:setCurrent()
core.mouse.set_current_handler(self)
if game then game.mouse = self end
-- if game then game.mouse = self end
_M.current = self
end
......
......@@ -32,7 +32,7 @@ function _M:loaded()
self.loaded_musics = self.loaded_musics or {}
end
function _M:playMusic(name)
function _M:playMusic(name, loop)
name = name or self.current_music
if not name then return end
local m = self.loaded_musics[name]
......@@ -45,7 +45,7 @@ function _M:playMusic(name)
if self.current_music then
core.sound.musicStop()
end
m:play()
m:play(loop or -1)
self.current_music = name
self.playing_music = true
end
......
......@@ -164,6 +164,7 @@ function _M:archeryShoot(damtype, mult, on_hit, tg, params)
local target = game.level.map(tx, ty, game.level.map.ACTOR)
if not target then return end
ret.firsttarget = ret.firsttarget or target
ammo = ammo.combat
damtype = damtype or ammo.damtype or DamageType.PHYSICAL
......@@ -211,8 +212,8 @@ function _M:archeryShoot(damtype, mult, on_hit, tg, params)
-- If we used only one arrow, use it
if params.one_shot then self:removeObject(self:getInven("QUIVER"), 1) end
if sound then game:playSoundNear(self, sound)
elseif sound_miss then game:playSoundNear(self, sound_miss) end
if sound then game:playSoundNear(ret.firsttarget or self, sound)
elseif sound_miss then game:playSoundNear(ret.firsttarget or self, sound_miss) end
return ret.hitted
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment