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
|
has vbox
|
||||||
spacing 12
|
spacing 12
|
||||||
|
|
||||||
default last_who = None
|
default last_who = ""
|
||||||
|
|
||||||
# Group consecutive entries by same character (convert to list to avoid multiple enumeration problems)
|
for entry in _history_list:
|
||||||
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:
|
|
||||||
vbox:
|
vbox:
|
||||||
xfill True
|
xfill True
|
||||||
spacing 12
|
spacing 12
|
||||||
|
|
||||||
add gui.format("interface/achievements/{}/spacer.webp") align (0.5, 1.0)
|
if not last_who == entry.who:
|
||||||
hbox:
|
hbox:
|
||||||
spacing 12
|
spacing 12
|
||||||
|
|
||||||
$ g = list(g)
|
if "icon" in entry.show_args:
|
||||||
if "icon" in g[0].show_args:
|
$ icon = entry.show_args["icon"]
|
||||||
$ 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)
|
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:
|
if entry.who:
|
||||||
|
text entry.who:
|
||||||
style "history_name"
|
style "history_name"
|
||||||
substitute False
|
substitute False
|
||||||
|
|
||||||
if "color" in g[0].who_args:
|
if "color" in entry.who_args:
|
||||||
text_color g[0].who_args["color"]
|
color entry.who_args["color"]
|
||||||
|
|
||||||
vbox:
|
vbox:
|
||||||
spacing 6
|
spacing 6
|
||||||
|
$ what = renpy.filter_text_tags(entry.what, allow=gui.history_allow_tags)
|
||||||
|
|
||||||
for h in g:
|
|
||||||
$ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
|
|
||||||
text what:
|
text what:
|
||||||
substitute False
|
substitute False
|
||||||
|
|
||||||
|
$ last_who = entry.who
|
||||||
|
|
||||||
if not _history_list:
|
if not _history_list:
|
||||||
label _("The dialogue history is empty.")
|
label _("The dialogue history is empty.")
|
||||||
|
|
||||||
@ -83,34 +81,17 @@ style history_window is empty:
|
|||||||
padding (0,6)
|
padding (0,6)
|
||||||
|
|
||||||
style history_name:
|
style history_name:
|
||||||
xanchor 1.0
|
align (0.1, 0.5)
|
||||||
|
size 22
|
||||||
|
|
||||||
style history_name_text:
|
style history_name_text:
|
||||||
text_align 1.0
|
text_align 1.0
|
||||||
|
|
||||||
style history_text:
|
style history_text:
|
||||||
text_align 0.0
|
text_align 0.0
|
||||||
# layout ("subtitle" if gui.history_text_xalign else "tex")
|
|
||||||
|
|
||||||
style history_label:
|
style history_label:
|
||||||
xfill True
|
xfill True
|
||||||
|
|
||||||
style history_label_text:
|
style history_label_text:
|
||||||
xalign 0.5
|
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 random
|
||||||
import pygame
|
import pygame
|
||||||
import colorsys
|
import colorsys
|
||||||
import itertools
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import posixpath
|
import posixpath
|
||||||
import re
|
import re
|
||||||
|
Loading…
Reference in New Issue
Block a user