mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
love.event.quit now accepts a single (optional) argument, which is used as the program's exit status number. Resolves issue #1070.
This commit is contained in:
@@ -134,7 +134,7 @@ Variant::~Variant()
|
|||||||
|
|
||||||
Variant *Variant::fromLua(lua_State *L, int n, bool allowTables)
|
Variant *Variant::fromLua(lua_State *L, int n, bool allowTables)
|
||||||
{
|
{
|
||||||
Variant *v = NULL;
|
Variant *v = nullptr;
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *str;
|
const char *str;
|
||||||
if (n < 0) // Fix the stack position, we might modify it later
|
if (n < 0) // Fix the stack position, we might modify it later
|
||||||
|
|||||||
@@ -97,9 +97,19 @@ int w_clear(lua_State *)
|
|||||||
|
|
||||||
int w_quit(lua_State *L)
|
int w_quit(lua_State *L)
|
||||||
{
|
{
|
||||||
Message *m = new Message("quit");
|
std::vector<StrongRef<Variant>> args;
|
||||||
|
|
||||||
|
Variant *v = Variant::fromLua(L, 1);
|
||||||
|
if (v)
|
||||||
|
{
|
||||||
|
args.push_back(v);
|
||||||
|
v->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
Message *m = new Message("quit", args);
|
||||||
instance()->push(m);
|
instance()->push(m);
|
||||||
m->release();
|
m->release();
|
||||||
|
|
||||||
luax_pushboolean(L, true);
|
luax_pushboolean(L, true);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -651,13 +651,12 @@ int Font::getWidth(const std::string &str)
|
|||||||
prevglyph = c;
|
prevglyph = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(utf8::exception &e)
|
catch (utf8::exception &e)
|
||||||
{
|
{
|
||||||
throw love::Exception("UTF-8 decoding error: %s", e.what());
|
throw love::Exception("UTF-8 decoding error: %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > max_width)
|
max_width = std::max(max_width, width);
|
||||||
max_width = width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return max_width;
|
return max_width;
|
||||||
|
|||||||
@@ -523,7 +523,7 @@ function love.run()
|
|||||||
for name, a,b,c,d,e,f in love.event.poll() do
|
for name, a,b,c,d,e,f in love.event.poll() do
|
||||||
if name == "quit" then
|
if name == "quit" then
|
||||||
if not love.quit or not love.quit() then
|
if not love.quit or not love.quit() then
|
||||||
return
|
return a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
love.handlers[name](a,b,c,d,e,f)
|
love.handlers[name](a,b,c,d,e,f)
|
||||||
|
|||||||
@@ -962,7 +962,7 @@ const unsigned char boot_lua[] =
|
|||||||
0x09, 0x09, 0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x71,
|
0x09, 0x09, 0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x71,
|
||||||
0x75, 0x69, 0x74, 0x20, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x71, 0x75,
|
0x75, 0x69, 0x74, 0x20, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x71, 0x75,
|
||||||
0x69, 0x74, 0x28, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
0x69, 0x74, 0x28, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
||||||
0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x0a,
|
0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x0a,
|
||||||
0x09, 0x09, 0x09, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
|
0x09, 0x09, 0x09, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||||
0x09, 0x09, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
|
0x09, 0x09, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||||
0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x5b,
|
0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x5b,
|
||||||
|
|||||||
Reference in New Issue
Block a user