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

added fullscreen resolutions to the menu

git-svn-id: http://svn.net-core.org/repos/t-engine4@448 51575b47-30f0-44d4-a5cc-537603b46e54
parent 533c4df2
No related branches found
No related tags found
No related merge requests found
......@@ -147,17 +147,21 @@ end
available_resolutions =
{
["800x600"] = {800, 600},
["1024x768"] = {1024, 768},
["1200x1024"] = {1200, 1024},
["1600x1200"] = {1600, 1200},
["800x600"] = {800, 600, false},
["1024x768"] = {1024, 768, false},
["1200x1024"] = {1200, 1024, false},
["1600x1200"] = {1600, 1200, false},
["800x600 Fullscreen"] = {800, 600, true},
["1024x768 Fullscreen"] = {1024, 768, true},
["1200x1024 Fullscreen"] = {1200, 1024, true},
["1600x1200 Fullscreen"] = {1600, 1200, true},
}
--- Change screen resolution
function _M:setResolution(res)
if not available_resolutions[res] then return false, "unknown resolution" end
local old_w, old_h = self.w, self.h
core.display.setWindowSize(available_resolutions[res][1], available_resolutions[res][2])
core.display.setWindowSize(available_resolutions[res][1], available_resolutions[res][2], available_resolutions[res][3])
self.w, self.h = core.display.size()
if self.w ~= old_w or self.h ~= old_h then
......
......@@ -45,7 +45,15 @@ function _M:generateList()
for r, _ in pairs(game.available_resolutions) do
l[#l+1] = r
end
table.sort(l, function(a,b) return game.available_resolutions[a][1] < game.available_resolutions[b][1] end)
table.sort(l, function(a,b)
if game.available_resolutions[a][2] == game.available_resolutions[b][2] then
return (game.available_resolutions[a][3] and 1 or 0) < (game.available_resolutions[b][3] and 1 or 0)
elseif game.available_resolutions[a][1] == game.available_resolutions[b][1] then
return game.available_resolutions[a][2] < game.available_resolutions[b][2]
else
return game.available_resolutions[a][1] < game.available_resolutions[b][1]
end
end)
-- Makes up the list
local list = {}
......
......@@ -64,7 +64,7 @@ function _M:init(t, no_default)
end
function _M:move(x, y, force)
x, y = self:tryPlayerSlide(x, y, force)
-- x, y = self:tryPlayerSlide(x, y, force)
local moved = mod.class.Actor.move(self, x, y, force)
if moved then
......
......@@ -823,8 +823,11 @@ static int sdl_set_window_size(lua_State *L)
int w = luaL_checknumber(L, 1);
int h = luaL_checknumber(L, 2);
bool fullscreen = lua_toboolean(L, 3);
int flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_HWSURFACE;
screen = SDL_SetVideoMode(w, h, 32, SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_HWSURFACE);
if (fullscreen) flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_HWSURFACE | SDL_FULLSCREEN;
screen = SDL_SetVideoMode(w, h, 32, flags);
if (screen==NULL) {
printf("error opening screen: %s\n", SDL_GetError());
return 0;
......
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