Interactive Object Highlight, Foreground, Bug fixes

* Added interactive room object highlights
* Added spacebar hotkey for the room objects highlights
* Added overlay param for room objects
* Fixed paperwork wheel menu action available before paperwork unlocks
* Improved foreground image handling for room objects
This commit is contained in:
LoafyLemon 2024-04-22 20:26:12 +01:00
parent 9d76d6088f
commit 4fbb2abad7
5 changed files with 62 additions and 15 deletions

View File

@ -162,6 +162,7 @@ init 1 python:
screen hotkeys_main():
tag hotkeys_main
if states.room == "main_room":
if states.map.unlocked:
key "map" action Jump("desk")
if states.paperwork_unlocked:
@ -172,3 +173,5 @@ screen hotkeys_main():
key "fap" action Jump("jerk_off")
key "summon" action Jump("door")
key "sleep" action If(game.daytime, Jump("night_start"), Jump("day_start"))
key "K_SPACE" action RoomHighlightToggle

View File

@ -15,7 +15,7 @@ init -1 python:
class RoomObject(object):
def __init__(self, room, id, pos, idle, hover=None, foreground=None, background=None, anchor=(0.5, 0.5), focus_mask=True, action=NullAction(), hovered=None, unhovered=None, tooltip=None, decoration=None, zorder=0, hidden=False):
def __init__(self, room, id, pos, idle, hover=None, foreground=None, background=None, anchor=(0.5, 0.5), focus_mask=True, action=NullAction(), hovered=None, unhovered=None, tooltip=None, decoration=None, zorder=0, hidden=False, overlay=None):
self.room = room
self.id = id
self.pos = pos
@ -32,6 +32,7 @@ init -1 python:
self.decoration = decoration
self.zorder = zorder
self.hidden = hidden
self.overlay = overlay
# Add to the main room if room was specified
if self.room:
@ -47,7 +48,7 @@ init -1 python:
def generate_hash(self):
salt = str( [self.id, self.pos, self.idle, self.hover, self.foreground, self.background, self.anchor, self.focus_mask,
self.action, self.hovered, self.unhovered, self.tooltip, self.decoration, self.zorder, self.hidden]
self.action, self.hovered, self.unhovered, self.tooltip, self.decoration, self.zorder, self.hidden, self.overlay]
)
return hash(salt)
@ -91,6 +92,21 @@ init -1 python:
# return Transform(Fixed(self.hover, self.decoration.room_image, fit_first=True), shader="outline_shader")
# return Transform(self.hover, shader="outline_shader")
def get_foreground(self):
return self._get_foreground(self.generate_hash())
@functools.cache
def _get_foreground(self, hash):
if self.hidden:
return Null()
if self.overlay:
if self.foreground:
return Fixed(self.foreground, self.overlay)
return self.overlay
elif self.foreground:
return self.foreground
def set_decoration(self, decoration):
if not isinstance(decoration, (Decoration, NoneType)):
raise TypeError("Decoration must be a Decoration instance reference or a NoneType")
@ -142,6 +158,31 @@ init -1 python:
return deco.replace_pos
return self.pos
def RoomHighlightToggle(state=None):
if not room_menu_active or renpy.in_rollback():
return
room = getattr(store, states.room, None)
if not room:
return
for i in room.objects:
if i.hidden or not i.action:
continue
if i.overlay:
i.overlay = None
else:
i.overlay = At(Text("🔎", align=(0.5, 0.5), size=24), room_highlight_anim)
renpy.restart_interaction()
transform room_highlight_anim:
subpixel True
easein 0.5 zoom 1.2
easeout 0.5 zoom 1.0
repeat
default room_menu_active = False
screen room_menu():

View File

@ -54,7 +54,7 @@ default desk_OBJ = RoomObject(
action={
"Sleep": (Text("💤", align=(0.5, 0.5)), IfExpr("game.daytime", Jump("night_start"), Jump("day_start")), "True"),
"Jerk Off": (Text("🍆", align=(0.5, 0.5)), Jump("jerk_off"), "True"),
"Do Paperwork": (Text("📝", align=(0.5, 0.5)), Jump("paperwork"), "True"),
"Do Paperwork": (Text("📝", align=(0.5, 0.5)), Jump("paperwork"), "states.paperwork_unlocked"),
"Open Deck Builder": (Text("🃏", align=(0.5, 0.5)), Jump("deck_builder"), "states.cardgame.unlocked"),
"Open Cheats Menu": (Text("🕹️", align=(0.5, 0.5)), Jump("cheats"), "game.cheats"),
},
@ -105,7 +105,7 @@ screen main_room():
pos obj.get_pos()
idle obj.get_idle()
hover obj.get_hover()
foreground obj.foreground
foreground obj.get_foreground()
background obj.background
focus_mask obj.focus_mask
tooltip obj.tooltip

View File

@ -19,7 +19,7 @@ screen seventh_floor():
pos obj.get_pos()
idle obj.get_idle()
hover obj.get_hover()
foreground obj.foreground
foreground obj.get_foreground()
background obj.background
focus_mask obj.focus_mask
tooltip obj.tooltip

View File

@ -16,6 +16,9 @@ screen snape_office():
default objects = sorted(snape_office.objects, key=lambda x: x.zorder)
if room_menu_active:
use hotkeys_main
add "images/rooms/snape_office/bg.webp" zoom 0.5
for obj in objects:
@ -24,7 +27,7 @@ screen snape_office():
pos obj.get_pos()
idle obj.get_idle()
hover obj.get_hover()
foreground obj.foreground
foreground obj.get_foreground()
background obj.background
focus_mask obj.focus_mask
tooltip obj.tooltip