Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20 add notifications and improve log #54

Merged
merged 13 commits into from
Oct 29, 2022
1 change: 1 addition & 0 deletions game/script.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ label start:
## make check, for event...
call after_spending_time

call enable_notifyEx
call screen room_navigation
return
5 changes: 2 additions & 3 deletions game/tool/action.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ init -5 python:
self.day_start = day_start
self.rooms = rooms if rooms else []
if self.day_start < 0:
renpy.log("Warn: You have set day_start < 0, so it will be ignored")
log_info("You have set day_start < 0, so it will be ignored", renpy.get_filename_line())
if self.day_deadline < 0:
renpy.log(
"Warn: You have set day_deadline < 0, so it will be ignored")
log_info("You have set day_deadline < 0, so it will be ignored", renpy.get_filename_line())


def getActions(actions: dict[str, Act], room: Room, now_hour: int, cur_day: int) -> list[Act]:
Expand Down
2 changes: 1 addition & 1 deletion game/tool/action_talk.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ init -11 python:
elif not isNullOrEmpty(DEFAULT_LABEL_TALK):
return DEFAULT_LABEL_TALK
else:
renpy.log("Error: DEFAULT_LABEL_TALK is null or empty")
log_error("DEFAULT_LABEL_TALK is null or empty", renpy.get_filename_line())
return

def getBackground(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion game/tool/action_talk_label.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ label talk:
scene expression (talk_image) as bg

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

# Costume Code
Expand Down
17 changes: 7 additions & 10 deletions game/tool/button.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ init -99 python:
self.disabled = disabled
self.hidden = hidden
if (self.xalign != None and self.yalign == None):
renpy.log(
"Warn: xalign is set but yalign is not, so yalign set to 0")
log_warn("xalign is set but yalign is not, so yalign set to 0", renpy.get_filename_line())
self.yalign = 0
if (self.xalign == None and self.yalign != None):
renpy.log(
"Warn: yalign is set but xalign is not, so xalign set to 0")
log_warn("yalign is set but xalign is not, so xalign set to 0", renpy.get_filename_line())
self.xalign = 0
if (isNullOrEmpty(self.button_icon) and isNullOrEmpty(self.picture_in_background)):
renpy.log(
"Error: You have set button_icon and picture_in_background to None, this action will be ignored")
log_info("You have set button_icon and picture_in_background to None, this action will be ignored", renpy.get_filename_line())

def isButton(self) -> bool:
"""This is a button?"""
Expand Down Expand Up @@ -66,7 +63,7 @@ init -99 python:
elif(not isNullOrEmpty(self.picture_in_background)):
return self.picture_in_background
else:
renpy.log("Error: You have set button_icon and picture_in_background to None, this button will be ignored")
log_error("You have set button_icon and picture_in_background to None, this button will be ignored", renpy.get_filename_line())
return ""

def getPictureInBackgroundOrDefault(self) -> str:
Expand All @@ -75,7 +72,7 @@ init -99 python:
elif(not isNullOrEmpty(self.button_icon)):
return self.button_icon
else:
renpy.log("Error: You have set button_icon and picture_in_background to None, this button will be ignored")
log_error("You have set button_icon and picture_in_background to None, this button will be ignored", renpy.get_filename_line())
return ""

def getSelectedButtonOrDefault(self) -> str:
Expand All @@ -88,7 +85,7 @@ init -99 python:
elif(not isNullOrEmpty(self.picture_in_background)):
return self.picture_in_background
else:
renpy.log("Error: You have set button_icon_selected and picture_in_background_selected and button_icon and picture_in_background to None, this button will be ignored")
log_info("You have set button_icon_selected and picture_in_background_selected and button_icon and picture_in_background to None, this button will be ignored", renpy.get_filename_line())
return ""

def getSelectedPictureInBackgroundOrDefault(self) -> str:
Expand All @@ -101,5 +98,5 @@ init -99 python:
elif(not isNullOrEmpty(self.button_icon)):
return self.button_icon
else:
renpy.log("Error: You have set picture_in_background_selected and button_icon_selected and button_icon and picture_in_background to None, this button will be ignored")
log_error("You have set picture_in_background_selected and button_icon_selected and button_icon and picture_in_background to None, this button will be ignored", renpy.get_filename_line())
return ""
2 changes: 1 addition & 1 deletion game/tool/flags.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ init python:
if (not flag_id in flags):
updateFlags(flags = flags, flag_keys = flag_keys)
if (not flag_id in flags):
renpy.log("Error(getFlags): in flags is not there flag_id: "+flag_id)
log_error("in flags is not there flag_id: " + flag_id, renpy.get_filename_line())
else:
return False
return flags[flag_id]
4 changes: 2 additions & 2 deletions game/tool/nav_class.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ init -9 python:
def getRoomById(room_id: str, rooms: list[Room]) -> None:
"""Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Navigation-and-Map#change-room """
if not room_id:
renpy.log("Warning: room_id is None")
log_warn("room_id is None", renpy.get_filename_line())
return
for room in rooms:
if room.id == room_id:
Expand All @@ -149,7 +149,7 @@ init -9 python:
def getLocationById(location_id: str, locations: list[Room]) -> None:
"""Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Navigation-and-Map#change-location """
if not location_id:
renpy.log("Error: location_id is None")
log_error("location_id is None", renpy.get_filename_line())
return
for location in locations:
if location.id == location_id:
Expand Down
4 changes: 2 additions & 2 deletions game/tool/nqtr_screens.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -688,12 +688,12 @@ label set_room_background(sp_bg_change_room = ""):
# and in the "label" I use "return" an almost all cases the game will end.
label after_return_from_room_navigation(label_name_to_call = ""):
if isNullOrEmpty(label_name_to_call):
$ renpy.log("Error(after_return_from_room_navigation): label_name_to_call is empty")
$ log_error("label_name_to_call is empty", renpy.get_filename_line())
else:
$ renpy.call(label_name_to_call)
call set_background_nqtr
# Custom Code:
# ...
call screen room_navigation
$ renpy.log("Error(after_return_from_room_navigation): thera is a anomaly in room_navigation. value: " + label_name_to_call)
$ log_error("thera is a anomaly in room_navigation. value: " + label_name_to_call, renpy.get_filename_line())
jump after_return_from_room_navigation
19 changes: 11 additions & 8 deletions game/tool/quest.rpy
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
init python:
from typing import Optional

new_quest_notify = _("A new quest began")
quest_updated_notify = _("The quest has been updated")

class Goal(object):
"""Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Quest#goal"""
Expand All @@ -19,10 +21,10 @@ init python:
self.have = 0
if (self.have < 0):
self.have = 0
renpy.log("Warn: You have set have < 0, so it will be set to 0.")
log_warn("You have set have < 0, so it will be set to 0.", renpy.get_filename_line())
if (self.need < 0):
self.need = 0
renpy.log("Warn: You have set need < 0, so it will be set to 0.")
log_warn("You have set need < 0, so it will be set to 0.", renpy.get_filename_line())

def find(self, value: int = 1) -> bool:
"""Adds in element to the target, then checks the completion status. In case a need is null completes the mission. Returns True if the mission has been completed.
Expand All @@ -32,7 +34,6 @@ init python:
self.have += value
if (self.isComplete()):
self.complete = True
# Todo: notify description
return True
return False

Expand Down Expand Up @@ -128,7 +129,6 @@ init python:
self.active = True
if (self.start_label_name != None):
renpy.call(self.start_label_name)
# TODO: notify
return True

def respectAllRequests(self) -> bool:
Expand Down Expand Up @@ -226,8 +226,8 @@ init python:
def setDayNumberRequiredToStart(self, dayNumberRequired: int) -> None:
"""Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Quest#add-days-waiting-before-start """
if (not (self.id in number_stages_completed_in_quest)):
renpy.log("Warn: the Quest: "+self.id +
" not is in number_stages_completed_in_quest, so i update it")
log_warn("the Quest: "+self.id +
" not is in number_stages_completed_in_quest, so i update it", renpy.get_filename_line())
self.update()
return current_task_stages[self.id].setDayNumberRequiredToStart(dayNumberRequired)

Expand Down Expand Up @@ -257,6 +257,8 @@ init python:
quest_stages[self.stages_id[n_stage]].addInCurrentQuestStages()
current_quest_stages[self.id].start()
number_stages_completed_in_quest[self.id] = n_stage
if (n_stage == 0):
notifyEx(new_quest_notify)
return

def nextStageOnlyIsCompleted(self) -> bool:
Expand All @@ -276,12 +278,13 @@ init python:
del current_task_stages[self.quest_id]
return
self.afterNextStage()
notifyEx(quest_updated_notify)
return

def afterNextStage(self) -> None:
if (not (self.id in number_stages_completed_in_quest)):
renpy.log("Warn: the Quest: "+self.id +
" not is in number_stages_completed_in_quest, so i update it")
log_warn("the Quest: "+self.id +
" not is in number_stages_completed_in_quest, so i update it", renpy.get_filename_line())
self.update()
if len(self.stages_id)-1 == number_stages_completed_in_quest[self.id]:
current_quest_stages[self.id].completed = True
Expand Down
10 changes: 4 additions & 6 deletions game/tool/time_handler.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ init -11 python:
self.image_time = 0
self.update_image_time()
if self.hour_of_new_day < 0:
renpy.log(
"Warn: You have set hour_of_new_day < 0, so it will be set to 0.")
log_warn("You have set hour_of_new_day < 0, so it will be set to 0.", renpy.get_filename_line())
self.hour_of_new_day = 0
if self.hour < 0:
renpy.log("Warn: You have set hour < 0, so it will be set to 0.")
log_warn("You have set hour < 0, so it will be set to 0.", renpy.get_filename_line())
self.hour = 0
if self.day < 0:
renpy.log("Warn: You have set day < 0, so it will be set to 0.")
log_warn("You have set day < 0, so it will be set to 0.", renpy.get_filename_line())
self.day = 0
if self.weekend_day < 0:
renpy.log(
"Warn: You have set weekend_day < 0, so it will be set to 6.")
log_warn("You have set weekend_day < 0, so it will be set to 6.", renpy.get_filename_line())
self.weekend_day = 6

def get_hour_name(self) -> str:
Expand Down