Compare commits

...

19 Commits

Author SHA1 Message Date
Gouvernathor 4770be5f1b Convert existing cds using the new system 2024-03-28 22:28:53 +01:00
Gouvernathor a048b0e3cc Exception type 2024-03-28 22:27:10 +01:00
Gouvernathor e98680d123 Add dynamic statement 2024-03-27 00:26:23 +01:00
Gouvernathor 8e80555393 Add decorator 2024-03-27 00:26:14 +01:00
Gouvernathor 17ebf50170 Cleanup 2024-03-26 23:10:18 +01:00
Gouvernathor 375b77b2ab fix 2024-03-26 22:10:26 +01:00
Gouvernathor ffc47109ed Speedup dict accesses
nested dicts are حَرَام but due punishment will come at a later time
2024-03-26 22:06:04 +01:00
Gouvernathor f39cebc06f Remove another throwaway variable 2024-03-26 22:05:15 +01:00
Gouvernathor 66f8f5ab28 Avoid code duplication and using throwaway variables 2024-03-26 21:58:59 +01:00
Gouvernathor f17cffa3ec Final f-string batch
some uses of str.format remain, but converting them would be more trouble than it's worth
2024-03-26 21:58:22 +01:00
Gouvernathor 04f76d2b54 Warn about using reset_variables 2024-03-26 20:36:44 +01:00
Gouvernathor be88d0ed7e A bunch more f-strings
I'm not done
2024-03-26 20:31:41 +01:00
Gouvernathor 5fa2a0ff19 Translation doesn't work like that 2024-03-26 20:07:43 +01:00
Gouvernathor 15b6025d39 More f-strings 2024-03-26 19:56:38 +01:00
Gouvernathor 489f43cd0b Fix kwarg calls 2024-03-26 19:53:28 +01:00
Gouvernathor fa0acdbfff Generalized use of f-strings 2024-03-26 19:49:01 +01:00
Gouvernathor e4d64839b8 Avoid shadowing the builtin 2024-03-26 19:43:42 +01:00
Gouvernathor c816674c7c Unnecessary formatting 2024-03-26 19:42:57 +01:00
Gouvernathor 40be2ccf18 Factorize check 2024-03-26 19:41:37 +01:00
43 changed files with 391 additions and 353 deletions

File diff suppressed because it is too large Load Diff

View File

@ -82,12 +82,12 @@ init python:
child = getattr(self, layer) child = getattr(self, layer)
if isinstance(child, ImageReference): if isinstance(child, ImageReference):
name = getattr(self, "_{}".format(layer)) name = getattr(self, f"_{layer}")
attributes = renpy.get_attributes(name) or renpy.get_attributes("{}_{}".format(tag_prefix, layer)) attributes = renpy.get_attributes(name) or renpy.get_attributes(f"{tag_prefix}_{layer}")
if attributes: if attributes:
attributes = " ".join(attributes) attributes = " ".join(attributes)
child = ImageReference("{} {}".format(name, attributes)) child = ImageReference(f"{name} {attributes}")
elif child.name != name: elif child.name != name:
child = ImageReference(name) child = ImageReference(name)
else: else:

View File

@ -24,7 +24,7 @@ init python:
states.gen.image.offset = (0, 600) states.gen.image.offset = (0, 600)
if face: if face:
variant = "genie {}".format(face) variant = f"genie {face}"
renpy.set_tag_attributes(variant) renpy.set_tag_attributes(variant)
side = "genie" side = "genie"

View File

@ -82,7 +82,7 @@ init python:
else: else:
chibi["base"] = "ch_hem walk_robe_n" chibi["base"] = "ch_hem walk_robe_n"
else: else:
chibi["base"] = "ch_hem walk" chibi["base"] = "ch_hem walk"
elif not chibi.action or chibi.action == "stand": elif not chibi.action or chibi.action == "stand":
# Determine clothing state # Determine clothing state
@ -97,7 +97,7 @@ init python:
else: else:
chibi["base"] = "ch_hem blink_robe_n" chibi["base"] = "ch_hem blink_robe_n"
else: else:
chibi["base"] = "ch_hem blink" chibi["base"] = "ch_hem blink"
elif chibi.action == "dance": elif chibi.action == "dance":
# Determine clothing state # Determine clothing state
@ -140,9 +140,9 @@ init python:
elif chibi.action in ("drink_potion", "sniff_potion", "hold_potion"): elif chibi.action in ("drink_potion", "sniff_potion", "hold_potion"):
if not hermione.is_any_worn("top", "bottom"): if not hermione.is_any_worn("top", "bottom"):
chibi["base"] = "ch_hem {}_nude".format(chibi.action) chibi["base"] = f"ch_hem {chibi.action}_nude"
else: else:
chibi["base"] = "ch_hem {}".format(chibi.action) chibi["base"] = f"ch_hem {chibi.action}"
# Sets up a chibi scene with Hermione and Genie in it # Sets up a chibi scene with Hermione and Genie in it

View File

@ -14,7 +14,7 @@ screen chibi(chibi_object):
screen chibi_emote(emote, chibi_object): screen chibi_emote(emote, chibi_object):
zorder chibi_object.zorder zorder chibi_object.zorder
sensitive False sensitive False
add "emo_{}".format(emote): add f"emo_{emote}":
at emote_effect at emote_effect
anchor (0.5, 1.0) anchor (0.5, 1.0)
pos chibi_object.pos pos chibi_object.pos
@ -45,12 +45,12 @@ init -1 python:
def get_chibi_object(name): def get_chibi_object(name):
"""Get a chibi object by its character's name.""" """Get a chibi object by its character's name."""
name = "{}_chibi".format(name) name = f"{name}_chibi"
c = getattr(renpy.store, name, None) c = getattr(renpy.store, name, None)
if c and isinstance(c, Chibi): if c and isinstance(c, Chibi):
return c return c
else: else:
raise Exception("Chibi object not found. {}".format(name)) raise Exception(f"Chibi object not found. {name}")
def complete_chibi_moves(**elapsed): def complete_chibi_moves(**elapsed):
"""Resume old chibi action after (multiple) reduced move calls.""" """Resume old chibi action after (multiple) reduced move calls."""
@ -120,7 +120,7 @@ init -1 python:
if image_path: if image_path:
self.image_path = image_path self.image_path = image_path
else: else:
self.image_path = "characters/{}/chibis".format(tag) self.image_path = f"characters/{tag}/chibis"
if actions: if actions:
# Override class variable for this instance # Override class variable for this instance
@ -138,11 +138,11 @@ init -1 python:
self.transform = None self.transform = None
# Define a screen for the chibi # Define a screen for the chibi
self.screen_tag = "{}_chibi".format(tag) self.screen_tag = f"{tag}_chibi"
renpy.define_screen(self.screen_tag, Chibi._screen, tag=self.screen_tag, zorder="chibi_object.zorder") renpy.define_screen(self.screen_tag, Chibi._screen, tag=self.screen_tag, zorder="chibi_object.zorder")
# Define a screen for the chibi emote # Define a screen for the chibi emote
self.emote_tag = "{}_chibi_emote".format(tag) self.emote_tag = f"{tag}_chibi_emote"
renpy.define_screen(self.emote_tag, Chibi._emote_screen, tag=self.emote_tag, zorder="chibi_object.zorder") renpy.define_screen(self.emote_tag, Chibi._emote_screen, tag=self.emote_tag, zorder="chibi_object.zorder")
@staticmethod @staticmethod
@ -282,7 +282,7 @@ init -1 python:
# Combine with base transform # Combine with base transform
return combine_transforms(self.base_transform(), trans(*args)) return combine_transforms(self.base_transform(), trans(*args))
elif config.developer: elif config.developer:
raise Exception("Expected a transform: {}".format(name)) raise Exception(f"Expected an ATL transform: {name}")
# No transform was given or found # No transform was given or found
return self.base_transform() return self.base_transform()
@ -358,7 +358,7 @@ init -1 python:
room = room or renpy.store.states.room room = room or renpy.store.states.room
chibi_room = ChibiRoom.rooms.get(room, None) chibi_room = ChibiRoom.rooms.get(room, None)
if not chibi_room: if not chibi_room:
raise Exception("Chibi room is not defined for {}".format(room)) raise Exception(f"Chibi room is not defined for {room}")
return chibi_room return chibi_room
@staticmethod @staticmethod

View File

@ -37,7 +37,7 @@ init 1 python:
ltype, *tails = fn.rsplit("_") ltype, *tails = fn.rsplit("_")
# if not ltype in types: # if not ltype in types:
# print("Invalid layer type for file: {}".format(f)) # print(f"Invalid layer type for file: {f}")
# continue # continue
zorder = types.get(ltype) or self.zorder zorder = types.get(ltype) or self.zorder
@ -50,7 +50,7 @@ init 1 python:
lmodifier, *tails = tails lmodifier, *tails = tails
if not lmodifier in modifiers: if not lmodifier in modifiers:
print("Invalid modifier for file: {}".format(f)) print(f"Invalid modifier for file: {f}")
continue continue
zorder_mod = modifiers.get(lmodifier) zorder_mod = modifiers.get(lmodifier)

View File

@ -108,7 +108,7 @@ init python:
ltype, *tails = fn.rsplit("_") ltype, *tails = fn.rsplit("_")
if not ltype.isdigit() and not ltype in types: if not ltype.isdigit() and not ltype in types:
print("Invalid layer type for file: {}".format(f)) print(f"Invalid layer type for file: {f}")
continue continue
zorder = z if (z := types.get(ltype)) is not None else self.zorder zorder = z if (z := types.get(ltype)) is not None else self.zorder
@ -121,7 +121,7 @@ init python:
lmodifier, *tails = tails lmodifier, *tails = tails
if not lmodifier in modifiers: if not lmodifier in modifiers:
print("Invalid modifier for file: {}".format(f)) print(f"Invalid modifier for file: {f}")
continue continue
zorder_mod = modifiers.get(lmodifier) zorder_mod = modifiers.get(lmodifier)
@ -319,7 +319,7 @@ init python:
# Method 4 # Method 4
average = (0.3333, 0.3333, 0.3333) average = (0.3333, 0.3333, 0.3333)
return Transform(img, maxsize=maxsize, matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha)) return Transform(img, maxsize=maxsize, matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha))
except TypeError: except TypeError:

View File

@ -131,7 +131,7 @@ init python:
lmodifier, *tails = tails lmodifier, *tails = tails
if not lmodifier in modifiers: if not lmodifier in modifiers:
print("Invalid modifier for file: {}".format(f)) print(f"Invalid modifier for file: {f}")
continue continue
zorder_mod = modifiers.get(lmodifier) zorder_mod = modifiers.get(lmodifier)

View File

@ -54,7 +54,7 @@ init python:
ltype, *tails = fn.rsplit("_") ltype, *tails = fn.rsplit("_")
if not ltype in types: if not ltype in types:
print("Invalid layer type for file: {}".format(f)) print(f"Invalid layer type for file: {f}")
continue continue
zorder = types.get(ltype) or face_layers.get(part) zorder = types.get(ltype) or face_layers.get(part)
@ -63,7 +63,7 @@ init python:
lmodifier, *tails = tails lmodifier, *tails = tails
if not lmodifier in modifiers: if not lmodifier in modifiers:
print("Invalid modifier for file: {}".format(f)) print(f"Invalid modifier for file: {f}")
continue continue
zorder_mod = modifiers.get(lmodifier) zorder_mod = modifiers.get(lmodifier)

View File

@ -5,13 +5,13 @@ init python:
for c in states.dolls: for c in states.dolls:
char = get_character_object(c) char = get_character_object(c)
body_default = get_character_body(c, type="default") body_default = get_character_body(c, typ="default")
char.equip(body_default) char.equip(body_default)
outfit_default = get_character_outfit(c, type="default") outfit_default = get_character_outfit(c, typ="default")
char.equip(outfit_default) char.equip(outfit_default)
outfit_last = outfit = get_character_outfit(c, type="last") outfit_last = outfit = get_character_outfit(c, typ="last")
outfit_last.save() outfit_last.save()
char.set_face(mouth="base", eyes="base", eyebrows="base", pupils="mid", cheeks="none", tears="none") char.set_face(mouth="base", eyes="base", eyebrows="base", pupils="mid", cheeks="none", tears="none")

View File

@ -49,7 +49,7 @@ init python:
lmodifier, *tails = tails lmodifier, *tails = tails
if not lmodifier in modifiers: if not lmodifier in modifiers:
print("Invalid modifier for file: {}".format(f)) print(f"Invalid modifier for file: {f}")
continue continue
zorder_mod = modifiers.get(lmodifier) zorder_mod = modifiers.get(lmodifier)

View File

@ -218,7 +218,7 @@ init python:
d, d,
"interface/wardrobe/export_frame.webp", "interface/wardrobe/export_frame.webp",
Text(states.active_girl, align=(0.5, 0.995)), Text(states.active_girl, align=(0.5, 0.995)),
Text("Ver. {}".format(config.version), size=10, align=(0.99, 0.99)) Text(f"Ver. {config.version}", size=10, align=(0.99, 0.99))
) )
displayable_to_file(d, path, size=(310, 470) ) displayable_to_file(d, path, size=(310, 470) )
@ -286,4 +286,3 @@ init python:
if self.has_type(arg): if self.has_type(arg):
return True return True
return False return False

View File

@ -26,7 +26,9 @@ init python in gui:
The returned form is "{theme}_{name}", so styles can fall back on parent styles. The returned form is "{theme}_{name}", so styles can fall back on parent styles.
""" """
theme = "dark" if is_dark() else "light" theme = "dark" if is_dark() else "light"
return "{}_{}".format(theme, name) if name else theme if name:
return f"{theme}_{name}"
return theme
def format(template): def format(template):
""" """

View File

@ -36,7 +36,7 @@ screen history():
if "icon" in entry.show_args: if "icon" in entry.show_args:
$ icon = entry.show_args["icon"] $ 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) add Fixed(gui.format("interface/achievements/{}/iconbox.webp"), Transform(f"interface/icons/head/{icon}.webp", xzoom=-1, size=(40, 40), align=(0.5, 0.5)), fit_first=True)
if entry.who: if entry.who:
text entry.who: text entry.who:

View File

@ -138,7 +138,7 @@ screen preferences_visuals():
label "Framerate" label "Framerate"
textbutton ("{} fps".format(int(renpy.get_refresh_rate()))) action [Preference("gl framerate", None), Notify(fps_msg)] textbutton (f"{int(renpy.get_refresh_rate())} fps") action [Preference("gl framerate", None), Notify(fps_msg)]
if renpy.get_refresh_rate() > 60: if renpy.get_refresh_rate() > 60:
textbutton "60 fps" action [Preference("gl framerate", 60), Notify(fps_msg)] textbutton "60 fps" action [Preference("gl framerate", 60), Notify(fps_msg)]
textbutton "30 fps" action [Preference("gl framerate", 30), Notify(fps_msg)] textbutton "30 fps" action [Preference("gl framerate", 30), Notify(fps_msg)]
@ -178,7 +178,7 @@ screen preferences_visuals():
hbox: hbox:
bar value DictValue(persistent.custom_settings, "image_cache_size", range=1792, max_is_zero=False, style="slider", offset=256, step=128, force_step=True, action=Notify("Restart the game to apply image cache size changes.")) tooltip "Improves performance at a cost of higher memory usage." bar value DictValue(persistent.custom_settings, "image_cache_size", range=1792, max_is_zero=False, style="slider", offset=256, step=128, force_step=True, action=Notify("Restart the game to apply image cache size changes.")) tooltip "Improves performance at a cost of higher memory usage."
text get_gpu_info() yalign 1.0 size 10 text get_gpu_info() yalign 1.0 size 10
screen preferences_sound(): screen preferences_sound():
@ -325,9 +325,9 @@ auto saves, quick saves, and manual saves.{/size}\n
Are you sure?""" Are you sure?"""
define gui.SAVE_INCOMPATIBLE_WARNING = """{color=#7a0000}Warning!{/color} define gui.SAVE_INCOMPATIBLE_WARNING = """{color=#7a0000}Warning!{/color}
{size=-4}The save file you are attempting to load is not compatible {size=-4}The save file you are attempting to load is not compatible
with the current game version. While you can try loading it, with the current game version. While you can try loading it,
doing so may result in unexpected crashes and bugs. doing so may result in unexpected crashes and bugs.
Proceed anyway?""" Proceed anyway?"""

View File

@ -92,9 +92,9 @@ screen file_slots(title):
$ minutes, seconds = divmod(int(playtime), 60) $ minutes, seconds = divmod(int(playtime), 60)
$ hours, minutes = divmod(minutes, 60) $ hours, minutes = divmod(minutes, 60)
text FileTime(slot, format=_(slot_time_format)) text FileTime(slot, format=slot_time_format)
text "Day: {}".format(day) text f"Day: {day}"
text "Playtime: {}H {}M {}S".format(hours, minutes, seconds) text f"Playtime: {hours}H {minutes}M {seconds}S"
else: else:
text "INCOMPATIBLE VERSION" color "#f00" text "INCOMPATIBLE VERSION" color "#f00"
@ -104,7 +104,7 @@ screen file_slots(title):
key "save_delete" action FileDelete(slot) key "save_delete" action FileDelete(slot)
else: else:
text "Empty Slot {}.".format(FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows)) style "slot_button_text" text f"Empty Slot {FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows)}." style "slot_button_text"
## Buttons to access other pages. ## Buttons to access other pages.
hbox: hbox:
@ -131,7 +131,7 @@ screen file_slots(title):
xminimum 40 xminimum 40
action FilePage(page) action FilePage(page)
if page < 10: if page < 10:
keysym "K_{}".format(page) keysym f"K_{page}"
textbutton _(">") action FilePageNext() textbutton _(">") action FilePageNext()

View File

@ -193,7 +193,7 @@ screen choice(items, menu_yalign=.6):
style "empty" style "empty"
if style_part: if style_part:
style_prefix gui.theme("{}_menu".format(style_part)) style_prefix gui.theme(f"{style_part}_menu")
fit_first "height" fit_first "height"

View File

@ -170,7 +170,7 @@ screen brewing_menuitem():
text "Usable on:" size 12 text "Usable on:" size 12
hbox: hbox:
for c in current_item.usable_on: for c in current_item.usable_on:
add "interface/icons/head/{}.webp".format(c) size (24, 24) add f"interface/icons/head/{c}.webp" size (24, 24)
hbox: hbox:
spacing 10 spacing 10

View File

@ -62,11 +62,11 @@ init python:
icon = item.image icon = item.image
if quantity == 1: if quantity == 1:
text = "You have received one {}.".format(item.name) text = f"You have received one {item.name}."
else: else:
text = "You have received {} pieces of {}.".format(num_to_word(quantity), item.name) text = f"You have received {num_to_word(quantity)} pieces of {item.name}."
else: else:
items = ", ".join( [" ".join( [str(x[1]), x[0].name] ) for x in self.contents] ) items = ", ".join(f"{x[1]} {x[0].name}" for x in self.contents)
icon = "interface/icons/box_brown_"+str(random.randint(1, 4))+".webp" icon = "interface/icons/box_brown_"+str(random.randint(1, 4))+".webp"
text = "You have received your ordered items:\n{size=-4}"+items+"{/size}" text = "You have received your ordered items:\n{size=-4}"+items+"{/size}"

View File

@ -55,8 +55,9 @@ screen tutorial(entry):
text "Tutorial" size 10 yalign 0.5 text "Tutorial" size 10 yalign 0.5
text tutorial_dict[entry][0] size 16 xalign 0.5 yalign 0.5 text tutorial_dict[entry][0] size 16 xalign 0.5 yalign 0.5
if renpy.loadable("interface/tutorials/{}.webp".format(entry)): $ formated = f"interface/tutorials/{entry}.webp"
add "interface/tutorials/{}.webp".format(entry) xalign 0.5 if renpy.loadable(formated):
add formated xalign 0.5
text tutorial_dict[entry][1] size 12 text tutorial_dict[entry][1] size 12

Some files were not shown because too many files have changed in this diff Show More