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

fixed loading screen

git-svn-id: http://svn.net-core.org/repos/t-engine4@153 51575b47-30f0-44d4-a5cc-537603b46e54
parent 661676f5
No related branches found
No related tags found
No related merge requests found
......@@ -99,22 +99,16 @@ function _M:click(i)
end
function _M:display()
if not self.changed then return self.surface end
end
self.surface:erase()
function _M:toScreen(x,y)
for i, b in ipairs(self.list) do
if i == self.selected then
self.surface:merge(b.ssel, 0, (i - 1) * (b.h + self.separator))
b.ssel:toScreen(x + 0, y + (i - 1) * (b.h + self.separator))
else
self.surface:merge(b.susel, 0, (i - 1) * (b.h + self.separator))
b.susel:toScreen(x + 0, y + (i - 1) * (b.h + self.separator))
end
end
return self.surface
end
function _M:toScreen(x,y)
self.surface:toScreenWithTexture(self.texture,x,y)
end
function _M:makeButton(name, font, w, h, sel)
......@@ -122,8 +116,9 @@ function _M:makeButton(name, font, w, h, sel)
local s = core.display.newSurface(w, h)
if sel then
s:erase(143, 155, 85, 200)
else
s:erase(0,0,0,200)
end
s:erase(0,0,0,200)
s:merge(tiles:get(nil, 0,0,0, 0,0,0, "border_7"..(sel and "_sel" or "")..".png"), 0, 0)
s:merge(tiles:get(nil, 0,0,0, 0,0,0, "border_9"..(sel and "_sel" or "")..".png"), w - 8, 0)
......
......@@ -21,6 +21,7 @@ end
--- Setups as the current game keyhandler
function _M:setCurrent()
core.key.set_current_handler(self)
if game then game.key = self end
_M.current = self
end
......
......@@ -52,8 +52,7 @@ end
--- List all available savefiles
-- Static
function _M:listSavefiles()
local savemods_path = fs.getHomePath() .. fs.getPathSeparator()
fs.mount(savemods_path, "/tmp/listsaves")
fs.mount(engine.homepath, "/tmp/listsaves")
local mods = self:listModules()
for _, mod in ipairs(mods) do
......@@ -74,7 +73,7 @@ function _M:listSavefiles()
end)
end
fs.umount(savemods_path)
fs.umount(engine.homepath)
return mods
end
......
......@@ -31,6 +31,7 @@ end
--- Setups as the current game keyhandler
function _M:setCurrent()
core.mouse.set_current_handler(self)
if game then game.mouse = self end
_M.current = self
end
......
......@@ -10,6 +10,8 @@ module(..., package.seeall, class.inherit(engine.Game))
function _M:init()
engine.Game.init(self, engine.KeyCommand.new())
self.background = core.display.loadImage("/data/gfx/mainmenu/background.jpg")
end
function _M:run()
......@@ -24,6 +26,11 @@ function _M:run()
end
function _M:display()
if self.background then
local bw, bh = self.background:getSize()
self.background:toScreen((self.w - bw) / 2, (self.h - bh) / 2)
end
self.step:display()
self.step:toScreen(self.step.display_x, self.step.display_y)
engine.Game.display(self)
......@@ -133,11 +140,17 @@ function _M:selectStepNew()
end
function _M:selectStepLoad()
local found = false
for i, mod in ipairs(self.save_list) do for j, save in ipairs(mod.savefiles) do found = true break end end
if not found then
Dialog:simplePopup("No savefiles", "You do not have any savefiles for any of the installed modules. Play a new game!")
return
end
local display_module = Dialog.new("", self.w * 0.73, self.h, self.w * 0.26, 0, 255)
local mod_font = core.display.newFont("/data/font/VeraIt.ttf", 14)
local list = {}
local found = false
for i, mod in ipairs(self.save_list) do
table.insert(list, { name=mod.name, font=mod_font, description="", fct=function() end, onSelect=function() self.step:skipSelected() end})
......@@ -158,11 +171,6 @@ function _M:selectStepLoad()
end
end
if not found then
Dialog:simplePopup("No savefiles", "You do not have any savefiles for any of the installed modules. Play a new game!")
return
end
-- Ok some saves to see, proceed
if self.step and self.step.close then self.step:close() end
......
......@@ -425,6 +425,7 @@ static int sdl_load_image(lua_State *L)
auxiliar_setclass(L, "sdl{surface}", -1);
*s = IMG_Load_RW(PHYSFSRWOPS_openRead(name), TRUE);
if (!*s) return 0;
return 1;
}
......@@ -463,6 +464,14 @@ static int sdl_surface_erase(lua_State *L)
return 0;
}
static int sdl_surface_get_size(lua_State *L)
{
SDL_Surface **s = (SDL_Surface**)auxiliar_checkclass(L, "sdl{surface}", 1);
lua_pushnumber(L, (*s)->w);
lua_pushnumber(L, (*s)->h);
return 2;
}
static void draw_textured_quad(int x, int y, int w, int h) {
glBegin( GL_QUADS );
......@@ -646,8 +655,9 @@ static const struct luaL_reg sdl_surface_reg[] =
{"__gc", sdl_free_surface},
{"close", sdl_free_surface},
{"erase", sdl_surface_erase},
{"getSize", sdl_surface_get_size},
{"merge", sdl_surface_merge},
{"toScreen", sdl_surface_toscreen},
{"toScreen", sdl_surface_toscreen},
{"toScreenWithTexture", sdl_surface_toscreen_with_texture},
{"putChar", lua_display_char},
{"drawString", sdl_surface_drawstring},
......
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