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

Activating caps-lock will put the map in scroll mode, allowing keyboard-only...

Activating caps-lock will put the map in scroll mode, allowing keyboard-only scrolling with the direction keys


git-svn-id: http://svn.net-core.org/repos/t-engine4@3798 51575b47-30f0-44d4-a5cc-537603b46e54
parent 499dc7a6
No related branches found
No related tags found
No related merge requests found
......@@ -722,6 +722,15 @@ function _M:checkMapViewBounded()
self._map:setScroll(self.mx, self.my, centered and 0 or self.smooth_scroll)
end
--- Scrolls the map in the given direction
function _M:scrollDir(dir)
self.changed = true
self.mx, self.my = util.coordAddDir(self.mx, self.my, dir)
self.mx = util.bound(self.mx, 0, self.w - self.viewport.mwidth)
self.my = util.bound(self.my, 0, self.h - self.viewport.mheight)
self._map:setScroll(self.mx, self.my, self.smooth_scroll)
end
--- Gets the tile under the mouse
function _M:getMouseTile(mx, my)
-- if mx < self.display_x or my < self.display_y or mx >= self.display_x + self.viewport.width or my >= self.display_y + self.viewport.height then return end
......
......@@ -173,6 +173,13 @@ function _M:run()
-- Run the current music if any
self:onTickEnd(function() self:playMusic() end)
-- Create the map scroll text overlay
self.player_display.font:setStyle("bold")
local s = core.display.drawStringBlendedNewSurface(self.player_display.font, "<Scroll mode, press keys to scroll, caps lock to exit>", unpack(colors.simple(colors.GOLD)))
self.player_display.font:setStyle("normal")
self.caps_scroll = {s:glTexture()}
self.caps_scroll.w, self.caps_scroll.h = s:getSize()
end
--- Checks if the current character is "tainted" by cheating
......@@ -913,6 +920,19 @@ function _M:display(nb_keyframes)
-- Mouse gestures
self.gestures:update()
self.gestures:display(map.display_x, map.display_y + map.viewport.height - self.gestures.font_h - 5)
-- Inform the player that map is in scroll mode
if core.key.modState("caps") then
local w = map.viewport.width * 0.5
local h = w * self.caps_scroll.h / self.caps_scroll.w
self.caps_scroll[1]:toScreenFull(
map.display_x + (map.viewport.width - w) / 2,
map.display_y + (map.viewport.height - h) / 2,
w, h,
self.caps_scroll[2] * w / self.caps_scroll.w, self.caps_scroll[3] * h / self.caps_scroll.h,
1, 1, 1, 0.5
)
end
end
-- We display the player's interface
......@@ -1033,15 +1053,15 @@ function _M:setupCommands()
self.key:addBinds
{
-- Movements
MOVE_LEFT = function() self.player:moveDir(4) end,
MOVE_RIGHT = function() self.player:moveDir(6) end,
MOVE_UP = function() self.player:moveDir(8) end,
MOVE_DOWN = function() self.player:moveDir(2) end,
MOVE_LEFT_UP = function() self.player:moveDir(7) end,
MOVE_LEFT_DOWN = function() self.player:moveDir(1) end,
MOVE_RIGHT_UP = function() self.player:moveDir(9) end,
MOVE_RIGHT_DOWN = function() self.player:moveDir(3) end,
MOVE_STAY = function() if self.player:enoughEnergy() then self.player:describeFloor(self.player.x, self.player.y) self.player:useEnergy() end end,
MOVE_LEFT = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(4) else self.player:moveDir(4) end end,
MOVE_RIGHT = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(6) else self.player:moveDir(6) end end,
MOVE_UP = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(8) else self.player:moveDir(8) end end,
MOVE_DOWN = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(2) else self.player:moveDir(2) end end,
MOVE_LEFT_UP = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(7) else self.player:moveDir(7) end end,
MOVE_LEFT_DOWN = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(1) else self.player:moveDir(1) end end,
MOVE_RIGHT_UP = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(9) else self.player:moveDir(9) end end,
MOVE_RIGHT_DOWN = function() if core.key.modState("caps") and self.level then self.level.map:scrollDir(3) else self.player:moveDir(3) end end,
MOVE_STAY = function() if core.key.modState("caps") and self.level then self.level.map:centerViewAround(self.player.x, self.player.y) else if self.player:enoughEnergy() then self.player:describeFloor(self.player.x, self.player.y) self.player:useEnergy() end end end,
RUN = function()
game.log("Run in which direction?")
......
......@@ -108,3 +108,11 @@ newLore{
image = "shertul_fortress_lore9.png",
lore = function() return [[This final mural has been ruined, with deep scores and scratches etched across its surface. All you can see of the original appears to be flames.]] end,
}
newLore{
id = "shertul-fortress-takeoff",
category = "sher'tul",
name = "Yiilkgur raising toward the sky",
image = "fortress_takeoff.png",
lore = [[Yiilkgur, the Sher'Tul Fortress is re-activated and raises from the depths of Nur toward the sky.]],
}
......@@ -151,6 +151,8 @@ upgrade_rod = function(self)
end
fly = function(self)
game.player:learnLore("shertul-fortress-takeoff")
local f = require("mod.class.FortressPC").new{}
game:changeLevel(1, "wilderness")
game.party:addMember(f, {temporary_level=1, control="full"})
......
......@@ -28,6 +28,7 @@ module(..., package.seeall, class.inherit(Dialog))
function _M:init(title, actor)
self.actor = actor
print("Lore of player", actor.name)
local total = #actor.lore_defs + actor.additional_lore_nb
local nb = 0
for id, data in pairs(actor.lore_known) do nb = nb + 1 end
......
......@@ -184,6 +184,7 @@ static int lua_get_mod_state(lua_State *L)
else if (!strcmp(mod, "ctrl")) lua_pushboolean(L, smod & KMOD_CTRL);
else if (!strcmp(mod, "alt")) lua_pushboolean(L, smod & KMOD_ALT);
else if (!strcmp(mod, "meta")) lua_pushboolean(L, smod & KMOD_META);
else if (!strcmp(mod, "caps")) lua_pushboolean(L, smod & KMOD_CAPS);
else lua_pushnil(L);
return 1;
......
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