Skip to content

Commit

Permalink
Merge pull request #82 from DRincs-Productions/80-improve-charanter-i…
Browse files Browse the repository at this point in the history
…nto-commitment-and-conversation

80 improve charanter into commitment and conversation
  • Loading branch information
BlackRam-oss committed Sep 22, 2023
2 parents 74a232c + 37c3fee commit a791c22
Show file tree
Hide file tree
Showing 20 changed files with 391 additions and 197 deletions.
14 changes: 10 additions & 4 deletions .vscode/NQTR-Routine.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"body": [
"python:",
" routine[\"${1:routine_id}\"] = Commitment(",
" ch_talkobj_dict={",
" \"${6:character_id}\" : TalkObject(",
" characters = [],",
" conversations = [",
" Conversation(",
" characters = ${6:character_name},",
" name=\"${7:talk_${1}}\",",
" label_name=\"${7:${6}_${1}_label}\",",
" conversation_background = \"${8:bg ${6} ${1} ${4} talk}\"",
Expand All @@ -25,8 +27,10 @@
"prefix": "DR_RoutineAdd_in_dict",
"body": [
"\"${1:routine_id}\" : Commitment(",
" ch_talkobj_dict={",
" \"${6:character_id}\" : TalkObject(",
" characters = [],",
" conversations = [",
" Conversation(",
" characters = ${6:character_name},",
" name=\"${7:talk_${1}}\",",
" label_name=\"${7:${6}_${1}_label}\",",
" conversation_background = \"${8:bg ${6} ${1} ${4} talk}\"",
Expand All @@ -45,6 +49,7 @@
"body": [
"python:",
" routine[\"${1:routine_id}\"] = Commitment(",
" characters=[],",
" event_label_name = \"${6:${1}_event_label}\"",
" hour_start=${2:0}, hour_stop=${3:24},",
" room_id=\"${4:room_id}\", location_id=\"${5:home}\",",
Expand All @@ -58,6 +63,7 @@
"prefix": "DR_EventAdd_in_dict",
"body": [
"\"${1:routine_id}\" : Commitment(",
" characters=[],",
" event_label_name = \"${6:${1}_event_label}\"",
" hour_start=${2:0}, hour_stop=${3:24},",
" room_id=\"${4:room_id}\", location_id=\"${5:home}\",",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/NQTR-Talk.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scope": "renpy",
"prefix": "DR_TalkChoiceAdd",
"body": [
"$ add_talk_choice(choice_id = \"${1:character_name}\", choice_text = _(\"${2:Name}\"), label_name = \"${3:label_be_started}\", dict_choices = talkch_choices)",
"$ add_conversation_choice(choice_character = ${1:character_name}, choice_text = _(\"${2:Name}\"), label_name = \"${3:label_be_started}\"",
"",
],
"description": "Add an Action in DEFAULT_LABEL_TALK"
Expand All @@ -12,7 +12,7 @@
"scope": "renpy",
"prefix": "DR_TalkChoiceDel",
"body": [
"$ del_talk_choice(choice_id = \"${1:character_name}\", choice_text = _(\"${2:Name}\"), dict_choices = talkch_choices)",
"$ del_conversation_choice(choice_character = ${1:character_name}, choice_text = _(\"${2:Name}\")",
"",
],
"description": "Delete an Action in DEFAULT_LABEL_TALK"
Expand Down
88 changes: 86 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,90 @@ Use search and replace of vscode with regex functionality enabled

![image](https://user-images.githubusercontent.com/67595890/224504331-1f546922-5673-4fa9-8cc7-e3fc4e671305.png)

### Routine Migration

For exemple:

the old routine:

```renpy
init python:
from pythonpackages.nqtr.routine import Commitment
from pythonpackages.nqtr.action_talk import TalkObject
define df_routine = {
# ...
"alice_read" : Commitment(
ch_talkobj_dict={
"alice" : TalkObject(
name="talk_alice_read",
conversation_background ="bg alice terrace talk"
),
},
hour_start=10, hour_stop=20,
location_id="house", room_id="terrace",
background ="bg alice terrace",
),
}
```

the new routine:

```renpy
init python:
from pythonpackages.nqtr.routine import Commitment
from pythonpackages.nqtr.conversation import Conversation
define df_routine = {
# ...
"alice_read" : Commitment(
conversations = [
Conversation(
name="talk_alice_read",
characters=a,
conversation_background ="bg alice terrace talk"
),
],
hour_start=10, hour_stop=20,
location_id="house", room_id="terrace",
background ="bg alice terrace",
),
}
```

### Conversation Migration

For exemple:

to add conversation:

```renpy
python:
add_talk_choice(choice_id = "alice", choice_text = _("About the Ann"), label_name = "stage_talkalice_aboutann", dict_choices = talkch_choices)
```

now:

```renpy
python:
add_conversation_choice(choice_character = a, choice_text = _("About the Ann"), label_name = "stage_talkalice_aboutann")
```

to remove conversation:

```renpy
python:
del_talk_choice(choice_id = "alice", choice_text = _("About the Ann"), dict_choices = talkch_choices)
```

now:

```renpy
python:
del_conversation_choice(choice_character = a, choice_text = _("About the Ann"))
```

### getTalkLabelName

* `getTalkLabelName\(\)`
Expand Down Expand Up @@ -393,12 +477,12 @@ Use search and replace of vscode with regex functionality enabled
### addTalkChoice

* `addTalkChoice\((.*)\)`
* `add_talk_choice($1)`
* `add_conversation_choice($1)`

### delTalkChoice

* `delTalkChoice\((.*)\)`
* `del_talk_choice($1)`
* `del_conversation_choice($1)`

# v1.0.3

Expand Down
9 changes: 0 additions & 9 deletions game/character_dict.rpy

This file was deleted.

1 change: 0 additions & 1 deletion game/flags_value.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ define flag_keys = [
# Wiki: https://github.com/DRincs-Productions/renpy-utility-lib/wiki/Flags#update_current_flags
label update_current_flags_custom:
# Custom code
$ log_info("is_weekend: " + str(tm.is_weekend))
if tm.is_weekend:
$ set_flags("weekend", True)
else:
Expand Down
8 changes: 5 additions & 3 deletions game/nqtr_screens/screens_nqtr.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ screen room_navigation():
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 ch_id, talk_obj in comm.ch_talkobj_dict.items():
if (talk_obj):
use action_talk_button(ch_id, talk_obj, comm.conversation_background(ch_id))
for conversation in comm.conversations:
if (conversation):
use action_talk_button(conversation, comm.conversation_background(conversation.character))

# Fixed button to wait
use wait_button()
Expand Down Expand Up @@ -190,6 +190,8 @@ label set_room_background(sp_bg_change_room = ""):
label after_return_from_room_navigation(label_name_to_call = ""):
if isNullOrEmpty(label_name_to_call):
$ log_error("label_name_to_call is empty", renpy.get_filename_line())
elif not renpy.has_label(label_name_to_call):
$ log_error("label_name_to_call: " + label_name_to_call + " not found", renpy.get_filename_line())
else:
$ renpy.call(label_name_to_call)
call set_background_nqtr
Expand Down
27 changes: 13 additions & 14 deletions game/nqtr_screens/screens_nqtr_component.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ screen wait_button(small = False):
else:
at nqtr_button_action_transform

screen character_icon(character_id):
if (character_id in character_dict):
screen character_icon_screen(icon):
if icon:
imagebutton:
idle character_dict.get(character_id).icon
idle icon
focus_mask True
action []
at dr_small_face_transform
Expand Down Expand Up @@ -64,30 +64,30 @@ screen action_picture_in_background(act):
tooltip act.name
at nqtr_button_action_picture_transform

screen action_talk_button(ch_id, talk_obj, background):
if not talk_obj.is_hidden(flags = flags, check_if_has_icon = False):
screen action_talk_button(conversation, background):
if not conversation.is_hidden(flags = flags, check_if_has_icon = False):
frame:
xysize (gui.nqtr_button_action_size, gui.nqtr_button_action_size)
background None

imagebutton:
align (0.5, 0.0)
if talk_obj.is_button:
idle talk_obj.button_icon
hover talk_obj.button_icon_selected
if conversation.is_button:
idle conversation.button_icon
hover conversation.button_icon_selected
else:
idle gui.default_talk_button_icon
focus_mask True
action [
SetVariable('talk_ch', ch_id),
SetVariable('talk_image', background),
Call("after_return_from_room_navigation", label_name_to_call = talk_obj.label_name),
SetVariable('current_conversation_character', conversation.character),
SetVariable('conversation_image', background),
Call("after_return_from_room_navigation", label_name_to_call = conversation.label_name),
]
at nqtr_button_action_transform
if renpy.variant("pc"):
tooltip _("Talk")

use character_icon(ch_id)
use character_icon_screen(conversation.character_icon)

screen location_button(location):
if (location.map_id == cur_map_id and not location.is_hidden(flags = flags)):
Expand Down Expand Up @@ -184,8 +184,7 @@ screen room_button(room, cur_room, i, find_ch = False):
for comm in commitments_in_cur_location.values():
# If it is the selected room
if room.id == comm.room_id:
for character_id in comm.ch_talkobj_dict:
use character_icon(character_id)
use character_icon_screen(comm.character_icon)
# Room name
text room.name:
size gui.dr_little_text_size
Expand Down
27 changes: 0 additions & 27 deletions game/nqtr_tool/action_talk_fun.rpy

This file was deleted.

31 changes: 31 additions & 0 deletions game/nqtr_tool/conversation_fun.rpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
init python:
def add_conversation_choice(choice_character, choice_text: str, label_name: str, dict_choices: dict[str, list] = None) -> None:
"""Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Conversation-system#add-an-talk-choice-in-default_label_talk """
if not dict_choices:
dict_choices = conversations
if (choice_character in dict_choices.keys()):
dict_choices[choice_character].append((choice_text, label_name))
else:
talk_choices = []
talk_choices.append((choice_text, label_name))
dict_choices[choice_character] = talk_choices
del talk_choices
return


def del_conversation_choice(choice_character: str, choice_text: str, dict_choices: dict[str, list] = None) -> None:
"""Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Conversation-system#delete-an-action-in-default_label_talk """
val = 0
if not dict_choices:
dict_choices = conversations
ch_to_del = choice_character
for cur_choice in dict_choices[choice_character]:
if cur_choice[0] == choice_text:
ch_to_del = choice_character
break
else:
val = val+1
dict_choices[choice_character].pop(val)
del val
del ch_to_del
return
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
define talk_ch = None
default talk_image = None
define current_conversation_character = None
default conversation_image = None
# used in talk_menu, internally there are the possible choices that you can make in a dialog with a certain ch
# is structured like this:
# 'alice' : [("Choice 1", "label_one"), ("Choice 2", "label_two")]
default talkch_choices = {}
default conversations = {}

define gui.default_talk_button_icon = "/nqtr_interface/action-talk.webp"

# Opens the choice menu, with the various dialogs you can currently do with a ch
label talk_menu:
# check if there is already a list of menu choices for talk_ch
# check if there is already a list of menu choices for current_conversation_character
# if it does not exist it creates it
if (talk_ch in talkch_choices.keys()):
$ talk_choices = talkch_choices[talk_ch]
if (current_conversation_character in conversations.keys()):
$ talk_choices = conversations[current_conversation_character]
else:
$ talk_choices = []

Expand All @@ -24,22 +24,15 @@ label talk_menu:
call expression menu_result
return

# label talk: is a label used to give the possibility to customize the dialog even more.
label talk:
if (talk_image != None):
scene expression (talk_image) as bg
# label nqtr_talk: is a label used to give the possibility to customize the dialog even more.
label nqtr_talk:
if (conversation_image != None):
scene expression (conversation_image) as bg

if(talk_ch == None):
$ log_error("talk_ch is None", renpy.get_filename_line())
if(current_conversation_character == None):
$ log_error("current_conversation_character is None", renpy.get_filename_line())
return

# Costume Code
if(talk_ch == "alice"):
mc "Hi [a]"
a "Hi, can you tell me something?"
else:
"Now is busy test later."

call talk_menu
return

Expand Down
9 changes: 9 additions & 0 deletions game/nqtr_values/action_label.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ menu talk_sleep:
"Leave her alone":
return

label alice_talk_menu:
if(current_conversation_character == a):
mc "Hi [a]"
a "Hi, can you tell me something?"
else:
"Now is busy test later."

call talk_menu

## Development Label

label open_smartphone:
Expand Down
Loading

0 comments on commit a791c22

Please sign in to comment.