[162] update overlays

This commit is contained in:
meisnate12 2022-10-26 17:14:08 -04:00
parent 2e9b0702be
commit 9702dd5dca
5 changed files with 101 additions and 112 deletions

View file

@ -1 +1 @@
1.17.3-develop161 1.17.3-develop162

BIN
config/overlays/temp.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

View file

@ -8,11 +8,19 @@
external_templates: external_templates:
pmm: templates pmm: templates
template_variables: template_variables:
default: style: round
style: round country: <<key>>
country: <<key>>
queue: position queue: position
pmm: flag/<<style>>/<<country>> pmm: flag/<<style>>/<<country>>
addon_position: left
addon_offset: 5
back_color: "#00000099"
back_width: 190
back_radius: 15
back_align: left
font: fonts/Inter-Bold.ttf
font_size: 50
final_name: text(<<text>>)
queues: queues:
position: position:
@ -75,245 +83,245 @@ templates:
overlays: overlays:
german: german:
variables: {key: de, weight: 610} variables: {key: de, text: DE, weight: 610}
template: [name: standard, name: flags] template: [name: standard, name: flags]
english: english:
variables: {key: en, weight: 600, country: us} variables: {key: en, text: EN, weight: 600, country: us}
template: [name: standard, name: flags] template: [name: standard, name: flags]
french: french:
variables: {key: fr, weight: 590} variables: {key: fr, text: FR, weight: 590}
template: [name: standard, name: flags] template: [name: standard, name: flags]
japanese: japanese:
variables: {key: ja, weight: 580, country: jp} variables: {key: ja, text: JA, weight: 580, country: jp}
template: [name: standard, name: flags] template: [name: standard, name: flags]
korean: korean:
variables: {key: ko, weight: 570, country: kr} variables: {key: ko, text: KO, weight: 570, country: kr}
template: [name: standard, name: flags] template: [name: standard, name: flags]
chinese: chinese:
variables: {key: zh, weight: 560, country: cn} variables: {key: zh, text: ZH, weight: 560, country: cn}
template: [name: standard, name: flags] template: [name: standard, name: flags]
danish: danish:
variables: {key: da, weight: 550, country: dk} variables: {key: da, text: DA, weight: 550, country: dk}
template: [name: standard, name: flags] template: [name: standard, name: flags]
russian: russian:
variables: {key: ru, weight: 540} variables: {key: ru, text: RU, weight: 540}
template: [name: standard, name: flags] template: [name: standard, name: flags]
spanish: spanish:
variables: {key: es, weight: 530} variables: {key: es, text: ES, weight: 530}
template: [name: standard, name: flags] template: [name: standard, name: flags]
italian: italian:
variables: {key: it, weight: 520} variables: {key: it, text: IT, weight: 520}
template: [name: standard, name: flags] template: [name: standard, name: flags]
portuguese: portuguese:
variables: {key: pt, weight: 510} variables: {key: pt, text: PT, weight: 510}
template: [name: standard, name: flags] template: [name: standard, name: flags]
hindi: hindi:
variables: {key: hi, weight: 500, country: in} variables: {key: hi, text: HI, weight: 500, country: in}
template: [name: standard, name: flags] template: [name: standard, name: flags]
telugu: telugu:
variables: {key: te, weight: 490, country: in} variables: {key: te, text: TE, weight: 490, country: in}
template: [name: standard, name: flags] template: [name: standard, name: flags]
farsi: farsi:
variables: {key: fa, weight: 480, country: ir} variables: {key: fa, text: FA, weight: 480, country: ir}
template: [name: standard, name: flags] template: [name: standard, name: flags]
thai: thai:
variables: {key: th, weight: 470} variables: {key: th, text: TH, weight: 470}
template: [name: standard, name: flags] template: [name: standard, name: flags]
dutch: dutch:
variables: {key: nl, weight: 460} variables: {key: nl, text: NL, weight: 460}
template: [name: standard, name: flags] template: [name: standard, name: flags]
norwegian: norwegian:
variables: {key: no, weight: 450} variables: {key: no, text: NO, weight: 450}
template: [name: standard, name: flags] template: [name: standard, name: flags]
icelandic: icelandic:
variables: {key: is, weight: 440} variables: {key: is, text: IS, weight: 440}
template: [name: standard, name: flags] template: [name: standard, name: flags]
swedish: swedish:
variables: {key: sv, weight: 430, country: se} variables: {key: sv, text: SV, weight: 430, country: se}
template: [name: standard, name: flags] template: [name: standard, name: flags]
turkish: turkish:
variables: {key: tr, weight: 420} variables: {key: tr, text: TR, weight: 420}
template: [name: standard, name: flags] template: [name: standard, name: flags]
polish: polish:
variables: {key: pl, weight: 410} variables: {key: pl, text: PL, weight: 410}
template: [name: standard, name: flags] template: [name: standard, name: flags]
czech: czech:
variables: {key: cs, weight: 400, country: cz} variables: {key: cs, text: CS, weight: 400, country: cz}
template: [name: standard, name: flags] template: [name: standard, name: flags]
ukrainian: ukrainian:
variables: {key: uk, weight: 390, country: ua} variables: {key: uk, text: UK, weight: 390, country: ua}
template: [name: standard, name: flags] template: [name: standard, name: flags]
hungarian: hungarian:
variables: {key: hu, weight: 380} variables: {key: hu, text: HU, weight: 380}
template: [name: standard, name: flags] template: [name: standard, name: flags]
arabic: arabic:
variables: {key: ar, weight: 370, country: eg} variables: {key: ar, text: AR, weight: 370, country: eg}
template: [name: standard, name: flags] template: [name: standard, name: flags]
bulgarian: bulgarian:
variables: {key: bg, weight: 360} variables: {key: bg, text: BG, weight: 360}
template: [name: standard, name: flags] template: [name: standard, name: flags]
bengali: bengali:
variables: {key: bn, weight: 350, country: bd} variables: {key: bn, text: BN, weight: 350, country: bd}
template: [name: standard, name: flags] template: [name: standard, name: flags]
bosnian: bosnian:
variables: {key: bs, weight: 340, country: ba} variables: {key: bs, text: BS, weight: 340, country: ba}
template: [name: standard, name: flags] template: [name: standard, name: flags]
catalan: catalan:
variables: {key: ca, weight: 330, country: es} variables: {key: ca, text: CA, weight: 330, country: es}
template: [name: standard, name: flags] template: [name: standard, name: flags]
welsh: welsh:
variables: {key: cy, weight: 320, country: uk} variables: {key: cy, text: CY, weight: 320, country: uk}
template: [name: standard, name: flags] template: [name: standard, name: flags]
greek: greek:
variables: {key: el, weight: 310, country: gr} variables: {key: el, text: EL, weight: 310, country: gr}
template: [name: standard, name: flags] template: [name: standard, name: flags]
estonian: estonian:
variables: {key: et, weight: 300, country: ee} variables: {key: et, text: ET, weight: 300, country: ee}
template: [name: standard, name: flags] template: [name: standard, name: flags]
basque: basque:
variables: {key: eu, weight: 290, country: es} variables: {key: eu, text: EU, weight: 290, country: es}
template: [name: standard, name: flags] template: [name: standard, name: flags]
finnish: finnish:
variables: {key: fi, weight: 280} variables: {key: fi, text: FI, weight: 280}
template: [name: standard, name: flags] template: [name: standard, name: flags]
filipino: filipino:
variables: {key: fil, weight: 270, country: ph} variables: {key: fil, text: FL, weight: 270, country: ph}
template: [name: standard, name: flags] template: [name: standard, name: flags]
galician: galician:
variables: {key: gl, weight: 260, country: es} variables: {key: gl, text: GL, weight: 260, country: es}
template: [name: standard, name: flags] template: [name: standard, name: flags]
hebrew: hebrew:
variables: {key: he, weight: 250, country: il} variables: {key: he, text: HE, weight: 250, country: il}
template: [name: standard, name: flags] template: [name: standard, name: flags]
croatian: croatian:
variables: {key: hr, weight: 240} variables: {key: hr, text: HR, weight: 240}
template: [name: standard, name: flags] template: [name: standard, name: flags]
indonesian: indonesian:
variables: {key: id, weight: 230} variables: {key: id, text: ID, weight: 230}
template: [name: standard, name: flags] template: [name: standard, name: flags]
georgian: georgian:
variables: {key: ka, weight: 220, country: ge} variables: {key: ka, text: KA, weight: 220, country: ge}
template: [name: standard, name: flags] template: [name: standard, name: flags]
kazakh: kazakh:
variables: {key: kk, weight: 210, country: kz} variables: {key: kk, text: KK, weight: 210, country: kz}
template: [name: standard, name: flags] template: [name: standard, name: flags]
kannada: kannada:
variables: {key: kn, weight: 200, country: in} variables: {key: kn, text: KN, weight: 200, country: in}
template: [name: standard, name: flags] template: [name: standard, name: flags]
latin: latin:
variables: {key: la, weight: 190, country: it} variables: {key: la, text: LA, weight: 190, country: it}
template: [name: standard, name: flags] template: [name: standard, name: flags]
lithuanian: lithuanian:
variables: {key: lt, weight: 180} variables: {key: lt, text: LT, weight: 180}
template: [name: standard, name: flags] template: [name: standard, name: flags]
latvian: latvian:
variables: {key: lv, weight: 170} variables: {key: lv, text: LV, weight: 170}
template: [name: standard, name: flags] template: [name: standard, name: flags]
macedonian: macedonian:
variables: {key: mk, weight: 160} variables: {key: mk, text: MK, weight: 160}
template: [name: standard, name: flags] template: [name: standard, name: flags]
malayalam: malayalam:
variables: {key: ml, weight: 150, country: in} variables: {key: ml, text: ML, weight: 150, country: in}
template: [name: standard, name: flags] template: [name: standard, name: flags]
marathi: marathi:
variables: {key: mr, weight: 140, country: in} variables: {key: mr, text: MR, weight: 140, country: in}
template: [name: standard, name: flags] template: [name: standard, name: flags]
malay: malay:
variables: {key: ms, weight: 130, country: my} variables: {key: ms, text: MS, weight: 130, country: my}
template: [name: standard, name: flags] template: [name: standard, name: flags]
norwegian bokmål: norwegian bokmål:
variables: {key: nb, weight: 120, country: no} variables: {key: nb, text: NB, weight: 120, country: no}
template: [name: standard, name: flags] template: [name: standard, name: flags]
norwegian nynorsk: norwegian nynorsk:
variables: {key: nn, weight: 110, country: no} variables: {key: nn, text: NN, weight: 110, country: no}
template: [name: standard, name: flags] template: [name: standard, name: flags]
punjabi: punjabi:
variables: {key: pa, weight: 100, country: in} variables: {key: pa, text: PA, weight: 100, country: in}
template: [name: standard, name: flags] template: [name: standard, name: flags]
romanian: romanian:
variables: {key: ro, weight: 90} variables: {key: ro, text: RO, weight: 90}
template: [name: standard, name: flags] template: [name: standard, name: flags]
slovak: slovak:
variables: {key: sk, weight: 80} variables: {key: sk, text: SK, weight: 80}
template: [name: standard, name: flags] template: [name: standard, name: flags]
slovenian: slovenian:
variables: {key: sv, weight: 70, country: si} variables: {key: sv, text: SV, weight: 70, country: si}
template: [name: standard, name: flags] template: [name: standard, name: flags]
albanian: albanian:
variables: {key: sq, weight: 60, country: al} variables: {key: sq, text: SQ, weight: 60, country: al}
template: [name: standard, name: flags] template: [name: standard, name: flags]
serbian: serbian:
variables: {key: sr, weight: 50, country: rs} variables: {key: sr, text: SR, weight: 50, country: rs}
template: [name: standard, name: flags] template: [name: standard, name: flags]
swahili: swahili:
variables: {key: sw, weight: 40, country: tz} variables: {key: sw, text: SW, weight: 40, country: tz}
template: [name: standard, name: flags] template: [name: standard, name: flags]
tamil: tamil:
variables: {key: ta, weight: 30, country: in} variables: {key: ta, text: TA, weight: 30, country: in}
template: [name: standard, name: flags] template: [name: standard, name: flags]
urdu: urdu:
variables: {key: ur, weight: 20, country: pk} variables: {key: ur, text: UR, weight: 20, country: pk}
template: [name: standard, name: flags] template: [name: standard, name: flags]
vietnamese: vietnamese:
variables: {key: vi, weight: 10, country: vn} variables: {key: vi, text: VI, weight: 10, country: vn}
template: [name: standard, name: flags] template: [name: standard, name: flags]

View file

@ -244,7 +244,8 @@ class DataFile:
for ck, cv in template["conditionals"].items(): for ck, cv in template["conditionals"].items():
conditionals[ck] = cv conditionals[ck] = cv
for input_dict, input_type, ignore_check in [ added_vars = {}
for input_dict, input_type, overwrite_call in [
(temp_vars, "External", False), (temp_vars, "External", False),
(extra_variables, "Definition", False), (extra_variables, "Definition", False),
(self.temp_vars, "Config", True) (self.temp_vars, "Config", True)
@ -261,8 +262,13 @@ class DataFile:
conditionals[ck] = cv conditionals[ck] = cv
elif input_value is None: elif input_value is None:
optional.append(str(input_key)) optional.append(str(input_key))
elif ignore_check or input_key not in variables: elif overwrite_call:
variables[input_key] = input_value variables[input_key] = input_value
else:
added_vars[input_key] = input_value
for k, v in added_vars.items():
if k not in variables:
variables[k] = v
language = variables["language"] if "language" in variables else "default" language = variables["language"] if "language" in variables else "default"
translation_variables = {k: v[language if language in v else "default"] for k, v in self.translations.items()} translation_variables = {k: v[language if language in v else "default"] for k, v in self.translations.items()}

View file

@ -205,11 +205,9 @@ class Overlay:
back_height = util.parse("Overlay", "back_height", self.data["back_height"], datatype="int", parent="overlay", minimum=0) if "back_height" in self.data else -1 back_height = util.parse("Overlay", "back_height", self.data["back_height"], datatype="int", parent="overlay", minimum=0) if "back_height" in self.data else -1
if self.name == "backdrop": if self.name == "backdrop":
self.back_box = (back_width, back_height) self.back_box = (back_width, back_height)
elif (back_width >= 0 > back_height) or (back_height >= 0 > back_width): elif self.back_align != "center" and back_width < 0:
raise Failed(f"Overlay Error: overlay attributes back_width and back_height must be used together") raise Failed(f"Overlay Error: overlay attribute back_align only works when back_width is used")
elif self.back_align != "center" and (back_width < 0 or back_height < 0): elif back_width >= 0 or back_height >= 0:
raise Failed(f"Overlay Error: overlay attribute back_align only works when back_width and back_height are used")
elif back_width >= 0 and back_height >= 0:
self.back_box = (back_width, back_height) self.back_box = (back_width, back_height)
self.has_back = True if self.back_color or self.back_line_color else False self.has_back = True if self.back_color or self.back_line_color else False
if self.name != "backdrop" and self.has_back and not self.has_coordinates() and not self.queue: if self.name != "backdrop" and self.has_back and not self.has_coordinates() and not self.queue:
@ -381,9 +379,9 @@ class Overlay:
box_width, box_height = box box_width, box_height = box
back_width, back_height = self.back_box if self.back_box else (None, None) back_width, back_height = self.back_box if self.back_box else (None, None)
if back_width == -1: if back_width == -1:
back_width = canvas_box[0] back_width = canvas_box[0] if self.name == "backdrop" else box_width
if back_height == -1: if back_height == -1:
back_height = canvas_box[1] back_height = canvas_box[1] if self.name == "backdrop" else box_height
start_x, start_y = self.get_coordinates(canvas_box, box, new_cords=new_cords) start_x, start_y = self.get_coordinates(canvas_box, box, new_cords=new_cords)
main_x = start_x main_x = start_x
main_y = start_y main_y = start_y
@ -403,17 +401,10 @@ class Overlay:
drawing.rectangle(cords, fill=self.back_color, outline=self.back_line_color, width=self.back_line_width) drawing.rectangle(cords, fill=self.back_color, outline=self.back_line_color, width=self.back_line_width)
if self.back_box: if self.back_box:
if self.back_align == "left": if self.back_align in ["left", "right", "center", "bottom"]:
main_y = start_y + (back_height - box_height) // 2 main_y = start_y + (back_height - box_height) // (1 if self.back_align == "bottom" else 2)
elif self.back_align == "right": if self.back_align in ["top", "bottom", "center", "right"]:
main_x = start_x + back_width - (text_width if text is not None else image_width) main_x = start_x + (back_width - box_width) // (1 if self.back_align == "right" else 2)
elif self.back_align == "top":
main_x = start_x + (back_width - box_width) // 2
elif self.back_align == "bottom":
main_y = start_y + back_height - (text_height if text is not None else image_height)
else:
main_x = start_x + (back_width - box_width) // 2
main_y = start_y + (back_height - box_height) // 2
addon_x = None addon_x = None
addon_y = None addon_y = None
@ -421,40 +412,18 @@ class Overlay:
addon_x = main_x addon_x = main_x
addon_y = main_y addon_y = main_y
if self.addon_position == "left": if self.addon_position == "left":
if self.back_align == "left": main_x = main_x + image_width + self.addon_offset
main_x = start_x + self.addon_offset
elif self.back_align == "right":
addon_x = start_x + back_width - self.addon_offset
else:
main_x = addon_x + image_width + self.addon_offset
elif self.addon_position == "right": elif self.addon_position == "right":
if self.back_align == "left": addon_x = main_x + text_width + self.addon_offset
addon_x = start_x + self.addon_offset
elif self.back_align == "right":
addon_x = start_x + back_width - image_width
main_x = start_x + back_width - self.addon_offset
else:
addon_x = main_x + text_width + self.addon_offset
elif text_width < image_width: elif text_width < image_width:
main_x = main_x + ((image_width - text_width) / 2) main_x = main_x + ((image_width - text_width) / 2)
elif text_width > image_width: elif text_width > image_width:
addon_x = main_x + ((text_width - image_width) / 2) addon_x = main_x + ((text_width - image_width) / 2)
if self.addon_position == "top": if self.addon_position == "top":
if self.back_align == "top": main_y = main_y + image_height + self.addon_offset
main_y = start_y + self.addon_offset
elif self.back_align == "bottom":
addon_y = start_y + back_height - self.addon_offset
else:
main_y = addon_y + image_height + self.addon_offset
elif self.addon_position == "bottom": elif self.addon_position == "bottom":
if self.back_align == "top": addon_y = main_y + text_height + self.addon_offset
addon_y = start_y + self.addon_offset
elif self.back_align == "bottom":
addon_y = start_y + back_height - image_height
main_y = start_y + back_height - self.addon_offset
else:
addon_y = main_y + text_height + self.addon_offset
elif text_height < image_height: elif text_height < image_height:
main_y = main_y + ((image_height - text_height) / 2) main_y = main_y + ((image_height - text_height) / 2)
elif text_height > image_height: elif text_height > image_height:
@ -463,6 +432,10 @@ class Overlay:
if text is not None: if text is not None:
drawing.text((int(main_x), int(main_y)), text, font=self.font, fill=self.font_color, drawing.text((int(main_x), int(main_y)), text, font=self.font, fill=self.font_color,
stroke_fill=self.stroke_color, stroke_width=self.stroke_width, anchor="lt") stroke_fill=self.stroke_color, stroke_width=self.stroke_width, anchor="lt")
logger.info(f"Text X: {main_x}")
logger.info(f"Text Y: {main_y}")
logger.info(f"Add X: {addon_x}")
logger.info(f"Add Y: {addon_y}")
if addon_x is not None: if addon_x is not None:
main_x = addon_x main_x = addon_x
main_y = addon_y main_y = addon_y
@ -496,7 +469,9 @@ class Overlay:
if new_cords is None and not self.has_coordinates(): if new_cords is None and not self.has_coordinates():
return 0, 0 return 0, 0
if self.back_box: if self.back_box:
box = self.back_box bw, bh = box
bbw, bbh = self.back_box
box = (bbw if bbw >= 0 else bw, bbh if bbh >= 0 else bh)
def get_cord(value, image_value, over_value, align): def get_cord(value, image_value, over_value, align):
value = int(image_value * 0.01 * int(value[:-1])) if str(value).endswith("%") else value value = int(image_value * 0.01 * int(value[:-1])) if str(value).endswith("%") else value