- When you click on a node, it zooms in on that node and neighboring nodes
- When you click on the node again, you jump into a story segment
I've been using an imagemap so far, because it seems to better support zooming in and when the hotspots move.
Code: Select all
def zoom_in():
renpy.show_screen("flowchart", zoomed_in=True)
renpy.restart_interaction()
transform imap_small():
zoom 1.0
transform imap_zoom(t=0.5):
zoom 1.0
linear t zoom 2.0
screen flowchart(zoomed_in=False):
default select_node = None
default zoomed_node = nodes[0]
default imap_size = imap_zoom if zoomed_in else imap_small
default hotspot_size = 80 if zoomed_in else 40
frame:
xysize (config.screen_width, config.screen_height)
# this is just a blue background
add "bg_flowchart"
vbox:
align (0.5, 0.5)
viewport id "repaired_flowchart":
xalign 0.5
yalign 0.5
arrowkeys True
xysize(900, 2000)
xinitial 0.5
for node in nodes:
add node.get_icon() pos (node.get_coordinates(zoomed_in)) size (40, 40) at imap_size
imagemap:
at imap_size
ground "flowchart/images/flowchart_repaired_no_true.png"
idle Solid("#FF09", xysize=(config.screen_width, config.screen_height))
hover Solid("#F009", xysize=(config.screen_width, config.screen_height))
for node in nodes:
hotspot (node.get_x(zoomed_in), node.get_y(zoomed_in), hotspot_size, hotspot_size):
action [Function(zoom_in), SetVariable("select_node", node)]
hover_sound "sound/confirm-beep.mp3"
Code: Select all
class Status(Enum):
UNREAD = "unread"
NOVEL = "novel"
ESCAPE = "escape"
END = "end"
LOCKED = "locked"
class Node:
def __init__(self, coordinates, label, name, description, is_accessible, status=None, icon=None):
self.coordinates = coordinates
self.label = label
self.name = name
self.description = description
self.is_accessible = is_accessible
self.status = status
self.icon = icon
def set_is_accessible(self, is_accessible):
self.is_accessible = is_accessible
def get_is_accessible(self):
if self.label is None or self.status is Status.END or self.status is Status.LOCKED:
return False
return True
def get_coordinates(self, is_zoomed):
return (self.get_x(is_zoomed), self.get_y(is_zoomed))
def get_x(self, is_zoomed):
if is_zoomed:
return self.coordinates[0] * 2
return self.coordinates[0]
def get_y(self, is_zoomed):
if is_zoomed:
return self.coordinates[1] * 2
return self.coordinates[1]
def get_icon(self):
if self.icon:
return self.icon
if self.status is Status.UNREAD:
return 'flowchart/images/nodes/unread.png'
elif self.status is Status.NOVEL:
return 'flowchart/images/nodes/novel.png'
elif self.status is Status.ESCAPE:
return 'flowchart/images/nodes/escape.png'
return None
nodes = [
Node((400, 0), "start", "Fragment 0 ~ Scene 1", "Beginning", True, Status.NOVEL),
Node((400, 80), "frag0_s2_start", "Fragment 0 ~ Scene 2", "Meeting Everyone", frag0_s1_complete, Status.UNREAD),
Node((400, 160), "frag0_s3_start", "Fragment 0 ~ Scene 3", "Rules of the Game", frag0_s2_complete, Status.UNREAD),
Node((400, 240), None, "End of Prologue", None, frag0_complete, Status.END, "flowchart/images/nodes/badend.png"),
]
1. I always zoom in on the same place of the flowchart
2. The hotspots no longer work when the image
This is my flowchart, ground image, and a gif of the bug