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
|
########################################################################################
# This file is part of Spheres.
# Copyright (C) 2019 Jesusalva
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
########################################################################################
# Account login & registration (screen & labels)
screen welcome():
#window:
#background Frame("gui/frame.png", 5, 5)
#yalign 0.5
#xalign 0.5
#ypadding 30
#xpadding 30
#xmaximum 0.7
#xminimum 0.7
#yminimum 95
#vbox:
#text (_("Welcome to %s!" % (config.name))) color "#fefefe" yalign 0.0 xalign 0.5 size 32
#null height 0.2
fixed:
image "gfx/nourishedflower.webp":
xalign 0.5
yalign 1.0
label (_("Welcome to %s!" % (config.name))):
style "pref_label"
yalign 0.02
xalign 0.50
text_size 54
text_outlines [ (1, "#000", 0, 0) ]
#color "#fefefe"
#size 32
textbutton _("{size=36}Login{/size}"):
xalign 0.33
yalign 0.15
xpadding 30
ypadding 30
background Frame("gui/frame.png", 5, 5)
action Jump("register_password")
textbutton _("{size=36}Register{/size}"):
xalign 0.67
yalign 0.15
xpadding 30
ypadding 30
background Frame("gui/frame.png", 5, 5)
action Jump("register_email")
textbutton _("{size=36}Preferences{/size}"):
xalign 0.5
yalign 0.25
xpadding 30
ypadding 30
background Frame("gui/frame.png", 5, 5)
action ShowMenu('preferences')
############################################################################
# Registration procedures
# You don't have an account yet
label register_email:
python:
import re
regex = '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$'
email = ""
# Ask player for their email
while email == "":
email=renpy.call_screen("input_box", "Welcome to %s!\nPlease insert your email to register an account: \n{size=24}Your account password will be emailed to you. This is the only way to recover a lost account. You can use an {a=https://www.tempmailaddress.com/}Temporary email{/a} if you wish.{/size}" % (config.name))
if not re.search(regex, email):
email=""
renpy.call_screen("msgbox",
"The email you've entered is not valid.")
# You've inserted a valid email
raw=send_packet("register", """{"email": "%s"}""" % email)
bt=json_decode(raw)
try:
password=bt["password"]
valid=True
except:
# Either a SQL error, or a server error, or a connection error...
# But either way, we can't proceed!
renpy.call_screen("msgbox", "An error happened, maybe this email is already registered.\nPlease try again later.")
valid=False
# An error happened, return to login screen
if not valid:
jump start
# Save data
$ persistent.password=password
jump login
# Registration procedures
# You already have an account and want to recover it
label register_password:
python:
password=""
while password == "":
password=renpy.call_screen("input_box",
"Welcome to %s!\nPlease insert your password: " % (config.name))
if not password.isalnum():
renpy.call_screen("msgbox",
"The password you've entered is not valid.")
password=""
jump login
|