diff --git a/game/engines/default/engine/Key.lua b/game/engines/default/engine/Key.lua index 439882025ec45502356475bc8139591742e10c88..b16d096a7f36400b64f3ae0d318991cd9480df28 100644 --- a/game/engines/default/engine/Key.lua +++ b/game/engines/default/engine/Key.lua @@ -35,7 +35,8 @@ end -- @param meta is the meta key pressed? -- @param unicode the unicode representation of the key, if possible -- @param isup true if the key was released, false if pressed -function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup) +-- @param key the unicode representation of the key pressed (without accounting for modifiers) +function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, key) print(sym, ctrl, shift, alt, meta, unicode, isup) self:handleStatus(sym, ctrl, shift, alt, meta, unicode, isup) end diff --git a/game/engines/default/engine/KeyBind.lua b/game/engines/default/engine/KeyBind.lua index a306d9aee882aba6ce4f5c60b5c68f939a907556..d1f374145665292cbd819c2bf615323cd0281af2 100644 --- a/game/engines/default/engine/KeyBind.lua +++ b/game/engines/default/engine/KeyBind.lua @@ -202,10 +202,10 @@ function _M:formatKeyString(ks) end end -function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, ismouse) +function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, key, ismouse) self:handleStatus(sym, ctrl, shift, alt, meta, unicode, isup) - if self.any_key then self.any_key(sym, ctrl, shift, alt, meta, unicode, isup) end + if self.any_key then self.any_key(sym, ctrl, shift, alt, meta, unicode, isup, key) end local ks, us if not ismouse then ks, us = self:makeKeyString(sym, ctrl, shift, alt, meta, unicode) @@ -225,7 +225,7 @@ function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, ismouse) end end end - return engine.KeyCommand.receiveKey(self, sym, ctrl, shift, alt, meta, unicode, isup) + return engine.KeyCommand.receiveKey(self, sym, ctrl, shift, alt, meta, unicode, isup, key) end --- Reset all binds diff --git a/game/engines/default/engine/KeyCommand.lua b/game/engines/default/engine/KeyCommand.lua index 096c0f7bb0b39b7abc602a0d6bfd861753ee42ea..c0bf42814f4701a915d3682b80e1aad83d050627 100644 --- a/game/engines/default/engine/KeyCommand.lua +++ b/game/engines/default/engine/KeyCommand.lua @@ -50,7 +50,7 @@ function _M:setupProfiler() end) end -function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup) +function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, key) self:handleStatus(sym, ctrl, shift, alt, meta, unicode, isup) if self.ignore[sym] then return end @@ -77,11 +77,11 @@ function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup) self.commands[sym].plain(sym, ctrl, shift, alt, meta, unicode) handled = true elseif not isup and self.commands[self.__DEFAULT] and self.commands[self.__DEFAULT].plain then - self.commands[self.__DEFAULT].plain(sym, ctrl, shift, alt, meta, unicode) + self.commands[self.__DEFAULT].plain(sym, ctrl, shift, alt, meta, unicode, key) handled = true end - if not isup and self.atLast then self.atLast(sym, ctrl, shift, alt, meta, unicode) handled = true end + if not isup and self.atLast then self.atLast(sym, ctrl, shift, alt, meta, unicode, key) handled = true end return handled end diff --git a/game/engines/default/engine/Map.lua b/game/engines/default/engine/Map.lua index a83ae392eec2a840d2f40779e48166e9e4cf29d3..87382cbaf57a49fc71d38b41b5ce9dbd054732a2 100644 --- a/game/engines/default/engine/Map.lua +++ b/game/engines/default/engine/Map.lua @@ -1020,11 +1020,15 @@ function _M:displayParticles(nb_keyframes) adx, ady = 0, 0 if e.x and e.y then -- Make sure we display on the real screen coords: handle current move anim position - if e._mo then - adx, ady = e._mo:getMoveAnim(self._map, e.x, e.y) + local _mo = e._mo + if not _mo then + _mo = self.map[e.x + e.y * self.w] and self.map[e.x + e.y * self.w][TERRAIN] and self.map[e.x + e.y * self.w][TERRAIN]._mo + end + if _mo then + adx, ady = _mo:getMoveAnim(self._map, e.x, e.y) else adx, ady = self._map:getScroll() - adx, ady = adx / self.tile_w, ady / self.tile_h + adx, ady = -adx / self.tile_w, -ady / self.tile_h end end diff --git a/game/engines/default/engine/interface/PlayerMouse.lua b/game/engines/default/engine/interface/PlayerMouse.lua index 426519d9abac4a502e5f152a2a0d0165ecc936a1..5f994bac297a6eac1c2e3c7bba8573894b91d459 100644 --- a/game/engines/default/engine/interface/PlayerMouse.lua +++ b/game/engines/default/engine/interface/PlayerMouse.lua @@ -138,7 +138,7 @@ function _M:mouseHandleDefault(key, allow_move, button, mx, my, xrel, yrel, even -- game.level.map:setZoom(-0.1, tmx, tmy) -- Pass any other buttons to the keybinder elseif button ~= "none" and not xrel and not yrel and event == "button" then - key:receiveKey(button, core.key.modState("ctrl") and true or false, core.key.modState("shift") and true or false, core.key.modState("alt") and true or false, core.key.modState("meta") and true or false, nil, false, true) + key:receiveKey(button, core.key.modState("ctrl") and true or false, core.key.modState("shift") and true or false, core.key.modState("alt") and true or false, core.key.modState("meta") and true or false, nil, false, nil, true) end if not xrel and not yrel then moving_around = false end diff --git a/game/modules/tome/data/maps/zones/tannen-tower-1.lua b/game/modules/tome/data/maps/zones/tannen-tower-1.lua index 5a45c59a70d47a8e96428a5135e97832378c2ceb..e9a073b533734993cd77eee2f3e7f540eba43a4a 100644 --- a/game/modules/tome/data/maps/zones/tannen-tower-1.lua +++ b/game/modules/tome/data/maps/zones/tannen-tower-1.lua @@ -22,7 +22,6 @@ defineTile("g", "FLOOR", nil, "DROLEM") defineTile("X", "HARDWALL") quickEntity('=', {name='open sky', display=' ', does_block_move=true}) defineTile("p", "FLOOR", nil, "TANNEN") -defineTile(">", "DOWN") defineTile(".", "FLOOR") -- addSpot section diff --git a/game/modules/tome/data/maps/zones/tannen-tower-2.lua b/game/modules/tome/data/maps/zones/tannen-tower-2.lua index f93497bd4f100f84fb9d9b9eb28b5ea86915387d..f6a7305c437c92fecabb843be023802c49bf1120 100644 --- a/game/modules/tome/data/maps/zones/tannen-tower-2.lua +++ b/game/modules/tome/data/maps/zones/tannen-tower-2.lua @@ -25,8 +25,8 @@ endy = 12 -- defineTile section defineTile("X", "HARDWALL") defineTile("+", "DOOR") -defineTile("<", "UP") -defineTile(">", "DOWN") +defineTile("<", "TUP") +defineTile(">", "TDOWN") defineTile(".", "FLOOR") -- addSpot section diff --git a/game/modules/tome/data/maps/zones/tannen-tower-3.lua b/game/modules/tome/data/maps/zones/tannen-tower-3.lua index 02a3af37ca432f8b263a3c61f61aa390df08dbf8..bd0a82d74e81efbb0189358c5a88c96c4e43be44 100644 --- a/game/modules/tome/data/maps/zones/tannen-tower-3.lua +++ b/game/modules/tome/data/maps/zones/tannen-tower-3.lua @@ -25,8 +25,8 @@ endy = 4 -- defineTile section defineTile("X", "HARDWALL") defineTile("~", "DEEP_WATER") -defineTile("<", "UP") -defineTile(">", "DOWN") +defineTile("<", "TUP") +defineTile(">", "TDOWN") defineTile(".", "FLOOR") -- addSpot section diff --git a/game/modules/tome/data/maps/zones/tannen-tower-4.lua b/game/modules/tome/data/maps/zones/tannen-tower-4.lua index 8860ca46136843000a8505bc13b748e6bae4821c..793910b3ddc2489832cc874b3e6aa5d07985414a 100644 --- a/game/modules/tome/data/maps/zones/tannen-tower-4.lua +++ b/game/modules/tome/data/maps/zones/tannen-tower-4.lua @@ -30,41 +30,16 @@ defineTile("E", "GRASS", nil, {random_filter={type="elemental"}}) defineTile("$", "FLOOR", nil, {random_filter={type="undead", subtype="giant"}}) defineTile("X", "HARDWALL") defineTile("~", "FLOOR") -defineTile("*", "SEALED_DOOR") +defineTile('*', "GENERIC_LEVER_DOOR", nil, nil, nil, {lever_action=4, lever_action_value=0, lever_action_kind="doors"}, {type="lever", subtype="door"}) +defineTile('&', "GENERIC_LEVER", nil, nil, nil, {lever=1, lever_kind="doors", lever_radius=50}) defineTile("+", "DOOR") -defineTile("<", "UP") +defineTile("<", "TUP") defineTile(",", "GRASS") defineTile(".", "FLOOR") defineTile(" ", "OLD_FLOOR") defineTile("!", "WALL") defineTile("T", "TREE") -addData{post_process = function(level) - level.nb_to_open = 0 - level.open_doors = function() - local doors = {{11,12},{12,11},{13,12},{12,13}} - local g = game.zone:makeEntityByName(game.level, "terrain", "SEALED_DOOR_CRACKED") - for i, d in ipairs(doors) do game.zone:addEntity(game.level, g, "terrain", d[1], d[2]) end - game.logPlayer(game.player, "#VIOLET#There is a loud crack coming from the center of the level.") - end - - -- Need to kill them all - for uid, a in pairs(level.entities) do - if a.faction and game.player:reactionToward(a) < 0 then - a.old_on_die = a.on_die - a.on_die = function(self, who) - local nb = 0 - for uid, a in pairs(game.level.entities) do - local ga = game.level.map(a.x, a.y, engine.Map.ACTOR) - if a.faction and game.player:reactionToward(a) < 0 and ga and ga == a and not a.dead then nb = nb + 1 end - end - if nb <= 0 then game.level.open_doors() end - self:check("old_on_die") - end - end - end -end} - -- ASCII map section return [[ XXXXXXXXXXXXXXXXXXXXXXXXX @@ -76,17 +51,17 @@ XXX..XXX# #X.XU!~!XX..XXX XXX.XX### #X.X!~!U!XX.XXX XX..X## #X.X~!U!~!X..XX XX.XX# #X.X!~!~!UXX.XX -XX.XX# " #X.XU!~!U!~X.XX -X..XX######X.X!U!~!~!X..X +XX.XX# &" #X.XU!~!U!~X.XX +X..XX######X.X&U!~!~!X..X X+XXXXXXXXXX*XXXXXXXXXX+X X.+........*<*........+.X X+XXXXXXXXXX*XXX+XXXXXX+X -X..XX......X.XX,,,XXXX..X +X..XX.....&X.XX,,,XXXX..X XX.XX......X.XEE,EEXXX.XX XX.XX......X.XEETEEXXX.XX XX..X....$$X.XEE,EEXX..XX XXX.XXXXXX+X.XX,,,XXX.XXX -XXX..XX.$..X.XXXXXXX..XXX +XXX..XX.$..X.XXX&XXX..XXX XXXX..X+XXXX.XXXXXX..XXXX XXXXX...XXXX.XXXX...XXXXX XXXXXXX....X+X....XXXXXXX diff --git a/game/modules/tome/data/zones/tannen-tower/grids.lua b/game/modules/tome/data/zones/tannen-tower/grids.lua index e49d12fcc6b8b9a6b05bc6acdf65c7a7de453798..169a7cad3f56a2be903506e17e4ad08977829283 100644 --- a/game/modules/tome/data/zones/tannen-tower/grids.lua +++ b/game/modules/tome/data/zones/tannen-tower/grids.lua @@ -23,28 +23,10 @@ load("/data/general/grids/water.lua") load("/data/general/grids/lava.lua") load("/data/general/grids/mountain.lua") -newEntity{ - define_as = "SEALED_DOOR", - name = "sealed door", image = "terrain/sealed_door.png", - display = '+', color=colors.WHITE, back_color=colors.DARK_UMBER, - notice = true, - always_remember = true, - block_sight = true, - does_block_move = true, -} - -newEntity{ - define_as = "SEALED_DOOR_CRACKED", - name = "destroyed sealed door", image = "terrain/sealed_door_cracked.png", - display = '_', color=colors.WHITE, back_color=colors.DARK_UMBER, - notice = true, - always_remember = true, -} - newEntity{ define_as = "PORTAL_BACK", name = "Portal to Last Hope", - display = '&', color_r=255, color_g=0, color_b=220, back_color=colors.VIOLET, + display = '&', color_r=255, color_g=0, color_b=220, back_color=colors.VIOLET, image = "terrain/marble_floor.png", add_mos = {{image="terrain/demon_portal.png"}}, notice = true, always_remember = true, show_tooltip = true, @@ -62,20 +44,11 @@ newEntity{ } -- Reversed! -newEntity{ - define_as = "UP", - name = "previous level", - display = '<', color_r=255, color_g=255, color_b=0, - notice = true, - always_remember = true, +newEntity{ base = "UP", + define_as = "TUP", change_level = 1, } - -newEntity{ - define_as = "DOWN", - name = "next level", - display = '>', color_r=255, color_g=255, color_b=0, - notice = true, - always_remember = true, +newEntity{ base = "DOWN", + define_as = "TDOWN", change_level = -1, } diff --git a/src/main.c b/src/main.c index 08a2c33007902498eb522f7e656f230f88646a31..1871d2ff2cacb09caf6fd65930ea9a802f451557 100644 --- a/src/main.c +++ b/src/main.c @@ -269,7 +269,35 @@ void on_event(SDL_Event *event) else lua_pushnil(L); lua_pushboolean(L, (event->type == SDL_KEYUP) ? TRUE : FALSE); - docall(L, 8, 0); + + /* Convert unicode UCS-2 to UTF8 string */ + if (event->key.keysym.sym) + { + wchar_t wc = event->key.keysym.sym; + + char buf[4] = {0,0,0,0}; + if (wc < 0x80) + { + buf[0] = wc; + } + else if (wc < 0x800) + { + buf[0] = (0xC0 | wc>>6); + buf[1] = (0x80 | wc & 0x3F); + } + else + { + buf[0] = (0xE0 | wc>>12); + buf[1] = (0x80 | wc>>6 & 0x3F); + buf[2] = (0x80 | wc & 0x3F); + } + + lua_pushstring(L, buf); + } + else + lua_pushnil(L); + + docall(L, 9, 0); } break; case SDL_MOUSEBUTTONDOWN: