1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#################################################################################
# This file is part of Mana Launcher.
# Copyright (C) 2021 Jesusalva <jesusalva@tmw2.org>
#
# Credits: https://arianeb.com/2019/07/19/adding-discord-rich-presence-to-renpy-games/
# Note: Likely no license applicable.
#################################################################################
init -2 python:
def readyCallback(current_user):
print('Our user: {}'.format(current_user))
def disconnectedCallback(codeno, codemsg):
print('Disconnected from Discord rich presence RPC. Code {}: {}'.format(
codeno, codemsg
))
def errorCallback(errno, errmsg):
print('An error occurred! Error {}: {}'.format(
errno, errmsg
))
def RPCUpdate(title, image):
if not persistent.discord:
stdout("Discord RPC disabled, update skipped")
return
discord_rpc.update_connection()
discord_rpc.run_callbacks()
discord_rpc.update_presence(
**{
'details': title,
'start_timestamp': float(now()),
'large_image_key': image
}
)
# 'state': subtitle,
discord_rpc.update_connection()
discord_rpc.run_callbacks()
label before_main_menu:
if not persistent.discord:
$ stdout("Discord RPC disabled")
return
python:
# Note: 'event_name': callback
callbacks = {
'ready': readyCallback,
'disconnected': disconnectedCallback,
'error': errorCallback,
}
discord_rpc.initialize('840427221193195541', callbacks=callbacks, log=False)
start = time.time()
print(start)
discord_rpc.update_connection()
discord_rpc.run_callbacks()
discord_rpc.update_presence(
**{
'details': 'Main Menu',
'start_timestamp': float(now()),
'large_image_key': 'tmw2'
}
)
discord_rpc.update_connection()
discord_rpc.run_callbacks()
return
label quit:
$ stdout("Shutdown requested, cleaning up...")
$ responsive=False
$ discord_rpc.shutdown()
$ stdout("Thanks for playing the Mana Launcher.")
return
init -4 python:
def parse_command():
parser = renpy.arguments.ArgumentParser()
# Collect args
parser.add_argument('args', nargs='+', help="Command-line arguments.")
targs = parser.parse_args()
args = targs.args
if config.developer:
print("PARSEC")
print("Args: %s" % str(args))
## Command Line Defaults
if ("steam" in args):
print("Steam Mode Enabled")
persistent.steam = True
return True
renpy.arguments.register_command('adv', parse_command)
|