Commit f3564402dd56784ce184189dac9ebc8bd3f00f0f
Merge remote-tracking branch 'upstream/master' into misc174
Showing
39 changed files
with
95 additions
and
27 deletions
... | ... | @@ -165,6 +165,13 @@ function _M:makeFrame(base, w, h, iw, ih) |
165 | 165 | f.b5 = self:getUITexture(base.."5.png") |
166 | 166 | if not w then w = iw + f.b4.w + f.b6.w end |
167 | 167 | if not h then h = ih + f.b8.h + f.b2.h end |
168 | + if self.ui_conf[self.ui].specifics and self.ui_conf[self.ui].specifics[base] then | |
169 | + local conf = self.ui_conf[self.ui].specifics[base] | |
170 | + w = w + (conf.offset_w or 0) | |
171 | + h = h + (conf.offset_h or 0) | |
172 | + f.ox = conf.offset_x or 0 | |
173 | + f.oy = conf.offset_y or 0 | |
174 | + end | |
168 | 175 | end |
169 | 176 | f.w = math.floor(w) |
170 | 177 | f.h = math.floor(h) |
... | ... | @@ -179,8 +186,8 @@ function _M:drawFrame(f, x, y, r, g, b, a, w, h, total_w, total_h, loffset_x, lo |
179 | 186 | total_w = total_w or 0 |
180 | 187 | total_h = total_h or 0 |
181 | 188 | |
182 | - x = math.floor(x) | |
183 | - y = math.floor(y) | |
189 | + x = math.floor(x) + (f.ox or 0) | |
190 | + y = math.floor(y) + (f.oy or 0) | |
184 | 191 | |
185 | 192 | f.w = math.floor(w or f.w) |
186 | 193 | f.h = math.floor(h or f.h) | ... | ... |
... | ... | @@ -602,10 +602,16 @@ function _M:setupUI(resizex, resizey, on_resize, addmw, addmh) |
602 | 602 | mw = mw + self.frame.ox1 - self.frame.ox2 |
603 | 603 | end |
604 | 604 | |
605 | - if on_resize then on_resize(resizex and mw or self.w, resizey and mh or self.h) end | |
605 | + if on_resize then | |
606 | + local rw, rh = on_resize(resizex and mw or self.w, resizey and mh or self.h) | |
607 | + if rw and rh then resizex, resizey = true, true mw, mh = rw, rh end | |
608 | + end | |
606 | 609 | nw, nh = resizex and mw or self.w, resizey and mh or self.h |
607 | 610 | else |
608 | - if on_resize then on_resize(self.w, self.h) end | |
611 | + if on_resize then | |
612 | + local rw, rh = on_resize(self.w, self.h) | |
613 | + if rw and rh then self.w, self.h = rw, rh end | |
614 | + end | |
609 | 615 | nw, nh = self.w, self.h |
610 | 616 | end |
611 | 617 | ... | ... |
... | ... | @@ -2087,6 +2087,7 @@ function _M:setupCommands() |
2087 | 2087 | print("===============") |
2088 | 2088 | end end, |
2089 | 2089 | [{"_g","ctrl"}] = function() if config.settings.cheat then |
2090 | + package.loaded["engine.ui.Textzone"] = nil | |
2090 | 2091 | package.loaded["engine.ui.Dialog"] = nil |
2091 | 2092 | package.loaded["engine.dialogs.Chat"] = nil |
2092 | 2093 | package.loaded["mod.dialogs.Chat"] = nil |
... | ... | @@ -2094,7 +2095,7 @@ function _M:setupCommands() |
2094 | 2095 | package.loaded["engine.Chat"] = nil |
2095 | 2096 | local Chat = require "engine.Chat" |
2096 | 2097 | Chat.chat_dialog = "mod.dialogs.Chat" |
2097 | - local chat = Chat.new("tareyal+test", engine.Entity.new{name=_t"Imperium courrier", image="npc/undead_risen_mistress_vira.png"}, game.player) | |
2098 | + local chat = Chat.new("tareyal+test", engine.Entity.new{name=_t"Imperium courrier"}, game.player) | |
2098 | 2099 | chat:invoke() |
2099 | 2100 | do return end |
2100 | 2101 | DamageType:get(DamageType.ACID).projector(game.player, game.player.x, game.player.y, DamageType.ACID, 100) | ... | ... |
... | ... | @@ -109,6 +109,7 @@ function _M:relearningLore(v) |
109 | 109 | end |
110 | 110 | |
111 | 111 | function _M:learnLore(lore, nopopup, silent, nostop, after_learn_cb) |
112 | + print("[LORE] learning..", lore) | |
112 | 113 | local l = self:getLore(lore, silent) |
113 | 114 | if not l then return end |
114 | 115 | local learnt = false | ... | ... |
... | ... | @@ -17,13 +17,14 @@ |
17 | 17 | -- Nicolas Casalini "DarkGod" |
18 | 18 | -- darkgod@te4.org |
19 | 19 | |
20 | - | |
21 | - | |
22 | 20 | local Dialog = require "engine.ui.Dialog" |
23 | 21 | local DamageType = require "engine.DamageType" |
24 | 22 | local o = version |
25 | 23 | local src = game.player |
26 | 24 | |
25 | +-- If staff does not provide a portrait, use the talent | |
26 | +if not npc.has_command_staff_portrait then cur_chat.npc_force_display_entity = src:getTalentFromId(src.T_COMMAND_STAFF) end | |
27 | + | |
27 | 28 | if o.factory_settings then |
28 | 29 | print("Just started the chat, and we apparently have o.factory_settings.") |
29 | 30 | else | ... | ... |

25.7 KB

31.2 KB

25.7 KB

31.3 KB

31.8 KB

3.85 KB

36.3 KB

45.4 KB

18.9 KB

67.9 KB
... | ... | @@ -20,10 +20,16 @@ |
20 | 20 | chat = { |
21 | 21 | frame_alpha = 1, |
22 | 22 | frame_darkness = 0.6, |
23 | - frame_ox1 = -64, | |
24 | - frame_ox2 = 64, | |
23 | + frame_ox1 = -14, | |
24 | + frame_ox2 = 14, | |
25 | 25 | frame_oy1 = -5, |
26 | 26 | frame_oy2 = 10, |
27 | 27 | -- force_min_w = 64 * 4, |
28 | 28 | -- force_min_h = 64 * 4, |
29 | + specifics = { | |
30 | + ["ui/textbox"] = { | |
31 | + offset_w = -(64 - 30) * 2, | |
32 | + offset_x = 64 - 30, | |
33 | + }, | |
34 | + }, | |
29 | 35 | } | ... | ... |
... | ... | @@ -59,7 +59,7 @@ on_status_change = function(self, who, status, sub) |
59 | 59 | end |
60 | 60 | |
61 | 61 | local Chat = require"engine.Chat" |
62 | - local chat = Chat.new("sorcerer-end", {name=_t"Endgame"}, game:getPlayer(true)) | |
62 | + local chat = Chat.new("sorcerer-end", {name=_t"Endgame", image="portrait/win.png"}, game:getPlayer(true)) | |
63 | 63 | chat:invoke() |
64 | 64 | |
65 | 65 | self:end_end_combat() | ... | ... |
... | ... | @@ -181,7 +181,7 @@ newTalent{ |
181 | 181 | local Chat = require("engine.Chat") |
182 | 182 | local chat = Chat.new("command-staff", staff, self, {version=staff, state=state, co=coroutine.running()}) |
183 | 183 | local d = chat:invoke() |
184 | - if not coroutine.yield() then return nil end | |
184 | + self:talentDialog(d) | |
185 | 185 | return true |
186 | 186 | else -- NPC picks a new element |
187 | 187 | local element, aspect = staff:getStaffPreferredElement(self) | ... | ... |
... | ... | @@ -945,7 +945,7 @@ newTalent{ |
945 | 945 | end, |
946 | 946 | callbackOnTakeDamage = function(self, t, src, x, y, type, dam, state) |
947 | 947 | if self:isTalentCoolingDown(t) then return end |
948 | - if (self.life / self.max_life) >= 0.3 then return end | |
948 | + if ((self.life-dam) / self.max_life) > 0.3 then return end | |
949 | 949 | |
950 | 950 | game.logSeen(self, "#RED#%s reacts immediately after taking severe wounds!#LAST#", self:getName():capitalize()) |
951 | 951 | self.energy.value = self.energy.value + game.energy_to_act * 1.5 |
... | ... | @@ -954,7 +954,7 @@ newTalent{ |
954 | 954 | info = function(self, t) |
955 | 955 | return ([[Yeeks live fast, think fast, and sacrifice fast for the Way. |
956 | 956 | Your global speed is increased by %0.1f%%. |
957 | - If your life drops below 30%% you gain 1.5 turns. This effect can only happen once every %d turns.]]):tformat(100*t.speedup(self, t), self:getTalentCooldown(t)) | |
957 | + If your life is below 30%% after taking damage you gain 1.5 turns. This effect can only happen once every %d turns.]]):tformat(100*t.speedup(self, t), self:getTalentCooldown(t)) | |
958 | 958 | end, |
959 | 959 | } |
960 | 960 | ... | ... |
... | ... | @@ -37,24 +37,36 @@ function _M:init(chat, id, width) |
37 | 37 | end |
38 | 38 | |
39 | 39 | function _M:makeUI() |
40 | - self.c_desc = Textzone.new{has_box=true, ui="chat", font=self.chat.dialog_text_font, width=self.iw, height=1, auto_height=true, text=self.text, can_focus=false} | |
40 | + self.c_desc = Textzone.new{has_box=true, ui="chat", font=self.chat.dialog_text_font, width=self.iw - 30, height=1, auto_height=true, text=self.text, can_focus=false} | |
41 | 41 | self.c_list = VariableList.new{font=self.chat.dialog_answer_font, width=self.iw, max_height=game.h * 0.70 - self.c_desc.h, list=self.list, fct=function(item) self:use(item) end, select=function(item) self:select(item) end} |
42 | - local npc_frame = ChatPortrait.new{ui="chat", actor=self:getActorPortrait(self.npc.chat_display_entity or self.npc)} | |
43 | - local player_frame = ChatPortrait.new{ui="chat", actor=self:getActorPortrait(self.player.chat_display_entity or self.player)} | |
42 | + local npc_frame = ChatPortrait.new{ui="chat", side="right", actor=self:getActorPortrait(self.chat.npc_force_display_entity or self.npc.chat_display_entity or self.npc)} | |
43 | + local player_frame = ChatPortrait.new{ui="chat", side="left", actor=self:getActorPortrait(self.chat.player_force_display_entity or self.player.chat_display_entity or self.player)} | |
44 | 44 | |
45 | 45 | local uis = { |
46 | 46 | {hcenter=0, top=-12, ui=self.c_desc}, |
47 | 47 | {right=0, bottom=0, ui=self.c_list}, |
48 | - {left=-player_frame.w+self.frame.ox1-5, vcenter=-self.ix-4, ui=player_frame, ignore_size=true}, | |
49 | - {right=-npc_frame.w-self.frame.ox2-5, vcenter=-self.ix-4, ui=npc_frame, ignore_size=true}, | |
48 | + {left=-player_frame.w+self.frame.ox1-5, top=self.frame.oy1-self.iy, ui=player_frame, ignore_size=true}, | |
49 | + {right=-npc_frame.w-self.frame.ox2-5, top=self.frame.oy1-self.iy, ui=npc_frame, ignore_size=true}, | |
50 | 50 | } |
51 | 51 | |
52 | + -- Only for size info | |
53 | + local back = self:getUITexture("ui/portrait_frame_back.png") | |
54 | + local deco_down = self:getUITexture("ui/chat_ui_deco_padding_left_down.png") | |
55 | + | |
52 | 56 | self:loadUI(uis) |
53 | 57 | self:setFocus(self.c_list) |
54 | 58 | self:setupUI(false, true, function(w, h) |
59 | + local frameh = -self.frame.oy1 + self.frame.oy2 | |
60 | + -- Ensure minimal height | |
61 | + if h + frameh < back.h then h = back.h - frameh end | |
62 | + -- Ensure if it's too big but too small to not have the down deco, to increase it a it | |
63 | + if h + frameh > back.h and h + frameh < back.h + deco_down.h / 2 then h = back.h - frameh + deco_down.h / 2 end | |
55 | 64 | self.force_x = game.w / 2 - w / 2 |
56 | 65 | self.force_y = game.h - h - 20 |
66 | + return w, h | |
57 | 67 | end) |
68 | + npc_frame:adjustHeight(self.h) | |
69 | + player_frame:adjustHeight(self.h) | |
58 | 70 | end |
59 | 71 | |
60 | 72 | function _M:getActorPortrait(actor) |
... | ... | @@ -69,23 +81,35 @@ function _M:getActorPortrait(actor) |
69 | 81 | if self.player.getCurrentTalent and self.player:getCurrentTalent() then |
70 | 82 | local t = self.player:getTalentFromId(self.player:getCurrentTalent()) |
71 | 83 | if t then |
72 | - return Entity.new{name=t.name, image=t.image or "talents/default.png"} | |
84 | + local image = t.image or "portrait/unknown.png" | |
85 | + if image:find("^talents/") and fs.exists("/data/gfx/shockbolt/"..image:gsub("^talents/", "portrait/")) then | |
86 | + image = image:gsub("^talents/", "portrait/") | |
87 | + end | |
88 | + return Entity.new{name=t.name, image=image, chat_ignore_margins=true} | |
73 | 89 | else |
74 | - return Entity.new{name=actor.name, image="talents/default.png"} | |
90 | + return Entity.new{name=actor.name, image="portrait/unknown.png", chat_ignore_margins=true} | |
75 | 91 | end |
76 | 92 | else |
77 | - return Entity.new{name=actor.name, image="talents/default.png"} | |
93 | + return Entity.new{name=actor.name, image="portrait/unknown.png", chat_ignore_margins=true} | |
78 | 94 | end |
79 | 95 | end |
80 | 96 | |
81 | 97 | -- No need for anything special |
82 | 98 | if actor.image:find("^portrait/") then return actor end |
83 | 99 | |
84 | - -- Find the npc portrait | |
100 | + -- Find the portrait | |
85 | 101 | if actor.image == "invis.png" and actor.add_mos and actor.add_mos[1] and actor.add_mos[1].image and actor.add_mos[1].image:find("^npc/") and fs.exists("/data/gfx/shockbolt/"..actor.add_mos[1].image:gsub("^npc/", "portrait/")) then |
86 | 102 | return Entity.new{name=actor.name, image=actor.add_mos[1].image:gsub("^npc/", "portrait/")} |
87 | 103 | elseif actor.image:find("^npc/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^npc/", "portrait/")) then |
88 | 104 | return Entity.new{name=actor.name, image=actor.image:gsub("^npc/", "portrait/")} |
105 | + elseif actor.image:find("^npc/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^npc/", "portrait/")) then | |
106 | + return Entity.new{name=actor.name, image=actor.image:gsub("^npc/", "portrait/")} | |
107 | + elseif actor.image:find("^object/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^object/", "portrait/")) then | |
108 | + return Entity.new{name=actor.name, image=actor.image:gsub("^object/", "portrait/")} | |
109 | + elseif actor.image:find("^object/artifact/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^object/artifact/", "portrait/")) then | |
110 | + return Entity.new{name=actor.name, image=actor.image:gsub("^object/artifact/", "portrait/")} | |
111 | + elseif actor.image:find("^talents/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^talents/", "portrait/")) then | |
112 | + return Entity.new{name=actor.name, image=actor.image:gsub("^talents/", "portrait/")} | |
89 | 113 | end |
90 | 114 | |
91 | 115 | -- Last resort, use it as it is | ... | ... |
... | ... | @@ -27,6 +27,7 @@ local ActorFrame = require "engine.ui.ActorFrame" |
27 | 27 | module(..., package.seeall, class.inherit(Base)) |
28 | 28 | |
29 | 29 | function _M:init(t) |
30 | + self.side = assert(t.side, "no ChatPortrait side") | |
30 | 31 | assert(t.actor, "no ChatPortrait actor") |
31 | 32 | |
32 | 33 | self.name = t.actor.getName and t.actor:getName() or _t(t.actor.name) or _t"???" |
... | ... | @@ -39,11 +40,12 @@ function _M:init(t) |
39 | 40 | end |
40 | 41 | if self.image then |
41 | 42 | local iw, ih = self.image:getSize() |
43 | + self.oiw, self.oih = iw, ih | |
42 | 44 | if iw <= 64 then iw, ih = iw * 2, ih * 2 end |
43 | 45 | self.iw, self.ih = iw, ih |
44 | - if self.image.getEmptyMargins then | |
46 | + if self.image.getEmptyMargins and not t.actor.ignore_margins then | |
45 | 47 | local x1, x2, y1, y2 = self.image:getEmptyMargins() |
46 | - self.iy = y1 | |
48 | + self.iy = 0 | |
47 | 49 | else |
48 | 50 | self.iy = 0 |
49 | 51 | end |
... | ... | @@ -51,6 +53,7 @@ function _M:init(t) |
51 | 53 | self.iy = 0 |
52 | 54 | self.iw, self.ih = 128, 128 |
53 | 55 | end |
56 | + self.h_deco = 0 | |
54 | 57 | |
55 | 58 | Base.init(self, t) |
56 | 59 | end |
... | ... | @@ -61,14 +64,33 @@ function _M:generate() |
61 | 64 | |
62 | 65 | self.front = self:getUITexture("ui/portrait_frame_front.png") |
63 | 66 | self.back = self:getUITexture("ui/portrait_frame_back.png") |
67 | + self.deco_down = self:getUITexture("ui/chat_ui_deco_padding_"..self.side.."_down.png") | |
68 | + self.deco_up = self:getUITexture("ui/chat_ui_deco_padding_"..self.side.."_up.png") | |
64 | 69 | self.w, self.h = self.front.w, self.front.h |
65 | 70 | |
66 | - if self.image then self.item = {self.image:glTexture(Tiles.sharp_scaling)} end | |
71 | + if self.image then self.item = {self.image:glTexture(false, true)} end | |
67 | 72 | |
68 | 73 | self.name_tex = self:drawFontLine(self.font, self.name, nil, 0xff, 0xee, 0xcb) |
69 | 74 | end |
70 | 75 | |
76 | +function _M:adjustHeight(h) | |
77 | + self.h_deco = h - self.back.h | |
78 | +end | |
79 | + | |
71 | 80 | function _M:display(x, y, nb_keyframes, screen_x, screen_y) |
81 | + local deco_x | |
82 | + if self.h_deco >= self.deco_up.h + self.deco_down.h then | |
83 | + if self.side == "left" then deco_x = x + self.back.w - self.deco_up.w else deco_x = x end | |
84 | + self.deco_up.t:toScreenFull(deco_x, y, self.deco_up.w, self.deco_up.h, self.deco_up.tw, self.deco_up.th) | |
85 | + y = y + self.deco_up.h | |
86 | + screen_y = screen_y + self.deco_up.h | |
87 | + end | |
88 | + if self.h_deco >= 1 then | |
89 | + if self.side == "left" then deco_x = x + self.back.w - self.deco_down.w else deco_x = x end | |
90 | + local deco_h = math.min(self.deco_down.h, self.h_deco) | |
91 | + self.deco_down.t:toScreenFull(deco_x, y + self.back.h, self.deco_down.w, deco_h, self.deco_down.tw, deco_h * self.deco_down.th / self.deco_down.h) | |
92 | + end | |
93 | + | |
72 | 94 | self.back.t:toScreenFull(x, y, self.back.w, self.back.h, self.back.tw, self.back.th) |
73 | 95 | core.display.glScissor(true, screen_x + 15, screen_y + 15, 128, 192) |
74 | 96 | local dx, dy = x + 15 + (128 - self.iw) / 2, y + 15 + (192 - self.ih) / 2 |
... | ... | @@ -76,7 +98,7 @@ function _M:display(x, y, nb_keyframes, screen_x, screen_y) |
76 | 98 | if self.actor_frame then |
77 | 99 | self.actor_frame:display(dx, dy - self.iy) |
78 | 100 | elseif self.item then |
79 | - self.item[1]:toScreen(dx, dy - self.iy, self.iw, self.ih) | |
101 | + self.item[1]:toScreenFull(dx, dy - self.iy, self.iw, self.ih, self.item[2] * self.iw / self.oiw, self.item[3] * self.ih / self.oih) | |
80 | 102 | end |
81 | 103 | core.display.glScissor(false) |
82 | 104 | self.front.t:toScreenFull(x, y, self.front.w, self.front.h, self.front.tw, self.front.th) | ... | ... |
... | ... | @@ -243,7 +243,7 @@ Store:loadStores("/data/general/stores/basic.lua") |
243 | 243 | |
244 | 244 | -- Configure chat dialogs |
245 | 245 | require("engine.dialogs.Chat").show_portraits = true |
246 | --- require("engine.Chat").chat_dialog = "mod.dialogs.Chat" | |
246 | +require("engine.Chat").chat_dialog = "mod.dialogs.Chat" | |
247 | 247 | |
248 | 248 | -- Inventory tabs |
249 | 249 | InventoryUI.default_tabslist = function(self) | ... | ... |
-
Please register or login to post a comment