diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 786024fc8baa4fb541bf878a499b6e73ec745e57..df762e958bcb9a871cf5741cfdfc57f53c465404 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -124,7 +124,7 @@ function _M:run() -- Start time self.real_starttime = os.time() - if self.level then self:setupDisplayMode() end + if self.level then self:setupDisplayMode(false, "postinit") end end --- Checks if the current character is "tainted" by cheating @@ -144,7 +144,7 @@ function _M:newGame() orders = {follow=true, behavior=true, leash=true}, }) self.party:setPlayer(player) - self:setupDisplayMode() +-- self:setupDisplayMode() -- Create the entity to store various game state things self.state = GameState.new{} @@ -291,7 +291,7 @@ function _M:loaded() end, } Map:setViewerActor(self.player) - Map:setViewPort(216, 36, self.w - 216, math.floor(self.h * 0.80) - 36, 32, 32, nil, 22, true) + self:setupDisplayMode(false, "init") if self.player then self.player.changed = true end self.key = engine.KeyBind.new() @@ -299,59 +299,63 @@ function _M:loaded() if self.player and config.settings.cheat then self.player.__cheated = true end end -function _M:setupDisplayMode(reboot) - local gfx = config.settings.tome.gfx - self:saveSettings("tome.gfx", ('tome.gfx = {tiles=%q, size=%q}\n'):format(gfx.tiles, gfx.size)) +function _M:setupDisplayMode(reboot, mode) + if not mode or mode == "init" then + local gfx = config.settings.tome.gfx + self:saveSettings("tome.gfx", ('tome.gfx = {tiles=%q, size=%q}\n'):format(gfx.tiles, gfx.size)) - if reboot then - self.change_res_dialog = true - self:saveGame() - util.showMainMenu(false, nil, nil, self.__mod_info.short_name, self.save_name, false) - end - - -- Show a count for stacked objects - Map.object_stack_count = true + if reboot then + self.change_res_dialog = true + self:saveGame() + util.showMainMenu(false, nil, nil, self.__mod_info.short_name, self.save_name, false) + end - -- Select tiles - Tiles.prefix = "/data/gfx/" - if gfx.tiles ~= "mushroom" then - Tiles.prefix = "/data/gfx/"..gfx.tiles.."/" - end - print("[DISPLAY MODE] Tileset: "..gfx.tiles) - print("[DISPLAY MODE] Size: "..gfx.size) - - local do_bg = true - - if gfx.size == "64x64" then - Map:setViewPort(216, 36, self.w - 216, math.floor(self.h * 0.80) - 36, 64, 64, nil, 44, do_bg) - Map:resetTiles() - elseif gfx.size == "32x32" then - Map:setViewPort(216, 36, self.w - 216, math.floor(self.h * 0.80) - 36, 32, 32, nil, 22, do_bg) - Map:resetTiles() - elseif gfx.size == "16x16" then - Map:setViewPort(216, 36, self.w - 216, math.floor(self.h * 0.80) - 36, 16, 16, "/data/font/FSEX300.ttf", 16, do_bg) - Map:resetTiles() - end + -- Show a count for stacked objects + Map.object_stack_count = true - Map.tiles.use_images = true - if gfx.tiles == "ascii" then Map.tiles.use_images = false Map.tiles.force_back_color = {r=0, g=0, b=0, a=255} end - if gfx.tiles == "ascii_full" then Map.tiles.use_images = false end - if gfx.tiles == "shockbolt" then Map.tiles.nicer_tiles = true end + -- Select tiles + Tiles.prefix = "/data/gfx/" + if gfx.tiles ~= "mushroom" then + Tiles.prefix = "/data/gfx/"..gfx.tiles.."/" + end + print("[DISPLAY MODE] Tileset: "..gfx.tiles) + print("[DISPLAY MODE] Size: "..gfx.size) + + local do_bg = true + + if gfx.size == "64x64" then + Map:setViewPort(216, 36, self.w - 216, math.floor(self.h * 0.80) - 36, 64, 64, nil, 44, do_bg) + Map:resetTiles() + elseif gfx.size == "32x32" then + Map:setViewPort(216, 36, self.w - 216, math.floor(self.h * 0.80) - 36, 32, 32, nil, 22, do_bg) + Map:resetTiles() + elseif gfx.size == "16x16" then + Map:setViewPort(216, 36, self.w - 216, math.floor(self.h * 0.80) - 36, 16, 16, "/data/font/FSEX300.ttf", 16, do_bg) + Map:resetTiles() + end - if self.level then - self.level.map:recreate() - self:initTargeting() - self.level.map:moveViewSurround(self.player.x, self.player.y, 8, 8) + Map.tiles.use_images = true + if gfx.tiles == "ascii" then Map.tiles.use_images = false Map.tiles.force_back_color = {r=0, g=0, b=0, a=255} end + if gfx.tiles == "ascii_full" then Map.tiles.use_images = false end + if gfx.tiles == "shockbolt" then Map.tiles.nicer_tiles = true end end - self:setupMiniMap() - -- Create the framebuffer - self.fbo = core.display.newFBO(Map.viewport.width, Map.viewport.height) - if self.fbo then - self.fbo_shader = Shader.new("main_fbo") - if not self.fbo_shader.shad then self.fbo = nil self.fbo_shader = nil end + if not mode or mode == "postinit" then + if self.level then + self.level.map:recreate() + self:initTargeting() + self.level.map:moveViewSurround(self.player.x, self.player.y, 8, 8) + end + self:setupMiniMap() + + -- Create the framebuffer + self.fbo = core.display.newFBO(Map.viewport.width, Map.viewport.height) + if self.fbo then + self.fbo_shader = Shader.new("main_fbo") + if not self.fbo_shader.shad then self.fbo = nil self.fbo_shader = nil end + end + if self.player then self.player:updateMainShader() end end - if self.player then self.player:updateMainShader() end end function _M:initTargeting() diff --git a/src/particles.c b/src/particles.c index 2ee1610b46dfd018fbc36a6654d59e7d6c0a6453..348da52e72f072b09cccdb64a88a76deea001d79 100644 --- a/src/particles.c +++ b/src/particles.c @@ -88,7 +88,6 @@ static int particles_new(lua_State *L) ps->lock = SDL_CreateMutex(); ps->name_def = strdup(name_def); ps->args = strdup(args); - ps->zoom = zoom; ps->density = density; ps->alive = TRUE; ps->l = NULL; @@ -211,6 +210,8 @@ static int particles_to_screen(lua_State *L) glColorPointer(4, GL_FLOAT, 0, colors); glVertexPointer(2, GL_FLOAT, 0, vertices); glTranslatef(x, y, 0); + glPushMatrix(); + glScalef(ps->zoom, ps->zoom, ps->zoom); glRotatef(ps->rotate, 0, 0, 1); int remaining = ps->batch_nb; @@ -224,6 +225,7 @@ static int particles_to_screen(lua_State *L) SDL_mutexV(ps->lock); glRotatef(-ps->rotate, 0, 0, 1); + glPopMatrix(); glTranslatef(-x, -y, 0); return 0; @@ -234,7 +236,7 @@ static void particles_update(lua_State *L, particles_type *ps, bool last) { int w = 0; bool alive = FALSE; - float zoom = ps->zoom; + float zoom = 1; int vert_idx = 0, col_idx = 0; int i, j;