mirror of
https://github.com/love2d/love-android.git
synced 2026-08-20 04:31:26 +02:00
Using latest changeset 593639000823 of love-android
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2014 LOVE Development Team
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -52,6 +52,9 @@ WindowSettings::WindowSettings()
|
||||
, highdpi(false)
|
||||
, sRGB(false)
|
||||
, refreshrate(0.0)
|
||||
, useposition(false)
|
||||
, x(0)
|
||||
, y(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -101,6 +104,8 @@ StringMap<Window::Setting, Window::SETTING_MAX_ENUM>::Entry Window::settingEntri
|
||||
{"highdpi", SETTING_HIGHDPI},
|
||||
{"srgb", SETTING_SRGB},
|
||||
{"refreshrate", SETTING_REFRESHRATE},
|
||||
{"x", SETTING_X},
|
||||
{"y", SETTING_Y},
|
||||
};
|
||||
|
||||
StringMap<Window::Setting, Window::SETTING_MAX_ENUM> Window::settings(Window::settingEntries, sizeof(Window::settingEntries));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2014 LOVE Development Team
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
SETTING_HIGHDPI,
|
||||
SETTING_SRGB,
|
||||
SETTING_REFRESHRATE,
|
||||
SETTING_X,
|
||||
SETTING_Y,
|
||||
SETTING_MAX_ENUM
|
||||
};
|
||||
|
||||
@@ -82,6 +84,11 @@ public:
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
|
||||
bool operator == (const WindowSize &w) const
|
||||
{
|
||||
return w.width == width && w.height == height;
|
||||
}
|
||||
};
|
||||
|
||||
struct MessageBoxData
|
||||
@@ -122,6 +129,9 @@ public:
|
||||
|
||||
virtual void getDesktopDimensions(int displayindex, int &width, int &height) const = 0;
|
||||
|
||||
virtual void setPosition(int x, int y, int displayindex) = 0;
|
||||
virtual void getPosition(int &x, int &y, int &displayindex) = 0;
|
||||
|
||||
virtual bool isCreated() const = 0;
|
||||
|
||||
virtual void setWindowTitle(const std::string &title) = 0;
|
||||
@@ -131,6 +141,7 @@ public:
|
||||
virtual love::image::ImageData *getIcon() = 0;
|
||||
|
||||
virtual void minimize() = 0;
|
||||
virtual void maximize() = 0;
|
||||
|
||||
// default no-op implementation
|
||||
virtual void swapBuffers();
|
||||
@@ -150,9 +161,14 @@ public:
|
||||
|
||||
virtual bool isTouchScreen(int displayindex) const = 0;
|
||||
|
||||
virtual double toPixels(double x) const = 0;
|
||||
virtual void toPixels(double wx, double wy, double &px, double &py) const = 0;
|
||||
virtual double fromPixels(double x) const = 0;
|
||||
virtual void fromPixels(double px, double py, double &wx, double &wy) const = 0;
|
||||
|
||||
virtual const void *getHandle() const = 0;
|
||||
|
||||
virtual bool showMessageBox(MessageBoxType type, const std::string &title, const std::string &message, bool attachtowindow) = 0;
|
||||
virtual bool showMessageBox(const std::string &title, const std::string &message, MessageBoxType type, bool attachtowindow) = 0;
|
||||
virtual int showMessageBox(const MessageBoxData &data) = 0;
|
||||
|
||||
//virtual static Window *createSingleton() = 0;
|
||||
@@ -202,6 +218,9 @@ struct WindowSettings
|
||||
bool highdpi; // false
|
||||
bool sRGB; // false
|
||||
double refreshrate; // 0.0
|
||||
bool useposition; // false
|
||||
int x; // 0
|
||||
int y; // 0
|
||||
|
||||
}; // WindowSettings
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2014 LOVE Development Team
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -131,6 +131,25 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
sdlflags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
#endif
|
||||
|
||||
int x = f.x;
|
||||
int y = f.y;
|
||||
|
||||
if (f.useposition && !f.fullscreen)
|
||||
{
|
||||
// The position needs to be in the global coordinate space.
|
||||
SDL_Rect displaybounds = {};
|
||||
SDL_GetDisplayBounds(f.display, &displaybounds);
|
||||
x += displaybounds.x;
|
||||
y += displaybounds.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (f.centered)
|
||||
x = y = SDL_WINDOWPOS_CENTERED_DISPLAY(f.display);
|
||||
else
|
||||
x = y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(f.display);
|
||||
}
|
||||
|
||||
graphics::Graphics *gfx = Module::getInstance<graphics::Graphics>(Module::M_GRAPHICS);
|
||||
if (gfx != nullptr)
|
||||
gfx->unSetMode();
|
||||
@@ -163,9 +182,6 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
}
|
||||
}
|
||||
|
||||
int centeredpos = SDL_WINDOWPOS_CENTERED_DISPLAY(f.display);
|
||||
int uncenteredpos = SDL_WINDOWPOS_UNDEFINED_DISPLAY(f.display);
|
||||
|
||||
if (!window)
|
||||
{
|
||||
created = false;
|
||||
@@ -174,9 +190,8 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
setWindowGLAttributes(f.msaa, f.sRGB);
|
||||
|
||||
const char *title = windowTitle.c_str();
|
||||
int pos = f.centered ? centeredpos : uncenteredpos;
|
||||
|
||||
window = SDL_CreateWindow(title, pos, pos, width, height, sdlflags);
|
||||
window = SDL_CreateWindow(title, x, y, width, height, sdlflags);
|
||||
|
||||
if (!window && f.msaa > 0)
|
||||
{
|
||||
@@ -184,7 +199,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
||||
|
||||
window = SDL_CreateWindow(title, pos, pos, width, height, sdlflags);
|
||||
window = SDL_CreateWindow(title, x, y, width, height, sdlflags);
|
||||
f.msaa = 0;
|
||||
}
|
||||
|
||||
@@ -195,15 +210,15 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
showMessageBox(MESSAGEBOX_ERROR, "Could not create window", SDL_GetError(), false);
|
||||
showMessageBox("Could not create window", SDL_GetError(), MESSAGEBOX_ERROR, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enforce minimum window dimensions.
|
||||
SDL_SetWindowMinimumSize(window, f.minwidth, f.minheight);
|
||||
|
||||
if (f.centered && !f.fullscreen)
|
||||
SDL_SetWindowPosition(window, centeredpos, centeredpos);
|
||||
if ((f.useposition || f.centered) && !f.fullscreen)
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
|
||||
SDL_RaiseWindow(window);
|
||||
|
||||
@@ -228,7 +243,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
#endif
|
||||
|
||||
if (!gfx->setMode(width, height, curMode.settings.sRGB))
|
||||
showMessageBox(MESSAGEBOX_ERROR, "Could not set graphics mode", "Unsupported OpenGL version?", true);
|
||||
showMessageBox("Could not set graphics mode", "Unsupported OpenGL version?", MESSAGEBOX_ERROR, true);
|
||||
}
|
||||
|
||||
// Make sure the mouse keeps its previous grab setting.
|
||||
@@ -289,7 +304,7 @@ bool Window::setContext(int msaa, bool vsync, bool sRGB)
|
||||
|
||||
if (!context)
|
||||
{
|
||||
showMessageBox(MESSAGEBOX_ERROR, "Could not create OpenGL context", SDL_GetError(), true);
|
||||
showMessageBox("Could not create OpenGL context", SDL_GetError(), MESSAGEBOX_ERROR, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -424,7 +439,8 @@ void Window::updateSettings(const WindowSettings &newsettings)
|
||||
curMode.settings.resizable = (wflags & SDL_WINDOW_RESIZABLE) != 0;
|
||||
curMode.settings.borderless = (wflags & SDL_WINDOW_BORDERLESS) != 0;
|
||||
curMode.settings.centered = newsettings.centered;
|
||||
curMode.settings.display = std::max(SDL_GetWindowDisplayIndex(window), 0);
|
||||
|
||||
getPosition(curMode.settings.x, curMode.settings.y, curMode.settings.display);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,1)
|
||||
curMode.settings.highdpi = (wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||
@@ -539,29 +555,17 @@ std::vector<WindowSize> Window::getFullscreenSizes(int displayindex) const
|
||||
{
|
||||
std::vector<WindowSize> sizes;
|
||||
|
||||
SDL_DisplayMode mode = {};
|
||||
std::vector<WindowSize>::const_iterator it;
|
||||
for (int i = 0; i < SDL_GetNumDisplayModes(displayindex); i++)
|
||||
{
|
||||
SDL_DisplayMode mode = {};
|
||||
SDL_GetDisplayMode(displayindex, i, &mode);
|
||||
|
||||
WindowSize w = {mode.w, mode.h};
|
||||
|
||||
// SDL2's display mode list has multiple entries for modes of the same
|
||||
// size with different bits per pixel, so we need to filter those out.
|
||||
bool alreadyhassize = false;
|
||||
for (it = sizes.begin(); it != sizes.end(); ++it)
|
||||
{
|
||||
if (it->width == mode.w && it->height == mode.h)
|
||||
{
|
||||
alreadyhassize = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!alreadyhassize)
|
||||
{
|
||||
WindowSize w = {mode.w, mode.h};
|
||||
if (std::find(sizes.begin(), sizes.end(), w) == sizes.end())
|
||||
sizes.push_back(w);
|
||||
}
|
||||
}
|
||||
|
||||
return sizes;
|
||||
@@ -593,6 +597,50 @@ void Window::getDesktopDimensions(int displayindex, int &width, int &height) con
|
||||
}
|
||||
}
|
||||
|
||||
void Window::setPosition(int x, int y, int displayindex)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
displayindex = std::min(std::max(displayindex, 0), getDisplayCount() - 1);
|
||||
|
||||
SDL_Rect displaybounds = {};
|
||||
SDL_GetDisplayBounds(displayindex, &displaybounds);
|
||||
|
||||
// The position needs to be in the global coordinate space.
|
||||
x += displaybounds.x;
|
||||
y += displaybounds.y;
|
||||
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
|
||||
curMode.settings.useposition = true;
|
||||
}
|
||||
|
||||
void Window::getPosition(int &x, int &y, int &displayindex)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
x = y = 0;
|
||||
displayindex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
displayindex = std::max(SDL_GetWindowDisplayIndex(window), 0);
|
||||
|
||||
SDL_GetWindowPosition(window, &x, &y);
|
||||
|
||||
// SDL always reports 0, 0 for fullscreen windows.
|
||||
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN))
|
||||
{
|
||||
SDL_Rect displaybounds = {};
|
||||
SDL_GetDisplayBounds(displayindex, &displaybounds);
|
||||
|
||||
// The position needs to be in the monitor's coordinate space.
|
||||
x -= displaybounds.x;
|
||||
y -= displaybounds.y;
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::isCreated() const
|
||||
{
|
||||
return created;
|
||||
@@ -666,6 +714,12 @@ void Window::minimize()
|
||||
SDL_MinimizeWindow(window);
|
||||
}
|
||||
|
||||
void Window::maximize()
|
||||
{
|
||||
if (window != nullptr)
|
||||
SDL_MaximizeWindow(window);
|
||||
}
|
||||
|
||||
void Window::swapBuffers()
|
||||
{
|
||||
SDL_GL_SwapWindow(window);
|
||||
@@ -746,6 +800,30 @@ bool Window::isTouchScreen(int displayindex) const
|
||||
#endif
|
||||
}
|
||||
|
||||
double Window::toPixels(double x) const
|
||||
{
|
||||
return x * getPixelScale();
|
||||
}
|
||||
|
||||
void Window::toPixels(double wx, double wy, double &px, double &py) const
|
||||
{
|
||||
double scale = getPixelScale();
|
||||
px = wx * scale;
|
||||
py = wy * scale;
|
||||
}
|
||||
|
||||
double Window::fromPixels(double x) const
|
||||
{
|
||||
return x / getPixelScale();
|
||||
}
|
||||
|
||||
void Window::fromPixels(double px, double py, double &wx, double &wy) const
|
||||
{
|
||||
double scale = getPixelScale();
|
||||
wx = px / scale;
|
||||
wy = py / scale;
|
||||
}
|
||||
|
||||
const void *Window::getHandle() const
|
||||
{
|
||||
return window;
|
||||
@@ -765,7 +843,7 @@ SDL_MessageBoxFlags Window::convertMessageBoxType(MessageBoxType type) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::showMessageBox(MessageBoxType type, const std::string &title, const std::string &message, bool attachtowindow)
|
||||
bool Window::showMessageBox(const std::string &title, const std::string &message, MessageBoxType type, bool attachtowindow)
|
||||
{
|
||||
SDL_MessageBoxFlags flags = convertMessageBoxType(type);
|
||||
SDL_Window *sdlwindow = attachtowindow ? window : nullptr;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2014 LOVE Development Team
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
|
||||
void getDesktopDimensions(int displayindex, int &width, int &height) const;
|
||||
|
||||
void setPosition(int x, int y, int displayindex);
|
||||
void getPosition(int &x, int &y, int &displayindex);
|
||||
|
||||
bool isCreated() const;
|
||||
|
||||
void setWindowTitle(const std::string &title);
|
||||
@@ -69,6 +72,7 @@ public:
|
||||
love::image::ImageData *getIcon();
|
||||
|
||||
void minimize();
|
||||
void maximize();
|
||||
|
||||
void swapBuffers();
|
||||
|
||||
@@ -87,9 +91,14 @@ public:
|
||||
|
||||
bool isTouchScreen(int displayindex) const;
|
||||
|
||||
double toPixels(double x) const;
|
||||
void toPixels(double wx, double wy, double &px, double &py) const;
|
||||
double fromPixels(double x) const;
|
||||
void fromPixels(double px, double py, double &wx, double &wy) const;
|
||||
|
||||
const void *getHandle() const;
|
||||
|
||||
bool showMessageBox(MessageBoxType type, const std::string &title, const std::string &message, bool attachtowindow);
|
||||
bool showMessageBox(const std::string &title, const std::string &message, MessageBoxType type, bool attachtowindow);
|
||||
int showMessageBox(const MessageBoxData &data);
|
||||
|
||||
static love::window::Window *createSingleton();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2014 LOVE Development Team
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -109,6 +109,16 @@ int w_setMode(lua_State *L)
|
||||
settings.highdpi = luax_boolflag(L, 3, settingName(Window::SETTING_HIGHDPI), false);
|
||||
settings.sRGB = luax_boolflag(L, 3, settingName(Window::SETTING_SRGB), false);
|
||||
|
||||
lua_getfield(L, 3, settingName(Window::SETTING_X));
|
||||
lua_getfield(L, 3, settingName(Window::SETTING_Y));
|
||||
settings.useposition = !(lua_isnoneornil(L, -2) && lua_isnoneornil(L, -1));
|
||||
if (settings.useposition)
|
||||
{
|
||||
settings.x = luaL_optint(L, -2, 0);
|
||||
settings.y = luaL_optint(L, -1, 0);
|
||||
}
|
||||
lua_pop(L, 2);
|
||||
|
||||
// We don't explicitly set the refresh rate, it's "read-only".
|
||||
|
||||
// For backward-compatibility. TODO: remove!
|
||||
@@ -178,6 +188,12 @@ int w_getMode(lua_State *L)
|
||||
lua_pushnumber(L, settings.refreshrate);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_REFRESHRATE));
|
||||
|
||||
lua_pushinteger(L, settings.x);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_X));
|
||||
|
||||
lua_pushinteger(L, settings.y);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_Y));
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -279,6 +295,27 @@ int w_getDesktopDimensions(lua_State *L)
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_setPosition(lua_State *L)
|
||||
{
|
||||
int x = luaL_checkint(L, 1);
|
||||
int y = luaL_checkint(L, 2);
|
||||
int displayindex = luaL_optint(L, 3, 1) - 1;
|
||||
instance()->setPosition(x, y, displayindex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_getPosition(lua_State *L)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int displayindex = 0;
|
||||
instance()->getPosition(x, y, displayindex);
|
||||
lua_pushinteger(L, x);
|
||||
lua_pushinteger(L, y);
|
||||
lua_pushinteger(L, displayindex + 1);
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_setIcon(lua_State *L)
|
||||
{
|
||||
image::ImageData *i = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
@@ -340,41 +377,86 @@ int w_isTouchScreen(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_toPixels(lua_State *L)
|
||||
{
|
||||
double wx = luaL_checknumber(L, 1);
|
||||
|
||||
if (lua_isnoneornil(L, 2))
|
||||
{
|
||||
lua_pushnumber(L, instance()->toPixels(wx));
|
||||
return 1;
|
||||
}
|
||||
|
||||
double wy = luaL_checknumber(L, 2);
|
||||
double px = 0.0, py = 0.0;
|
||||
|
||||
instance()->toPixels(wx, wy, px, py);
|
||||
|
||||
lua_pushnumber(L, px);
|
||||
lua_pushnumber(L, py);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_fromPixels(lua_State *L)
|
||||
{
|
||||
double px = luaL_checknumber(L, 1);
|
||||
|
||||
if (lua_isnoneornil(L, 2))
|
||||
{
|
||||
lua_pushnumber(L, instance()->fromPixels(px));
|
||||
return 1;
|
||||
}
|
||||
|
||||
double py = luaL_checknumber(L, 2);
|
||||
double wx = 0.0, wy = 0.0;
|
||||
|
||||
instance()->fromPixels(px, py, wx, wy);
|
||||
|
||||
lua_pushnumber(L, wx);
|
||||
lua_pushnumber(L, wy);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_minimize(lua_State* /*L*/)
|
||||
{
|
||||
instance()->minimize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_maximize(lua_State *)
|
||||
{
|
||||
instance()->maximize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_showMessageBox(lua_State *L)
|
||||
{
|
||||
Window::MessageBoxData data = {};
|
||||
data.type = Window::MESSAGEBOX_INFO;
|
||||
|
||||
const char *typestr = luaL_checkstring(L, 1);
|
||||
if (!Window::getConstant(typestr, data.type))
|
||||
return luaL_error(L, "Invalid messagebox type: %s", typestr);
|
||||
|
||||
data.title = luaL_checkstring(L, 2);
|
||||
data.message = luaL_checkstring(L, 3);
|
||||
data.title = luaL_checkstring(L, 1);
|
||||
data.message = luaL_checkstring(L, 2);
|
||||
|
||||
// If we have a table argument, we assume a list of button names, which
|
||||
// means we should use the more complex message box API.
|
||||
if (lua_istable(L, 4))
|
||||
if (lua_istable(L, 3))
|
||||
{
|
||||
size_t numbuttons = lua_objlen(L, 4);
|
||||
size_t numbuttons = lua_objlen(L, 3);
|
||||
if (numbuttons == 0)
|
||||
return luaL_error(L, "Must have at least one messagebox button.");
|
||||
|
||||
// Array of button names.
|
||||
for (size_t i = 0; i < numbuttons; i++)
|
||||
{
|
||||
lua_rawgeti(L, 4, i + 1);
|
||||
lua_rawgeti(L, 3, i + 1);
|
||||
data.buttons.push_back(luax_checkstring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
// Optional table entry specifying the button to use when enter is pressed.
|
||||
lua_getfield(L, 4, "enterbutton");
|
||||
lua_getfield(L, 3, "enterbutton");
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
data.enterButtonIndex = luaL_checkint(L, -1) - 1;
|
||||
else
|
||||
@@ -382,13 +464,17 @@ int w_showMessageBox(lua_State *L)
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Optional table entry specifying the button to use when esc is pressed.
|
||||
lua_getfield(L, 4, "escapebutton");
|
||||
lua_getfield(L, 3, "escapebutton");
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
data.escapeButtonIndex = luaL_checkint(L, -1) - 1;
|
||||
else
|
||||
data.escapeButtonIndex = (int) data.buttons.size() - 1;
|
||||
lua_pop(L, 1);
|
||||
|
||||
const char *typestr = lua_isnoneornil(L, 4) ? nullptr : luaL_checkstring(L, 4);
|
||||
if (typestr && !Window::getConstant(typestr, data.type))
|
||||
return luaL_error(L, "Invalid messagebox type: %s", typestr);
|
||||
|
||||
data.attachToWindow = luax_optboolean(L, 5, true);
|
||||
|
||||
int pressedbutton = instance()->showMessageBox(data);
|
||||
@@ -396,10 +482,14 @@ int w_showMessageBox(lua_State *L)
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *typestr = lua_isnoneornil(L, 3) ? nullptr : luaL_checkstring(L, 3);
|
||||
if (typestr && !Window::getConstant(typestr, data.type))
|
||||
return luaL_error(L, "Invalid messagebox type: %s", typestr);
|
||||
|
||||
data.attachToWindow = luax_optboolean(L, 4, true);
|
||||
|
||||
// Display a simple message box.
|
||||
bool success = instance()->showMessageBox(data.type, data.title, data.message, data.attachToWindow);
|
||||
bool success = instance()->showMessageBox(data.title, data.message, data.type, data.attachToWindow);
|
||||
luax_pushboolean(L, success);
|
||||
}
|
||||
|
||||
@@ -420,6 +510,8 @@ static const luaL_Reg functions[] =
|
||||
{ "getHeight", w_getHeight },
|
||||
{ "getDimensions", w_getDimensions },
|
||||
{ "getDesktopDimensions", w_getDesktopDimensions },
|
||||
{ "setPosition", w_setPosition },
|
||||
{ "getPosition", w_getPosition },
|
||||
{ "setIcon", w_setIcon },
|
||||
{ "getIcon", w_getIcon },
|
||||
{ "setTitle", w_setTitle },
|
||||
@@ -429,6 +521,8 @@ static const luaL_Reg functions[] =
|
||||
{ "isVisible", w_isVisible },
|
||||
{ "getPixelScale", w_getPixelScale },
|
||||
{ "isTouchScreen", w_isTouchScreen },
|
||||
{ "toPixels", w_toPixels },
|
||||
{ "fromPixels", w_fromPixels },
|
||||
{ "minimize", w_minimize },
|
||||
{ "showMessageBox", w_showMessageBox },
|
||||
{ 0, 0 }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2014 LOVE Development Team
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -41,6 +41,8 @@ int w_getWidth(lua_State *L);
|
||||
int w_getHeight(lua_State *L);
|
||||
int w_getDimensions(lua_State *L);
|
||||
int w_getDesktopDimensions(lua_State *L);
|
||||
int w_setPosition(lua_State *L);
|
||||
int w_getPosition(lua_State *L);
|
||||
int w_setIcon(lua_State *L);
|
||||
int w_getIcon(lua_State *L);
|
||||
int w_setTitle(lua_State *L);
|
||||
@@ -50,7 +52,10 @@ int w_hasMouseFocus(lua_State *L);
|
||||
int w_isVisible(lua_State *L);
|
||||
int w_getPixelScale(lua_State *L);
|
||||
int w_isTouchScreen(lua_State *L);
|
||||
int w_toPixels(lua_State *L);
|
||||
int w_fromPixels(lua_State *L);
|
||||
int w_minimize(lua_State *L);
|
||||
int w_maximize(lua_State *L);
|
||||
int w_showMessageBox(lua_State *L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_window(lua_State *L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user