Skip to content
Snippets Groups Projects
Commit c4b8f54e authored by Alex Ksandra's avatar Alex Ksandra
Browse files

Fixed NPC list not working and multitude of hotkeys display problems.

parent ba9e561a
No related branches found
No related tags found
No related merge requests found
......@@ -39,27 +39,22 @@ function _M:init(actor, x, y, w, h, bgcolor, fontname, fontsize, icon_w, icon_h)
self.dragclics = {}
self.clics = {}
self.items = {}
self.cache = {}
setmetatable(self.cache, {__mode="v"})
self.icon_w, self.icon_h = icon_w, icon_h
self.tiles = Tiles.new(icon_w, icon_h, fontname or "/data/font/DroidSansMono.ttf", fontsize or 10, true, true)
self.tiles.use_images = true
self.tiles.force_back_color = {r=0, g=0, b=0}
local fw, fh = core.display.loadImage("/data/gfx/ui/talent_frame_ok.png"):getSize()
self.frames = {w=math.floor(fw * icon_w / 64), h=math.floor(fh * icon_h / 64), rw=icon_w / 64, rh=icon_h / 64}
self.frames.fx = math.floor((self.frames.w - icon_w) / 2)
self.frames.fy = math.floor((self.frames.h - icon_h) / 2)
self.fontname = fontname
self.fontsize = fontsize
--local fw, fh = core.display.loadImage("/data/gfx/ui/talent_frame_ok.png"):getSize()
--self.frames = {w=math.floor(fw * icon_w / 64), h=math.floor(fh * icon_h / 64), rw=icon_w / 64, rh=icon_h / 64}
self.frames = {}
-- self.frames.ok = { core.display.loadImage("/data/gfx/ui/talent_frame_ok.png"):glTexture() }
-- self.frames.disabled = { core.display.loadImage("/data/gfx/ui/talent_frame_disabled.png"):glTexture() }
-- self.frames.cooldown = { core.display.loadImage("/data/gfx/ui/talent_frame_cooldown.png"):glTexture() }
-- self.frames.sustain = { core.display.loadImage("/data/gfx/ui/talent_frame_sustain.png"):glTexture() }
self.frames.base = UI:makeFrame("ui/icon-frame/frame", self.frames.w, self.frames.h)
self.frames.base = UI:makeFrame("ui/icon-frame/frame", icon_w + 8, icon_h + 8) --doesn't really matter since we pass a different size
self.default_entity = Entity.new{display='?', color=colors.WHITE}
self:resize(x, y, w, h)
self:resize(x, y, w, h, icon_w, icon_h)
end
--- Sets the display into nb columns
......@@ -71,13 +66,25 @@ function _M:enableShadow(v)
end
--- Resize the display area
function _M:resize(x, y, w, h)
function _M:resize(x, y, w, h, iw, ih)
self.display_x, self.display_y = math.floor(x), math.floor(y)
self.w, self.h = math.floor(w), math.floor(h)
self.surface = core.display.newSurface(w, h)
self.texture, self.texture_w, self.texture_h = self.surface:glTexture()
if self.actor then self.actor.changed = true end
if iw and ih and (self.icon_w ~= iw or self.icon_h ~= ih) then
self.icon_w = iw
self.icon_h = ih
self.frames.w = iw + 8
self.frames.fx = 4
self.frames.h = ih + 8
self.frames.fy = 4
self.tiles = Tiles.new(iw, ih, self.fontname or "/data/font/DroidSansMono.ttf", self.fontsize or 10, true, true)
self.tiles.use_images = true
self.tiles.force_back_color = {r=0, g=0, b=0}
end
self.max_cols = math.floor(self.w / self.frames.w)
self.max_rows = math.floor(self.h / self.frames.h)
......@@ -123,7 +130,7 @@ function _M:display()
self.dragclics = {}
self.clics = {}
self.items = {}
local w, h = self.icon_w, self.icon_h
local w, h = self.frames.w, self.frames.h
for page = bpage, #page_to_hotkey do for i = 1, 12 do
local ts = nil
......@@ -222,7 +229,7 @@ function _M:display()
self.items[#self.items+1] = {i=i, x=x, y=y, e=display_entity or self.default_entity, color=color, angle=angle, key=key, gtxt=gtxt, frame=frame, pagesel=lpage==spage}
self.clics[i] = {x,y,w,h}
else
local i = i + (12 * (page - bpage))
local i = i + (12 * (page - 1))
local angle = 0
local color = {190,190,190}
local frame = "disabled"
......@@ -260,7 +267,7 @@ function _M:toScreen()
if self.bg_texture then self.bg_texture:toScreenFull(self.display_x, self.display_y, self.w, self.h, self.bg_texture_w, self.bg_texture_h) end
for i = 1, #self.items do
local item = self.items[i]
if not item.show_on_drag or (game.mouse and game.mouse.drag and self.cur_sel) then
if not item.show_on_drag or (game.mouse and game.mouse.drag) and self.cur_sel then
local key = item.key
local gtxt = item.gtxt
local frame = frames_colors[item.frame]
......@@ -274,7 +281,7 @@ function _M:toScreen()
-- frame[1]:toScreenFull(self.display_x + item.x, self.display_y + item.y, self.frames.w, self.frames.h, frame[2] * self.frames.rw, frame[3] * self.frames.rh, pagesel, pagesel, pagesel, 255)
-- frame[1]:toScreenFull(self.display_x + item.x, self.display_y + item.y, self.frames.w, self.frames.h, frame[2] * self.frames.rw, frame[3] * self.frames.rh, pagesel, pagesel, pagesel, 255)
UI:drawFrame(self.frames.base, self.display_x + item.x, self.display_y + item.y, frame[1], frame[2], frame[3], 1)
UI:drawFrame(self.frames.base, self.display_x + item.x, self.display_y + item.y, frame[1], frame[2], frame[3], 1, self.frames.w, self.frames.h)
if self.shadow then
if shader then
......@@ -364,8 +371,6 @@ function _M:onMouse(button, mx, my, click, on_over, on_click)
a.changed = true
else
a.changed = true
local oldsel = self.cur_sel
self.cur_sel = i
if on_over and self.cur_sel ~= oldsel and not zone.fake then
local text = ""
if a.hotkey[i] and a.hotkey[i][1] == "talent" then
......@@ -381,6 +386,8 @@ function _M:onMouse(button, mx, my, click, on_over, on_click)
on_over(text)
end
end
local oldsel = self.cur_sel
self.cur_sel = i
return
end
end
......
......@@ -625,7 +625,7 @@ function _M:resizeMapViewport(w, h, x, y)
h = math.floor(h)
-- convert from older faulty versionsPg
if game.level.map and rawget(game.level.map, "display_x") == Map.display.x and rawget(game.level.map, "display_y") == Map.display_y then
if game.level.map and rawget(game.level.map, "display_x") == Map.display_x and rawget(game.level.map, "display_y") == Map.display_y then
game.level.map.display_x, game.level.map.display_y = nil, nil
end
Map.display_x = x
......@@ -1939,6 +1939,7 @@ do return end
else
self.log("Displaying talents.")
end
if self.uiset.resizeIconsHotkeysToolbar then self.uiset:resizeIconsHotkeysToolbar() end
end,
SCREENSHOT = function() self:saveScreenshot() end,
......
......@@ -59,7 +59,8 @@ function _M:activate()
self.init_size_mono = size_mono
self.init_font_mono_h = font_mono_h
self.hotkeys_display_text = HotkeysDisplay.new(nil, 216, game.h - 52, game.w - 216, 52, "/data/gfx/ui/talents-list.png", font_mono, size_mono)
local text_display_h = font_mono_h * 4.2
self.hotkeys_display_text = HotkeysDisplay.new(nil, 216, game.h - text_display_h, game.w - 216, text_display_h, "/data/gfx/ui/talents-list.png", font_mono, size_mono)
self.hotkeys_display_text:enableShadow(0.6)
self.hotkeys_display_text:setColumns(3)
self:resizeIconsHotkeysToolbar()
......@@ -76,7 +77,7 @@ function _M:activate()
profile.chat:enableFading(config.settings.tome.log_fade or 3)
profile.chat:enableDisplayChans(false)
self.npcs_display = ActorsSeenDisplay.new(nil, 216, game.h - font_mono_h * 4.2, game.w - 216, font_mono_h * 4.2, "/data/gfx/ui/talents-list.png", font_mono, size_mono)
self.npcs_display = ActorsSeenDisplay.new(nil, 216, game.h - text_display_h, game.w - 216, text_display_h, "/data/gfx/ui/talents-list.png", font_mono, size_mono)
self.npcs_display:setColumns(3)
self.minimap_bg, self.minimap_bg_w, self.minimap_bg_h = core.display.loadImage("/data/gfx/ui/minimap.png"):glTexture()
......@@ -99,21 +100,31 @@ function _M:setupMinimap(level)
end
function _M:resizeIconsHotkeysToolbar()
local h = 52
if config.settings.tome.hotkey_icons then h = (4 + config.settings.tome.hotkey_icons_size) * config.settings.tome.hotkey_icons_rows end
local h
if game.show_npc_list then
h = self.npcs_display.h
else
if config.settings.tome.hotkey_icons then h = (8 + config.settings.tome.hotkey_icons_size) * config.settings.tome.hotkey_icons_rows
else h = self.hotkeys_display_text.h end
end
local oldstop = self.map_h_stop or (game.h - h)
self.map_h_stop = game.h - h
self.map_h_stop_tooltip = game.h - h
self.hotkeys_display_icons = HotkeysIconsDisplay.new(nil, 216, game.h - h, game.w - 216, h, "/data/gfx/ui/talents-list.png", self.init_font_mono, self.init_size_mono, config.settings.tome.hotkey_icons_size, config.settings.tome.hotkey_icons_size)
self.hotkeys_display_icons:enableShadow(0.6)
if self.hotkeys_display_icons then
self.hotkeys_display_icons:resize(216, game.h - h, game.w - 216, h, config.settings.tome.hotkey_icons_size, config.settings.tome.hotkey_icons_size)
else
self.hotkeys_display_icons = HotkeysIconsDisplay.new(nil, 216, game.h - h, game.w - 216, h, "/data/gfx/ui/talents-list.png", self.init_font_mono, self.init_size_mono, config.settings.tome.hotkey_icons_size, config.settings.tome.hotkey_icons_size)
self.hotkeys_display_icons:enableShadow(0.6)
end
if game.inited then
game:resizeMapViewport(game.w - 216, self.map_h_stop - 16, 216, 0)
self.logdisplay.display_y = self.logdisplay.display_y + self.map_h_stop - oldstop
profile.chat.display_y = profile.chat.display_y + self.map_h_stop - oldstop
game:setupMouse()
game:setupMouse(true)
end
self.hotkeys_display = config.settings.tome.hotkey_icons and self.hotkeys_display_icons or self.hotkeys_display_text
......@@ -160,7 +171,7 @@ function _M:displayUI()
-- Icons
local x, y = icon_x, icon_y
if (not self.show_npc_list) then
if (not game.show_npc_list) then
_talents_icon:toScreenFull(x, y, _talents_icon_w, _talents_icon_h, _talents_icon_w, _talents_icon_h)
else
_actors_icon:toScreenFull(x, y, _actors_icon_w, _actors_icon_h, _actors_icon_w, _actors_icon_h)
......@@ -196,7 +207,7 @@ function _M:displayUI()
x = x + _talents_icon_w
_log_icon:toScreenFull(x, y, _log_icon_w, _log_icon_h, _log_icon_w, _log_icon_h)
x = x + _talents_icon_w
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
if (not config.settings.tome.actor_based_movement_mode and not game.bump_attack_disabled) or (config.settings.tome.actor_based_movement_mode and not game.player.bump_attack_disabled) then
_mm_aggressive_icon:toScreenFull(x, y, _mm_aggressive_icon_w, _mm_aggressive_icon_h, _mm_aggressive_icon_w, _mm_aggressive_icon_h)
else
_mm_passive_icon:toScreenFull(x, y, _mm_passive_icon_w, _mm_passive_icon_h, _mm_passive_icon_w, _mm_passive_icon_h)
......@@ -263,7 +274,7 @@ function _M:mouseIcon(bx, by)
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 self.show_npc_list) then
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#")
......@@ -347,7 +358,7 @@ function _M:display(nb_keyframes)
self.logdisplay:toScreen()
self.player_display:toScreen(nb_keyframes)
if self.show_npc_list then
if game.show_npc_list then
self.npcs_display:toScreen()
else
self.hotkeys_display:toScreen()
......@@ -364,7 +375,7 @@ function _M:setupMouse(mouse)
end)
-- Use hotkeys with mouse
mouse:registerZone(self.hotkeys_display.display_x, self.hotkeys_display.display_y, game.w, game.h, function(button, mx, my, xrel, yrel, bx, by, event)
if self.show_npc_list then return end
if game.show_npc_list then return end
if event == "out" then self.hotkeys_display.cur_sel = nil return end
if event == "button" and button == "left" and ((game.zone and game.zone.wilderness) or (game.key ~= game.normal_key)) then return end
self.hotkeys_display:onMouse(button, mx, my, event == "button",
......
......@@ -266,7 +266,7 @@ function _M:resetPlaces()
local w, h = core.display.size()
local th = 52
if config.settings.tome.hotkey_icons then th = (4 + config.settings.tome.hotkey_icons_size) * config.settings.tome.hotkey_icons_rows end
if config.settings.tome.hotkey_icons then th = (8 + config.settings.tome.hotkey_icons_size) * config.settings.tome.hotkey_icons_rows end
local hup = h - th
self.places = {
......@@ -399,15 +399,19 @@ end
function _M:resizeIconsHotkeysToolbar()
local h = 52
if config.settings.tome.hotkey_icons then h = (4 + config.settings.tome.hotkey_icons_size) * config.settings.tome.hotkey_icons_rows end
if config.settings.tome.hotkey_icons then h = (8 + config.settings.tome.hotkey_icons_size) * config.settings.tome.hotkey_icons_rows end
local oldstop = self.map_h_stop_up or (game.h - h)
self.map_h_stop = game.h
self.map_h_stop_up = game.h - h
self.map_h_stop_tooltip = self.map_h_stop_up
self.hotkeys_display_icons = HotkeysIconsDisplay.new(nil, self.places.hotkeys.x, self.places.hotkeys.y, self.places.hotkeys.w, self.places.hotkeys.h, nil, self.init_font_mono, self.init_size_mono, config.settings.tome.hotkey_icons_size, config.settings.tome.hotkey_icons_size)
self.hotkeys_display_icons:enableShadow(0.6)
if not self.hotkeys_display_icons then
self.hotkeys_display_icons = HotkeysIconsDisplay.new(nil, self.places.hotkeys.x, self.places.hotkeys.y, self.places.hotkeys.w, self.places.hotkeys.h, nil, self.init_font_mono, self.init_size_mono, config.settings.tome.hotkey_icons_size, config.settings.tome.hotkey_icons_size)
self.hotkeys_display_icons:enableShadow(0.6)
else
self.hotkeys_display_icons:resize(self.places.hotkeys.x, self.places.hotkeys.y, self.places.hotkeys.w, self.places.hotkeys.h, config.settings.tome.hotkey_icons_size, config.settings.tome.hotkey_icons_size)
end
if self.no_ui then
self.map_h_stop = game.h
......
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