From 2df6d32ec66e49d9dc6ad6657c4832e0b6c33fa2 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Sat, 30 Jul 2011 16:18:36 +0000 Subject: [PATCH] Added an option to set scroll distance. Set it high enough and you get always centered scrolling git-svn-id: http://svn.net-core.org/repos/t-engine4@4027 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/modules/tome/class/Player.lua | 2 +- game/modules/tome/dialogs/GameOptions.lua | 25 +++++++++++++---------- game/modules/tome/load.lua | 1 + 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 70da42b369..b217a38e0a 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -172,7 +172,7 @@ function _M:move(x, y, force) local ox, oy = self.x, self.y local moved = mod.class.Actor.move(self, x, y, force) if moved then - game.level.map:moveViewSurround(self.x, self.y, 8, 8) + game.level.map:moveViewSurround(self.x, self.y, config.settings.tome.scroll_dist, config.settings.tome.scroll_dist) game.level.map.attrs(self.x, self.y, "walked", true) if self.describeFloor then self:describeFloor(self.x, self.y) end diff --git a/game/modules/tome/dialogs/GameOptions.lua b/game/modules/tome/dialogs/GameOptions.lua index 786a687995..754819170d 100644 --- a/game/modules/tome/dialogs/GameOptions.lua +++ b/game/modules/tome/dialogs/GameOptions.lua @@ -62,6 +62,18 @@ function _M:generateList() local list = {} local i = 0 + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Defines the distance from the screen edge at which scrolling will start. If set high enough the game will always center on the player.#WHITE#"} + list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Scroll distance#WHITE##{normal}#", status=function(item) + return tostring(config.settings.tome.scroll_dist) + end, fct=function(item) + game:registerDialog(GetQuantity.new("Scroll distance", "From 1 to 20", config.settings.tome.scroll_dist, 20, function(qty) + qty = util.bound(qty, 1, 20) + game:saveSettings("tome.scroll_dist", ("tome.scroll_dist = %d\n"):format(qty)) + config.settings.tome.scroll_dist = qty + self.c_list:drawItem(item) + end, 1)) + end,} + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Saves in the background, allowing you to continue playing. If disabled you will have to wait until the saving is done, but it will be faster.#WHITE#"} list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Save in the background#WHITE##{normal}#", status=function(item) return tostring(config.settings.background_saves and "enabled" or "disabled") @@ -70,16 +82,7 @@ function _M:generateList() game:saveSettings("background_saves", ("background_saves = %s\n"):format(tostring(config.settings.background_saves))) self.c_list:drawItem(item) end,} ---[[ - local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Autosaves the whole game when switching zones. This is safer but can make playing a bit slower while it saves. Savefiles will also be somewhat bigger.#WHITE#"} - list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Autosave when leaving a zone#WHITE##{normal}#", status=function(item) - return tostring(config.settings.tome.autosave and "enabled" or "disabled") - end, fct=function(item) - config.settings.tome.autosave = not config.settings.tome.autosave - game:saveSettings("tome.autosave", ("tome.autosave = %s\n"):format(tostring(config.settings.tome.autosave))) - self.c_list:drawItem(item) - end,} -]] + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Forces the game to save each level instead of each zone.\nThis makes it save more often but the game will use less memory when deep in a dungeon.\n\n#LIGHT_RED#Changing this option will not affect already visited zones.#WHITE#"} list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Zone save per level#WHITE##{normal}#", status=function(item) return tostring(config.settings.tome.save_zone_levels and "enabled" or "disabled") @@ -191,7 +194,7 @@ function _M:generateList() list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Log fade time#WHITE##{normal}#", status=function(item) return tostring(config.settings.tome.log_fade) end, fct=function(item) - game:registerDialog(GetQuantity.new("Fade time (in seconds)", "From 2 to 20", config.settings.tome.log_fade, 20, function(qty) + game:registerDialog(GetQuantity.new("Fade time (in seconds)", "From 0 to 20", config.settings.tome.log_fade, 20, function(qty) qty = util.bound(qty, 0, 20) game:saveSettings("tome.log_fade", ("tome.log_fade = %d\n"):format(qty)) config.settings.tome.log_fade = qty diff --git a/game/modules/tome/load.lua b/game/modules/tome/load.lua index 0ef73547ed..a373b0b2b1 100644 --- a/game/modules/tome/load.lua +++ b/game/modules/tome/load.lua @@ -66,6 +66,7 @@ if not config.settings.tome.fonts then config.settings.tome.fonts = {type="fanta if not config.settings.tome.ui_theme then config.settings.tome.ui_theme = "stone" end if not config.settings.tome.log_lines then config.settings.tome.log_lines = 5 end if not config.settings.tome.log_fade then config.settings.tome.log_fade = 3 end +if not config.settings.tome.scroll_dist then config.settings.tome.scroll_dist = 8 end Map.smooth_scroll = config.settings.tome.smooth_move Map.faction_danger_check = function(self, e) return e.rank > 3 end -- GitLab