Skip to content

Commit 1896558

Browse files
committed
Merge branch 'content' into r7.4
2 parents beab338 + 06baf31 commit 1896558

57 files changed

Lines changed: 620 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Monika After Story/game/0config.rpy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ python early:
1616
## The version of the game.
1717
renpy.config.version = "0.13.0"
1818

19+
1920
#Triple space suffix to avoid potential issues with same names in window title
2021
config.window_title = "Monika After Story "
2122

Monika After Story/game/0utils.rpy

Lines changed: 82 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,79 @@ python early in mas_utils:
388388

389389
mas_log = init_mas_log()
390390

391+
# Keep all warnings
392+
_deprecation_warnings = set()
393+
394+
def report_deprecation(
395+
deprecated,
396+
use_instead="",
397+
should_raise=False,
398+
deprecated_msg_fmt="{deprecated} is deprecated.",
399+
use_instead_msg_fmt="Use '{use_instead}' instead."
400+
):
401+
"""
402+
A unified function to report deprecation
403+
404+
IN:
405+
deprecated - the object that was deprecated or a str explaining what
406+
was deprecated
407+
Examples:
408+
report_deprecation("parameter 'mode'")
409+
report_deprecation(some_func)
410+
report_deprecation(DeprecatedClassExample)
411+
use_instead - str, the name of the function/class to use instead
412+
or just a message
413+
should_raise - bool, whether we raise an exception or just log the error
414+
deprecated_msg_fmt - str, formatter string used to report the deprecated object
415+
NOTE: MUST accept the 'deprecated' keyword and only it
416+
use_instead_msg_fmt - str, formatter string used to report the object to use instead
417+
of the deprecated one
418+
NOTE: MUST accept the 'use_instead' keyword and only it
419+
Examples:
420+
report_deprecation(
421+
"using 'int's",
422+
use_instead="floats"
423+
deprecated_msg_fmt="{deprecated} is no longer supported",
424+
use_instead_msg_fmt="The function now accepts {use_instead}."
425+
)
426+
427+
RAISES:
428+
DeprecationWarning - if should_raise is True
429+
"""
430+
if isinstance(deprecated, basestring):
431+
deprecated = deprecated.capitalize()
432+
433+
else:
434+
module = getattr(deprecated, "__module__", "")
435+
if module:
436+
module += "."
437+
438+
name = getattr(deprecated, "__name__", None)
439+
if not name:
440+
name = str(deprecated)
441+
442+
deprecated = "'{}{}'".format(module, name)
443+
444+
msg_start = deprecated_msg_fmt.format(deprecated=deprecated)
445+
446+
if use_instead:
447+
msg_end = " " + use_instead_msg_fmt.format(use_instead=use_instead)
448+
449+
else:
450+
msg_end = ""
451+
452+
msg = msg_start + msg_end
391453

392-
def deprecated(use_instead=None, should_raise=False):
454+
_deprecation_warnings.add(msg)
455+
456+
if should_raise:
457+
raise DeprecationWarning(msg)
458+
459+
else:
460+
print("[WARNING]: " + msg, file=sys.stderr)
461+
mas_log.warning(msg)
462+
463+
def deprecated(**report_kws):
393464
"""
394465
Decorator that marks functions and classes as deprecated
395466
@@ -399,11 +470,16 @@ python early in mas_utils:
399470
will be reported in the main log (mas_log.txt) and stderr
400471
NOTE: if we were allowed to raise, we RAISE a DeprecationWarning intead
401472
402-
You can access all the reports via __all_warnings__
473+
You can access all the reports via mas_utils._deprecation_warnings
403474
404475
IN:
405-
use_instead - string with the name of the function/class to use instead
406-
should_raise - whether we raise an exception or just log the error
476+
use_instead - string, the name of the function/class to use instead
477+
should_raise - bool, whether we raise an exception or just log the error
478+
deprecated_msg_fmt - string, a custom formater for the message (see report_deprecation)
479+
use_instead_msg_fmt - string, a custom formater for the message (see report_deprecation)
480+
481+
RAISES:
482+
DeprecationWarning - if should_raise is True
407483
"""
408484
def decorator(callable_):
409485
"""
@@ -421,43 +497,15 @@ python early in mas_utils:
421497
"""
422498
Wrapper around the deprecated function/class
423499
"""
424-
msg = "'{module}{name}' is deprecated.{use_instead_text}"
425-
426-
if hasattr(callable_, "__module__") and callable_.__module__:
427-
module = callable_.__module__ + "."
428-
else:
429-
module = ""
430-
431-
name = callable_.__name__
432-
433-
if not use_instead:
434-
use_instead_text = ""
435-
else:
436-
use_instead_text = " Use '{0}' instead.".format(use_instead)
437-
438-
msg = msg.format(
439-
module=module,
440-
name=name,
441-
use_instead_text=use_instead_text
442-
)
443-
444-
deprecated.__all_warnings__.add(msg)
445-
446-
if should_raise:
447-
raise DeprecationWarning(msg)
448-
449-
else:
450-
print("[WARNING]: " + msg, file=sys.stderr)
451-
mas_log.warning(msg)
500+
report_deprecation(callable_, **report_kws)
452501

453502
return callable_(*args, **kwargs)
454503

455504
return wrapper
456505

457506
return decorator
458507

459-
# Keep all warnings
460-
deprecated.__all_warnings__ = set()
508+
deprecated.__all_warnings__ = _deprecation_warnings
461509

462510
@deprecated(use_instead="mas_utils.mas_log.info")
463511
def writelog(msg):

Monika After Story/game/event-handler.rpy

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ init python:
24062406
eventdb.setdefault(event.eventlabel, event)
24072407

24082408

2409-
@store.mas_utils.deprecated("mas_hideEvent")
2409+
@store.mas_utils.deprecated(use_instead="mas_hideEvent")
24102410
def hideEvent(
24112411
event,
24122412
lock=False,
@@ -2576,7 +2576,8 @@ init python:
25762576
evhand._lockEventLabel(evlabel, eventdb=eventdb)
25772577

25782578

2579-
def mas_pushEvent(*args, **kwargs):
2579+
@store.mas_utils.deprecated(use_instead="MASEventList.push")
2580+
def pushEvent(event_label, skipeval=False, notify=False):
25802581
"""
25812582
NOTE: Preferable to use MASEventList.push
25822583
This pushes high priority or time sensitive events onto the top of
@@ -2597,7 +2598,8 @@ init python:
25972598
MASEventList.push(*args, **kwargs)
25982599

25992600

2600-
def mas_queueEvent(*args, **kwargs):
2601+
@store.mas_utils.deprecated(use_instead="MASEventList.queue")
2602+
def queueEvent(event_label, notify=False):
26012603
"""
26022604
NOTE: Preferable to use MASEventList.queue
26032605
This adds low priority or order-sensitive events onto the bottom of

0 commit comments

Comments
 (0)