summaryrefslogtreecommitdiff
path: root/game/renpy.rpy
blob: 85f556c1b9b0b64a31c88317d7814ff2bc42a43f (plain) (blame)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#################################################################################
#     This file is part of Mana Launcher.
#     Copyright (C) 2021  Jesusalva <jesusalva@tmw2.org>
#
#     Distributed under the MIT license.
#################################################################################

image TMW2 = "images/TMW2.png"
image MLP  = "images/mirrorlake.png"
image DKSD = "images/darkshadow.png"
image DKBG = "#210"
define evil = Character("???", color="#f00")

screen loading():
    zorder 100

    fixed:
        frame:
            xfill True
            yfill True
            background Frame("images/default.png", 0, 0)
        bar:
            value progress
            range 100
            xalign 0.5
            yalign 0.45
            xmaximum 0.75
        label "[statusmsg]":
            xalign 0.5
            yalign 0.55

screen serverdata(server):
    zorder 100

    fixed:
        frame:
            xfill True
            yfill True
            background Frame("images/default.png", 0, 0)
        label "{b}%s{/b}" % persistent.serverlist[server]["Name"]:
            xalign 0.5
            yalign 0.2
        label "{color=#fff}[statusmsg]{/color}":
            xalign 0.5
            yalign 0.5
        hbox:
            xalign 0.5
            yalign 0.8
            text _("{a=%s}Website{/a}" % persistent.serverlist[server]["Link"])
            null width 20
            text "|"
            null width 20
            text _("{a=%s}Support{/a}" % persistent.serverlist[server]["Help"])
            null width 20
            text _("{a=%s}News{/a}" % persistent.serverlist[server]["News"])
            null width 20
            text _("{a=%s}Terms of Use{/a}" % persistent.serverlist[server]["Policy"])

screen souldata():
    zorder 100
    if mySoul is not None:
      fixed:
        frame:
            background Frame("images/default.png", 0, 0)
            xalign 0.5
            yalign 0.5
            xminimum 0.85
            xmaximum 0.85
            yminimum 0.8
            ymaximum 0.8
            hbox:
                null width 320
                null width 40
                vbox:
                    null height 20
                    label "{b}{color=#FFF}%s{/color}{/b}" % mySoul["name"]
                    null height 20
                    hbox:
                        label "{color=#FFF}0{/color}"
                        null width 20
                        bar:
                            value mySoul["exp"]
                            range mySoul["next"]
                            xmaximum 0.5
                        null width 20
                        label "{color=#FFF}%d{/color}" % mySoul["next"]
                    null height 30
                    hbox:
                        label "{color=#FFF}%s %d{/color}" % (_("Level"), mySoul["level"])
                        #button Level up
                    null height 30
                    ## TODO: Other stuff
                    null height 30
                    label "{color=#FFF}%s{/color}" % _("Scene Recollection")
                    vpgrid:
                        cols 2
                        spacing 5
                        draggable True
                        mousewheel True
                        scrollbars "vertical"
                        side_xalign 0.5
                        if mySoul["level"] >= 0:
                            textbutton _("Prologue"):
                                background Frame("gui/frame.png", 0, 0)
                                xysize (200, 40)
                                action Return("intro")
                                tooltip _("Replay the prologue.")
        frame:
            yalign 0.9
            xalign 0.9
            xmaximum 240
            button:
                xmaximum 240
                ymaximum 40
                action Return(None)
                fixed:
                    #add Frame("gui/button/choice_hover_background.png", 0, 0)
                    text _("Return »"):
                        color "#000"
                        xalign 0.5
                        yalign 0.5

# The game starts here.
label start:
    $ statusmsg="Validating SSL Certificates..."
    scene black

    show screen loading
    call before_main_menu
    $ stdout("Before menu OK")

    # Build the Vault PEM, blocking and fatal
    $ build_vault()
    $ stdout("Vault PEM OK")

    # Run updater
    $ renpy.invoke_in_thread(CONFIGURE_LAUNCHER)
    $ stdout("Thread start OK")

    # Estabilish the connection to server
    python:
        # Block the main thread until the socket connection is done
        while progress < 100:
            if responsive:
                sdelay()
            else:
                break

            # Maybe we are waiting some prompt
            if SCR_PROMPT is not None:
                SCR_RESULT = renpy.call_screen("confirm", SCR_PROMPT,
            Return(True), Return(False))
                SCR_PROMPT = None


    $ stdout("Thread finish OK")

    # Kill the program
    if not responsive:
        jump die

    # Do we have a Vault ID?
    if not vaultId:
        call register

    # If we still don't have a Vault ID - something went wrong D:
    if not vaultId:
        $ status_update("{color=#F00}Failure! Vault ID could not be set.{/color}")
        jump die

    $ stdout("Connection established! User ID %d" % vaultId)

    # Open game
    hide screen loading
    scene black
    if persistent.vaultId is None or persistent.vaultId != vaultId:
        $ persistent.vaultId = vaultId
        call intro
        scene black with None
    show TMW2 at truecenter
    with Dissolve(0.5)
    pause 1.0
    hide TMW2 with dissolve
    #centered "Error"
    #if config.developer:
    #    "User ID: [vaultId]"
label start_loop:
    while True:
        $ renpy.block_rollback()
        call screen mirrorlake
        ## Quit request
        if _return is None or _return == "QUIT":
            $ stdout("Good bye!")
            $ renpy.quit()
            return
        ## Asked for The Void
        if _return < 0:
            $ stdout("V0id")
            call thevoid
            jump start_loop
        ## Asked for any subworld
        scene black
        # FIXME: Improve this waiting screen
        # Possibly retrieve messages from the thread
        $ statusmsg="Now loading..."
        show screen serverdata(_return)
        with None
        pause 0.01
        python:
            renpy.invoke_in_thread(launch_game, _return)
            progress = 0
            # Block the main thread until the socket connection is done
            while progress < 100:
                if responsive:
                    sdelay()
                else:
                    break

                # Maybe we are waiting some prompt
                if SCR_PROMPT is not None:
                    SCR_RESULT = renpy.call_screen("confirm", SCR_PROMPT,
                Return(True), Return(False))
                    SCR_PROMPT = None

        hide screen serverdata
        # Kill the program instead of looping back
        if not responsive:
            scene black
            centered "{color=#FFF}{b}An error happened.{/b}\n\nPlease login again. If this issue persists, relaunch the app or {a=https://discord.gg/BQNTe68}contact us{/a}{/color}"
            $ stdout("Program died - unsucessful game launch")
            return

        # Automatically loop back
    # Will never reach this line
    return

#################################################################################
init python:
    class ManaSparkle(object):
        def __init__(self, spd=25, multi=True):
            self.sm = SpriteManager(update=self.update)
            self.items = [ ]
            if multi:
                d = Transform("images/EnBallBlue.png", zoom=.05)
                for i in range(0, 80):
                    self.add(d, renpy.random.randint(spd, spd*2))
            d = Transform("images/EnBallBlue.png", zoom=.10)
            for i in range(0, 45):
                self.add(d, renpy.random.randint(spd, spd*2))
            d = Transform("images/EnBallBlue.png", zoom=.25)
            for i in range(0, 10):
                self.add(d, renpy.random.randint(spd, spd*2))
            d = Transform("images/EnBallBlue.png", zoom=.40)
            for i in range(0, 5):
                self.add(d, renpy.random.randint(spd, spd*2))
        def add(self, d, speed):
            s = self.sm.create(d)
            startx = renpy.random.randint(0, 1200)
            starty = renpy.random.randint(400, 720)
            vect = renpy.random.randint(0, 4)
            self.items.append((s, startx, starty, vect, speed))
        def update(self, st):
            for s, startx, starty, vect, speed in self.items:
                if vect % 2 == 0:
                    s.x = (startx + speed * st) % 1300
                else:
                    s.x = (startx - speed * st) % 1300
                if vect % 2 == 1:
                    s.y = (starty - speed * st) % 800
                else:
                    s.y = (starty + speed * st) % 800
            return 0
label intro:
    $ RPCUpdate("The Void", "launcher")
    scene DKBG
    show expression (ManaSparkle().sm) as flare
    show DKSD at left
    with Dissolve(1.0)
    evil "{cps=80}Look at this... All this mana... Doesn't it look peaceful?{/cps}"
    evil "{cps=80}What do you think that would happen if I mess with it... like this?!{/cps}{nw}"
    hide flare
    show expression (ManaSparkle(spd=100).sm) as flare behind DKSD
    with None
    evil "What do you think that would happen if I mess with it... like this?!{fast}{nw}" with vpunch
    evil "What do you think that would happen if I mess with it... like this?!{fast}{nw}" with hpunch
    evil "What do you think that would happen if I mess with it... like this?!{fast}{nw}" with vpunch
    evil "What do you think that would happen if I mess with it... like this?!{fast}" with hpunch
    evil "{cps=80}...What? No, you cannot stop me.{/cps}"
    evil "{i}*evil grin*{/i} {cps=80}Hey, let's play a game.{/cps}"
    evil "{cps=80}I'll shatter your Soul and I want see if you can catch me!{/cps}"
    evil "{cps=80}HAHAHAHAHAHA--{/cps}{w=.5}{nw}"
    hide flare with dissolve
    show black behind DKSD with dissolve
    scene black with None # fade out to black
    evil "HAHAHAHAHAHA{fast}{cps=80}HAHAHAHAHAHAHAH!{/cps}"
    window hide
    show MLP at truecenter with Dissolve(1.0) # TODO: Locale
    pause 2.5
    scene black with Dissolve(1.0)
    show expression (ManaSparkle(spd=10, multi=False).sm) as flare
    with Dissolve(5.0)
    centered "{color=#fff}{cps=80}Having your soul shattered to pieces, you drift along the void...{p=1.5}\n\
Your soul was shattered, your memories forfeit, but your willpower remained.{p=1.5}\n\
That's right - You have a task to do, a mission to accomplish.{p=1.5}\n\
\"This is not the end.\" You think to yourself.{p=1.5}\n\
So, you dive in the Mirror Lake, allowing your willpower to become part of the worlds which came to be...{/cps}{/color}"
    window hide
    pause 0.5
    hide flare with dissolve
    centered "{color=#fff}{b}Tutorial{/b}\n\n\
In the next screen, you'll be at the Mirror Lake Interface.\nThe worlds are listed to the left, and a description is available at right.\n\
Select any world, and allow your willpower to take form on the world, as one of its inhabitants.\n\
Each world is different from each other, there is no consistency on gameplay rules, art style or history.\n\
\n\
And eventually, your power shall return to you...{/color}{fast}"
    centered "{color=#f35}{b}DISCLAIMER{/b}\n\n\
{color=#fff}The worlds may be operated by different staff, and are in an eternal mutation state.\n\
Be sure to read each subworld specific rules and complete the tutorial to spot the differences!\n\
\n\
Attempt to restore your soul as you try to stop the evil which threatens the multiverse.\n\
Soul Level remains constant regardless of the subworld you're at.{/color}{fast}"
    scene black
    return

#################################################################################
label thevoid:
    $ progress = 0
    $ mySoul = None
    $ renpy.invoke_in_thread(load_souldata)
    scene DKBG
    show expression (ManaSparkle().sm) as flare
    with Dissolve(1.0)
    # Block the main thread until the socket connection is done
    show expression Text(_("{color=#FFF}Loading user data...{/color}")) at truecenter as loader
    with None
    python:
        while progress < 100:
            if responsive:
                sdelay()
            else:
                break
    hide loader with None
    if mySoul is not None:
        ## Setup
        python:
            if persistent.steam and steam.initialized:
                mySoul["name"] = steam.get_persona_name()
            else:
                mySoul["name"] = _("Wanderer")
        ## Loop
        $ loop = True
        while loop:
            call screen souldata()
            if isinstance(_return, str):
                $ renpy.call_in_new_context(_return)
            else:
                $ loop = False
        $ del loop
    scene black with Dissolve(1.5)
    pause 0.15
    return