Skip to content

Commit

Permalink
Merge pull request #98 from DRincs-Productions/97-enable-picture-in-b…
Browse files Browse the repository at this point in the history
…ackground-for-room-and-conversation

97 enable picture in background for room and conversation
  • Loading branch information
BlackRam-oss committed Jan 29, 2024
2 parents fc7e634 + 87d94b4 commit a2f8f46
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 25 deletions.
17 changes: 10 additions & 7 deletions game/nqtr_screens/screens_nqtr.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ init python:
from pythonpackages.nqtr.navigation import is_closed_room
from pythonpackages.nqtr.routine import commitment_background
from pythonpackages.nqtr.action import current_button_actions, current_picture_in_background_actions
from pythonpackages.nqtr.conversation_fun import current_button_conversations, current_picture_in_background_conversations

screen room_navigation():
modal True
Expand All @@ -17,12 +18,18 @@ screen room_navigation():
use location_button(location)

else:
# Action wich Picture in background
# Action and Room with Picture in background
for room in rooms:
if room.is_picture_in_background and not room.is_hidden(flags = flags):
use room_picture_in_background(room)
# Adds the button list of possible actions in that room
if (cur_room and room.id == cur_room.id and not room.id in closed_rooms):
for act in current_picture_in_background_actions(actions= actions | df_actions, room = room, now_hour = tm.hour , current_day = tm.day, tm = tm, flags = flags):
use action_picture_in_background(act)
# Talk
# Adds a talk for each ch (NPC) and at the talk interval adds the icon for each secondary ch
for conversation, comm in current_picture_in_background_conversations(commitments_in_cur_location, room, cur_room):
use conversation_picture_in_background(conversation, comm.conversation_background(conversation.character))

# Rooms
use room_button_list(rooms, commitments_in_cur_location)
Expand All @@ -40,12 +47,8 @@ screen room_navigation():

# Talk
# Adds a talk for each ch (NPC) and at the talk interval adds the icon for each secondary ch
for comm in commitments_in_cur_location.values():
if (cur_room and comm and room.id == comm.room_id and room.id == cur_room.id):
# Insert in talk for every ch, main in that room
for conversation in comm.conversations:
if (conversation):
use action_talk_button(conversation, comm.conversation_background(conversation.character))
for conversation, comm in current_button_conversations(commitments_in_cur_location, room, cur_room):
use conversation_button(conversation, comm.conversation_background(conversation.character))

# Fixed button to wait
use wait_button()
Expand Down
45 changes: 31 additions & 14 deletions game/nqtr_screens/screens_nqtr_component.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ screen time_text(tm, show_wait_button = False):
# Fixed button to wait
use wait_button(small = True)

screen button_picture_in_background(button, my_actions = []):
imagebutton:
align (button.xalign, button.yalign)
idle button.picture_in_background
hover button.picture_in_background_selected
focus_mask True
action my_actions
if renpy.variant("pc"):
tooltip button.name
if button.picture_in_background_selected == button.picture_in_background:
at nqtr_button_picture_transform

screen action_button(act):
imagebutton:
idle act.button_icon
Expand All @@ -52,20 +64,11 @@ screen action_button(act):
at nqtr_button_action_transform

screen action_picture_in_background(act):
imagebutton:
align (act.xalign, act.yalign)
idle act.picture_in_background
hover act.picture_in_background_selected
focus_mask True
action [
Call("after_return_from_room_navigation", label_name_to_call = act.label_name),
]
if renpy.variant("pc"):
tooltip act.name
if act.picture_in_background_selected == act.picture_in_background:
at nqtr_button_action_picture_transform
use button_picture_in_background(act, [
Call("after_return_from_room_navigation", label_name_to_call = act.label_name),
])

screen action_talk_button(conversation, background):
screen conversation_button(conversation, background):
python:
my_action = [
SetVariable('current_conversation_character', conversation.character),
Expand All @@ -92,6 +95,13 @@ screen action_talk_button(conversation, background):

use character_icon_screen(conversation.character_icon, my_action)

screen conversation_picture_in_background(conversation):
use button_picture_in_background(conversation, [
SetVariable('current_conversation_character', conversation.character),
SetVariable('conversation_image', background),
Call("after_return_from_room_navigation", label_name_to_call = conversation.label_name),
])

screen location_button(location):
if (location.map_id == cur_map_id and not location.is_hidden(flags = flags)):
vbox:
Expand Down Expand Up @@ -172,7 +182,7 @@ screen room_button_list(rooms, commitments_in_cur_location):
$ there_are_ch = True

# If the Locations where I am is the same as the Locations where the room is located
if (room.location_id == cur_location.id and room.is_button != None and not room.is_hidden(flags)):
if (room.location_id == cur_location.id and room.is_button and not room.is_hidden(flags)):
$ key_room += 1
use room_button(room, cur_room, key_room, there_are_ch)

Expand Down Expand Up @@ -223,3 +233,10 @@ screen room_button(room, cur_room, key_room, find_ch = False):
key str(key_room) action room_action
elif key_room == 10:
key str(0) action room_action

screen room_picture_in_background(room):
use button_picture_in_background(room, [
SetVariable('prev_room', cur_room),
SetVariable('cur_room', room),
Call("after_return_from_room_navigation", label_name_to_call = "change_room"),
])
2 changes: 1 addition & 1 deletion game/screens_style
2 changes: 1 addition & 1 deletion pythonpackages/nqtr/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(
if len(characters) == 0:
log_error(
f"Conversation {self.name} has no characters. This not work.",
filename_line="pythonpackages/nqtr/action_talk.py:Conversation.__init__",
filename_line="pythonpackages/nqtr/conversation.py:Conversation.__init__",
)
self.characters = characters
self.conversation_background = conversation_background
Expand Down
38 changes: 38 additions & 0 deletions pythonpackages/nqtr/conversation_fun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from pythonpackages.nqtr.conversation import Conversation
from pythonpackages.nqtr.navigation import Room
from pythonpackages.nqtr.routine import Commitment
from pythonpackages.renpy_utility.renpy_custom_log import *
from pythonpackages.renpy_utility.utility import *
import renpy.character as character


def current_button_conversations(
commitments_in_cur_location: dict[character.ADVCharacter, Commitment],
room: Room,
cur_room: Room,
) -> list[tuple[Conversation, Commitment]]:
"""Return a list of conversation buttons for the current room and available for the current time"""
conversations: list[tuple[Conversation, Commitment]] = []
for comm in commitments_in_cur_location.values():
if cur_room and comm and room.id == comm.room_id and room.id == cur_room.id:
# Insert in talk for every ch, main in that room
for conversation in comm.conversations:
if conversation:
conversations.append((conversation, comm))
return conversations


def current_picture_in_background_conversations(
commitments_in_cur_location: dict[character.ADVCharacter, Commitment],
room: Room,
cur_room: Room,
) -> list[tuple[Conversation, Commitment]]:
"""Return a list of conversation picture in background for the current room and available for the current time"""
conversations: list[tuple[Conversation, Commitment]] = []
for comm in commitments_in_cur_location.values():
if cur_room and comm and room.id == comm.room_id and room.id == cur_room.id:
# Insert in talk for every ch, main in that room
for conversation in comm.conversations:
if conversation and conversation.is_picture_in_background:
conversations.append((conversation, comm))
return conversations
2 changes: 1 addition & 1 deletion pythonpackages/nqtr/locals.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Act",
"clear_expired_actions",
"current_actions",
# action_talk
# conversation
"Conversation",
# button
"Button",
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from d34de9 to b7798b

0 comments on commit a2f8f46

Please sign in to comment.