From a567db7f2e2eef2edcc1d66b7d733a44598ae7c7 Mon Sep 17 00:00:00 2001 From: Zughy <4279489-marco_a@users.noreply.gitlab.com> Date: Tue, 28 Jul 2020 14:57:10 +0200 Subject: [PATCH] to scale the title + bugfix with .is_shown() --- DOCS.md | 1 + api.lua | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/DOCS.md b/DOCS.md index acea9cc..ab947fe 100644 --- a/DOCS.md +++ b/DOCS.md @@ -16,6 +16,7 @@ The parameters it takes are the following: * `bg`: the picture to put in the background * `bg_scale`: its scaling * `title`: the default text +* `title_size`: (table) as a multiplier, where Y is not considered. Ie. `{ x = 2}` will double up the font size * `title_alignment` * `title_offset` * `title_color` diff --git a/api.lua b/api.lua index a7112df..a1f4e66 100644 --- a/api.lua +++ b/api.lua @@ -18,11 +18,12 @@ Panel = { }, title_def = { hud_elem_type = "text", - position = {x = 1, y = 0.5}, + position = {x = 1, y = 0.5}, alignment = {x = 0, y = 0}, - offset = {x = 0, y = 0}, - number = 0xFFFFFF, - text = "Default" + offset = {x = 0, y = 0}, + size = { x = 1 }, + number = 0xFFFFFF, + text = "Default" }, sub_img_elems = {}, @@ -74,6 +75,10 @@ function Panel:new(def) panel.title_def.number = def.title_color end + if def.title_size then + panel.title_def.size = def.title_size + end + if def.player then panel.player_name = def.player end @@ -172,7 +177,7 @@ function Panel:update(def, txt_elems, img_elems) for elem, _ in pairs(txt_elems) do for k, v in pairs(txt_elems[elem]) do self[elem][k] = v - if self.is_shown then + if self.is_shown == true then player:hud_change(self.hud_id[elem], k, v) end end @@ -185,7 +190,7 @@ function Panel:update(def, txt_elems, img_elems) for elem, _ in pairs(img_elems) do for k, v in pairs(img_elems[elem]) do self[elem][k] = v - if self.is_shown then + if self.is_shown == true then player:hud_change(self.hud_id[elem], k, v) end end