Skip to content
Snippets Groups Projects
Commit 3d96ab12 authored by DarkGod's avatar DarkGod
Browse files

Classic UI can now cancel buffs by right-click

parent 0289b858
No related branches found
No related tags found
No related merge requests found
......@@ -157,6 +157,7 @@ local _sep_left = {core.display.loadImage("/data/gfx/ui/separator-left.png")} _s
local _sep_leftl = {core.display.loadImage("/data/gfx/ui/separator-left_line_end.png")} _sep_leftl.tex = {_sep_leftl[1]:glTexture()}
local _sep_rightl = {core.display.loadImage("/data/gfx/ui/separator-right_line_end.png")} _sep_rightl.tex = {_sep_rightl[1]:glTexture()}
local _coin_icon, _coin_icon_w, _coin_icon_h = core.display.loadImage("/data/gfx/ui/playerframe/mtx_coin_button_framed.png"):glTexture()
local _log_icon, _log_icon_w, _log_icon_h = core.display.loadImage("/data/gfx/ui/log-icon.png"):glTexture()
local _chat_icon, _chat_icon_w, _chat_icon_h = core.display.loadImage("/data/gfx/ui/chat-icon.png"):glTexture()
local _talents_icon, _talents_icon_w, _talents_icon_h = core.display.loadImage("/data/gfx/ui/talents-icon.png"):glTexture()
......@@ -199,6 +200,7 @@ function _M:displayUI()
else
_mm_passive_icon:toScreenFull(x, y, _mm_passive_icon_w, _mm_passive_icon_h, _mm_passive_icon_w, _mm_passive_icon_h)
end
_coin_icon:toScreenFull(icon_x, icon_y - _inventory_icon_h, _coin_icon_w, _coin_icon_h, _coin_icon_w, _coin_icon_h)
-- Separators
_sep_horiz.tex[1]:toScreenFull(map_left + 16, self.map_h_stop - _sep_horiz[3], game.w - map_left - 16, _sep_horiz[3], _sep_horiz.tex[2], _sep_horiz.tex[3])
......@@ -216,7 +218,7 @@ end
function _M:createSeparators()
local icon_x = 0
local icon_y = game.h - (_talents_icon_h * 1)
local icon_y = game.h - (_talents_icon_h * 2)
self.icons = {
display_x = icon_x,
display_y = icon_y,
......@@ -226,70 +228,89 @@ function _M:createSeparators()
end
function _M:clickIcon(bx, by)
if bx < _talents_icon_w then
game.key:triggerVirtual("TOGGLE_NPC_LIST")
elseif bx < 2*_talents_icon_w then
game.key:triggerVirtual("SHOW_INVENTORY")
elseif bx < 3*_talents_icon_w then
game.key:triggerVirtual("SHOW_CHARACTER_SHEET")
elseif bx < 4*_talents_icon_w then
game.key:triggerVirtual("EXIT")
elseif bx < 5*_talents_icon_w then
game.key:triggerVirtual("SHOW_MESSAGE_LOG")
elseif bx < 6*_talents_icon_w then
game.key:triggerVirtual("TOGGLE_BUMP_ATTACK")
if by >= _talents_icon_h then
if bx < _talents_icon_w then
game.key:triggerVirtual("TOGGLE_NPC_LIST")
elseif bx < 2*_talents_icon_w then
game.key:triggerVirtual("SHOW_INVENTORY")
elseif bx < 3*_talents_icon_w then
game.key:triggerVirtual("SHOW_CHARACTER_SHEET")
elseif bx < 4*_talents_icon_w then
game.key:triggerVirtual("EXIT")
elseif bx < 5*_talents_icon_w then
game.key:triggerVirtual("SHOW_MESSAGE_LOG")
elseif bx < 6*_talents_icon_w then
game.key:triggerVirtual("TOGGLE_BUMP_ATTACK")
end
else
if bx < _talents_icon_w then
package.loaded["engine.dialogs.microtxn.MTXMain"] = nil
game:registerDialog(require("engine.dialogs.microtxn.MTXMain").new())
end
end
end
function _M:mouseIcon(bx, by)
local virtual
local key
if bx < _talents_icon_w then
virtual = "TOGGLE_NPC_LIST"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (not game.show_npc_list) then
game:tooltipDisplayAtMap(game.w, game.h, "Displaying talents (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for creature display")
else
game:tooltipDisplayAtMap(game.w, game.h, "Displaying creatures (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for talent display#")
end
elseif bx < 2*_talents_icon_w then
virtual = "SHOW_INVENTORY"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (key == "I") then
game:tooltipDisplayAtMap(game.w, game.h, "#{bold}##GOLD#I#LAST##{normal}#nventory")
else
game:tooltipDisplayAtMap(game.w, game.h, "Inventory (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
end
elseif bx < 3*_talents_icon_w then
virtual = "SHOW_CHARACTER_SHEET"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (key == "C") then
game:tooltipDisplayAtMap(game.w, game.h, "#{bold}##GOLD#C#LAST##{normal}#haracter Sheet")
else
game:tooltipDisplayAtMap(game.w, game.h, "Character Sheet (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
local virtual, virtual2
local key, key2
if by >= _talents_icon_h then
if bx < _talents_icon_w then
virtual = "TOGGLE_NPC_LIST"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (not game.show_npc_list) then
game:tooltipDisplayAtMap(game.w, game.h, "Displaying talents (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for creature display")
else
game:tooltipDisplayAtMap(game.w, game.h, "Displaying creatures (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for talent display#")
end
elseif bx < 2*_talents_icon_w then
virtual = "SHOW_INVENTORY"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (key == "I") then
game:tooltipDisplayAtMap(game.w, game.h, "#{bold}##GOLD#I#LAST##{normal}#nventory")
else
game:tooltipDisplayAtMap(game.w, game.h, "Inventory (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
end
elseif bx < 3*_talents_icon_w then
virtual = "SHOW_CHARACTER_SHEET"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (key == "C") then
game:tooltipDisplayAtMap(game.w, game.h, "#{bold}##GOLD#C#LAST##{normal}#haracter Sheet")
else
game:tooltipDisplayAtMap(game.w, game.h, "Character Sheet (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
end
elseif bx < 4*_talents_icon_w then
virtual = "EXIT"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
game:tooltipDisplayAtMap(game.w, game.h, "Main menu (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
elseif bx < 5*_talents_icon_w then
virtual = "SHOW_MESSAGE_LOG"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
game:tooltipDisplayAtMap(game.w, game.h, "Show message/chat log (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
elseif bx < 6*_talents_icon_w then
virtual = "TOGGLE_BUMP_ATTACK"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (not config.settings.tome.actor_based_movement_mode and not self.bump_attack_disabled) or (config.settings.tome.actor_based_movement_mode and not game.player.bump_attack_disabled) then
game:tooltipDisplayAtMap(game.w, game.h, "Movement: #LIGHT_GREEN#Default#LAST# (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for passive mode")
else
game:tooltipDisplayAtMap(game.w, game.h, "Movement: #LIGHT_RED#Passive#LAST# (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for default mode")
end
end
elseif bx < 4*_talents_icon_w then
virtual = "EXIT"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
game:tooltipDisplayAtMap(game.w, game.h, "Main menu (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
elseif bx < 5*_talents_icon_w then
virtual = "SHOW_MESSAGE_LOG"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
game:tooltipDisplayAtMap(game.w, game.h, "Show message/chat log (#{bold}##GOLD#"..key.."#LAST##{normal}#)")
elseif bx < 6*_talents_icon_w then
virtual = "TOGGLE_BUMP_ATTACK"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
if (not config.settings.tome.actor_based_movement_mode and not self.bump_attack_disabled) or (config.settings.tome.actor_based_movement_mode and not game.player.bump_attack_disabled) then
game:tooltipDisplayAtMap(game.w, game.h, "Movement: #LIGHT_GREEN#Default#LAST# (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for passive mode")
else
game:tooltipDisplayAtMap(game.w, game.h, "Movement: #LIGHT_RED#Passive#LAST# (#{bold}##GOLD#"..key.."#LAST##{normal}#)\nToggle for default mode")
else
if bx < _talents_icon_w then
virtual = "MTXN_PURCHASE"
key = game.key.binds_remap[virtual] ~= nil and game.key.binds_remap[virtual][1] or game.key:findBoundKeys(virtual)
key = (key ~= nil and game.key:formatKeyString(key) or "unbound"):capitalize()
virtual2 = "MTXN_USE"
key2 = game.key.binds_remap[virtual2] ~= nil and game.key.binds_remap[virtual2][1] or game.key:findBoundKeys(virtual2)
key2 = (key2 ~= nil and game.key:formatKeyString(key2) or "unbound"):capitalize()
game:tooltipDisplayAtMap(game.w, game.h, "Cosmetics & Events shop (#{bold}##GOLD#"..key.."#LAST##{normal}#, #{bold}##GOLD#"..key2.."#LAST##{normal}#)")
end
end
end
......
......@@ -19,6 +19,7 @@
require "engine.class"
local Mouse = require "engine.Mouse"
local Dialog = require "engine.ui.Dialog"
local Button = require "engine.ui.Button"
local ActorResource = require "engine.interface.ActorResource"
local TooltipsData = require "mod.class.interface.TooltipsData"
......@@ -69,8 +70,8 @@ end
function _M:mouseTooltip(text, w, h, x, y, click)
self.mouse:registerZone(x, y, w, h, function(button, mx, my, xrel, yrel, bx, by, event)
game.tooltip_x, game.tooltip_y = 1, 1; game:tooltipDisplayAtMap(game.w, game.h, text)
if click and event == "button" and button == "left" then
click()
if click and event == "button"then
click(button)
end
end)
end
......@@ -154,8 +155,8 @@ function _M:makePortrait(a, current, x, y)
self.items[#self.items+1] = {p, x=x, y=y}
end
function _M:makeEntityIcon(e, tiles, x, y, desc, gtxt, frame)
self:mouseTooltip(desc, 40, 40, x, y)
function _M:makeEntityIcon(e, tiles, x, y, desc, gtxt, frame, click)
self:mouseTooltip(desc, 40, 40, x, y, click)
local item = function(dx, dy)
e:toScreen(tiles, dx+x+4, dy+y+4, 32, 32)
......@@ -181,6 +182,14 @@ function _M:handleEffect(eff_id, e, p, ex, h)
desc = ("#{bold}##GOLD#%s\n(%s: %s)#WHITE##{normal}#\n"):format(name, e.type, eff_subtype)..e.long_desc(player, p)
end
local remove_fct = function(button) if button == "right" then
Dialog:yesnoPopup(name, "Really cancel "..name.."?", function(ret)
if ret then
player:removeEffect(eff_id)
end
end)
end end
if config.settings.tome.effects_icons and e.display_entity then
local txt = nil
if e.decrease > 0 then
......@@ -188,16 +197,19 @@ function _M:handleEffect(eff_id, e, p, ex, h)
txt = self.fontbig:draw(dur, 40, colors.WHITE.r, colors.WHITE.g, colors.WHITE.b, true)[1]
txt.fw, txt.fh = self.fontbig:size(dur)
end
self:makeEntityIcon(e.display_entity, game.uiset.hotkeys_display_icons.tiles, ex, h, desc, txt, e.status ~= "detrimental" and self.icon_green or self.icon_red)
self:makeEntityIcon(e.display_entity, game.uiset.hotkeys_display_icons.tiles, ex, h, desc, txt, e.status ~= "detrimental" and self.icon_green or self.icon_red, ((e.status == "beneficial" and not e.no_player_remove) or config.settings.cheat) and remove_fct or nil)
ex = ex + 40
if ex + 40 >= self.w then ex = 0 h = h + 40 end
else
ex = 0
if e.status == "detrimental" then
self:mouseTooltip(desc, self:makeTexture((e.decrease > 0) and ("#LIGHT_RED#%s(%d)"):format(name, dur) or ("#LIGHT_RED#%s"):format(name), ex, h, 255, 255, 255)) h = h + self.font_h
local _w, _h, _x, _y = self:makeTexture((e.decrease > 0) and ("#LIGHT_RED#%s(%d)"):format(name, dur) or ("#LIGHT_RED#%s"):format(name), ex, h, 255, 255, 255)
self:mouseTooltip(desc, _w, _h, _x, _y, config.settings.cheat and remove_fct or nil) h = h + self.font_h
else
self:mouseTooltip(desc, self:makeTexture((e.decrease > 0) and ("#LIGHT_GREEN#%s(%d)"):format(name, dur) or ("#LIGHT_GREEN#%s"):format(name), ex, h, 255, 255, 255)) h = h + self.font_h
local _w, _h, _x, _y = self:makeTexture((e.decrease > 0) and ("#LIGHT_GREEN#%s(%d)"):format(name, dur) or ("#LIGHT_GREEN#%s"):format(name), ex, h, 255, 255, 255)
self:mouseTooltip(desc, _w, _h, _x, _y, ((e.status == "beneficial" and not e.no_player_remove) or config.settings.cheat) and remove_fct or nil) h = h + self.font_h
end
end
return ex, h
......
game/modules/tome/data/gfx/ui/playerframe/mtx_coin_button_framed.png

7.18 KiB

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