forked from SilverStudioGames/WTS
History Screen improvements and fixes
* Removed itertools dependency * Removed substitution for variables (redundant) * Fixed a crash caused by anonymous variable assignment inside a nested lambda function, inside list comprehension due to unsupported ast magic (what a mouthful) * Improved styling
This commit is contained in:
parent
260036b196
commit
2e42f6addb
@ -23,40 +23,38 @@ screen history():
|
||||
has vbox
|
||||
spacing 12
|
||||
|
||||
default last_who = None
|
||||
default last_who = ""
|
||||
|
||||
# Group consecutive entries by same character (convert to list to avoid multiple enumeration problems)
|
||||
default groups = [(k, list(g)) for k, g in itertools.groupby(_history_list, lambda x: x.who or x.show_args.get("icon", None))]
|
||||
|
||||
for k, g in groups:
|
||||
for entry in _history_list:
|
||||
vbox:
|
||||
xfill True
|
||||
spacing 12
|
||||
|
||||
add gui.format("interface/achievements/{}/spacer.webp") align (0.5, 1.0)
|
||||
hbox:
|
||||
spacing 12
|
||||
if not last_who == entry.who:
|
||||
hbox:
|
||||
spacing 12
|
||||
|
||||
$ g = list(g)
|
||||
if "icon" in g[0].show_args:
|
||||
$ icon = g[0].show_args["icon"]
|
||||
add Fixed(gui.format("interface/achievements/{}/iconbox.webp"), Transform("interface/icons/head/{}.webp".format(icon), xzoom=-1, size=(40, 40), align=(0.5, 0.5)), fit_first=True)
|
||||
elif g[0].who:
|
||||
label g[0].who:
|
||||
style "history_name"
|
||||
substitute False
|
||||
if "icon" in entry.show_args:
|
||||
$ icon = entry.show_args["icon"]
|
||||
add Fixed(gui.format("interface/achievements/{}/iconbox.webp"), Transform("interface/icons/head/{}.webp".format(icon), xzoom=-1, size=(40, 40), align=(0.5, 0.5)), fit_first=True)
|
||||
|
||||
if "color" in g[0].who_args:
|
||||
text_color g[0].who_args["color"]
|
||||
|
||||
vbox:
|
||||
spacing 6
|
||||
|
||||
for h in g:
|
||||
$ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
|
||||
text what:
|
||||
if entry.who:
|
||||
text entry.who:
|
||||
style "history_name"
|
||||
substitute False
|
||||
|
||||
if "color" in entry.who_args:
|
||||
color entry.who_args["color"]
|
||||
|
||||
vbox:
|
||||
spacing 6
|
||||
$ what = renpy.filter_text_tags(entry.what, allow=gui.history_allow_tags)
|
||||
|
||||
text what:
|
||||
substitute False
|
||||
|
||||
$ last_who = entry.who
|
||||
|
||||
if not _history_list:
|
||||
label _("The dialogue history is empty.")
|
||||
|
||||
@ -83,34 +81,17 @@ style history_window is empty:
|
||||
padding (0,6)
|
||||
|
||||
style history_name:
|
||||
xanchor 1.0
|
||||
align (0.1, 0.5)
|
||||
size 22
|
||||
|
||||
style history_name_text:
|
||||
text_align 1.0
|
||||
|
||||
style history_text:
|
||||
text_align 0.0
|
||||
# layout ("subtitle" if gui.history_text_xalign else "tex")
|
||||
|
||||
style history_label:
|
||||
xfill True
|
||||
|
||||
style history_label_text:
|
||||
xalign 0.5
|
||||
|
||||
init 1 python:
|
||||
# Substitute variables when history is added
|
||||
def substitute_history_entry(h):
|
||||
if h.what:
|
||||
for p in history_match_tags:
|
||||
h.what = p.sub('{\g<1>=[\g<2>]}', h.what)
|
||||
|
||||
h.what = renpy.substitute(h.what)
|
||||
|
||||
config.history_callbacks.append(substitute_history_entry)
|
||||
|
||||
# Match variables in tags and make them substitutable
|
||||
history_match_tags = []
|
||||
for t in gui.history_allow_tags:
|
||||
p = re.compile('\{(' + t + ')=([a-z_]+)\}', re.IGNORECASE)
|
||||
history_match_tags.append(p)
|
||||
|
@ -6,7 +6,6 @@ init -1 python:
|
||||
import random
|
||||
import pygame
|
||||
import colorsys
|
||||
import itertools
|
||||
import fnmatch
|
||||
import posixpath
|
||||
import re
|
||||
|
Loading…
Reference in New Issue
Block a user