Some fixes
This commit is contained in:
parent
7eb372c539
commit
bd3cdbb23d
@ -757,6 +757,7 @@ namespace ui_scripting::lua
|
||||
{
|
||||
this->state_.collect_garbage();
|
||||
this->scheduler_.clear();
|
||||
this->event_handler_.clear();
|
||||
this->state_ = {};
|
||||
}
|
||||
|
||||
|
@ -358,15 +358,15 @@ namespace ui_scripting::lua::engine
|
||||
|
||||
void start()
|
||||
{
|
||||
clear_menus();
|
||||
get_scripts().clear();
|
||||
clear_menus();
|
||||
load_scripts();
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
clear_menus();
|
||||
get_scripts().clear();
|
||||
clear_menus();
|
||||
}
|
||||
|
||||
void ui_event(const std::string& type, const std::vector<int>& arguments)
|
||||
|
@ -1,7 +1,4 @@
|
||||
function element:animate(state, animationtime)
|
||||
self:notify("cancel_animation")
|
||||
|
||||
local doanimation = function()
|
||||
function element:animate(name, state, animationtime)
|
||||
local start = {
|
||||
x = self.x,
|
||||
y = self.y,
|
||||
@ -23,16 +20,25 @@ function element:animate(state, animationtime)
|
||||
for k, v in pairs(_end) do
|
||||
if (type(v) == "table") then
|
||||
local value = {}
|
||||
local different = false
|
||||
|
||||
for _k, _v in pairs(v) do
|
||||
value[_k] = _v - start[k][_k]
|
||||
if (value[_k] ~= 0) then
|
||||
different = true
|
||||
end
|
||||
end
|
||||
|
||||
if (different) then
|
||||
diffs[k] = value
|
||||
end
|
||||
else
|
||||
local value = v - start[k]
|
||||
if (value ~= 0) then
|
||||
diffs[k] = v - start[k]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local timeout = nil
|
||||
local interval = nil
|
||||
@ -41,13 +47,12 @@ function element:animate(state, animationtime)
|
||||
interval = game:onframe(function()
|
||||
local time = game:time()
|
||||
local percentage = (time - starttime) / animationtime
|
||||
if (percentage >= 1) then
|
||||
for k, v in pairs(_end) do
|
||||
self[k] = v
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if (percentage >= 1) then
|
||||
for k, v in pairs(diffs) do
|
||||
self[k] = _end[k]
|
||||
end
|
||||
else
|
||||
for k, v in pairs(diffs) do
|
||||
if (type(v) == "table") then
|
||||
local value = {}
|
||||
@ -61,26 +66,26 @@ function element:animate(state, animationtime)
|
||||
self[k] = start[k] + v * percentage
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
timeout = game:ontimeout(function()
|
||||
interval:clear()
|
||||
for k, v in pairs(_end) do
|
||||
self[k] = v
|
||||
for k, v in pairs(diffs) do
|
||||
self[k] = _end[k]
|
||||
end
|
||||
end, animationtime)
|
||||
|
||||
self:onnotifyonce("cancel_animation", function()
|
||||
self:onnotifyonce("cancel_animation", function(_name)
|
||||
if (name == _name) then
|
||||
timeout:clear()
|
||||
interval:clear()
|
||||
end)
|
||||
end
|
||||
|
||||
game:ontimeout(doanimation, 0)
|
||||
end)
|
||||
end
|
||||
|
||||
function element:cancelanimations(callback)
|
||||
self:notify("cancel_animation")
|
||||
function element:cancelanimations(name, callback)
|
||||
self:notify("cancel_animation", name)
|
||||
if (type(callback) == "function") then
|
||||
game:ontimeout(callback, 0)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user