From 3c954ed0caf42498b2f743f233473eca30205ee5 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Tue, 23 Aug 2011 15:49:36 +0000 Subject: [PATCH] Tannen level has correct tiles Permanent particle effects like farportal vortexes correctly scroll git-svn-id: http://svn.net-core.org/repos/t-engine4@4230 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/Key.lua | 3 +- game/engines/default/engine/KeyBind.lua | 6 +-- game/engines/default/engine/KeyCommand.lua | 6 +-- game/engines/default/engine/Map.lua | 10 +++-- .../default/engine/interface/PlayerMouse.lua | 2 +- .../tome/data/maps/zones/tannen-tower-1.lua | 1 - .../tome/data/maps/zones/tannen-tower-2.lua | 4 +- .../tome/data/maps/zones/tannen-tower-3.lua | 4 +- .../tome/data/maps/zones/tannen-tower-4.lua | 39 ++++--------------- .../tome/data/zones/tannen-tower/grids.lua | 37 +++--------------- src/main.c | 30 +++++++++++++- 11 files changed, 61 insertions(+), 81 deletions(-) diff --git a/game/engines/default/engine/Key.lua b/game/engines/default/engine/Key.lua index 439882025e..b16d096a7f 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 a306d9aee8..d1f3741456 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 096c0f7bb0..c0bf42814f 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 a83ae392ee..87382cbaf5 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 426519d9ab..5f994bac29 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 5a45c59a70..e9a073b533 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 f93497bd4f..f6a7305c43 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 02a3af37ca..bd0a82d74e 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 8860ca4613..793910b3dd 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 e49d12fcc6..169a7cad3f 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 08a2c33007..1871d2ff2c 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: -- GitLab