From 1f171ec3dd67f8d6ceaf87475fc8be9d2d8ec3bb Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Mon, 15 Jul 2013 00:48:32 +0200 Subject: [PATCH] Added a slight outline to currently moused over item on the map --- game/modules/tome/class/Game.lua | 17 +++++++++- .../tome/data/gfx/shaders/objectsoutline.lua | 31 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 game/modules/tome/data/gfx/shaders/objectsoutline.lua diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 51a5cd90fe..c577ede715 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -1711,11 +1711,27 @@ end function _M:setupMouse(reset) if reset == nil or reset then self.mouse:reset() end + + local cur_obj = nil + local outline = Shader.new("objectsoutline").shad + self.mouse:registerZone(Map.display_x, Map.display_y, Map.viewport.width, Map.viewport.height, function(button, mx, my, xrel, yrel, bx, by, event, extra) if not self.uiset:isLocked() then return end + if core.shader.allow("adv") and outline then + local tmx, tmy = game.level.map:getMouseTile(mx, my) + local o = self.level.map(tmx, tmy, Map.OBJECT) + if cur_obj and cur_obj._mo then cur_obj._mo:shader(nil) end + if o and o._mo and not o.shader then + outline:paramNumber2("textSize", Map.tile_w, Map.tile_h) + o._mo:shader(outline) + cur_obj = o + end + end + self.tooltip.add_map_str = extra and extra.log_str + if game.tooltip.locked then if button == "wheelup" and event == "button" then game.tooltip.container.scrollbar.pos = util.minBound(game.tooltip.container.scrollbar.pos - 1, 0, game.tooltip.container.scrollbar.max) @@ -1742,7 +1758,6 @@ function _M:setupMouse(reset) -- Cheat kill if config.settings.cheat and button == "right" and core.key.modState("ctrl") and core.key.modState("shift") and not xrel and not yrel and event == "button" and self.zone and not self.zone.wilderness then - local tmx, tmy = game.level.map:getMouseTile(mx, my) local target = game.level.map(tmx, tmy, Map.ACTOR) if target then target:die(game.player) diff --git a/game/modules/tome/data/gfx/shaders/objectsoutline.lua b/game/modules/tome/data/gfx/shaders/objectsoutline.lua new file mode 100644 index 0000000000..4fc329d9ce --- /dev/null +++ b/game/modules/tome/data/gfx/shaders/objectsoutline.lua @@ -0,0 +1,31 @@ +-- ToME - Tales of Maj'Eyal +-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +return { + frag = "textoutline", + vert = nil, + args = { + tex = { texture = 0 }, + textSize = textSize or {1, 1}, + intensity = intensity or 0.3, + outlineSize = outlineSize or {2, 2}, + outlineColor = outlineColor or {0, 1, 0.5, 0.4}, + }, + clone = false, +} -- GitLab