diff options
-rw-r--r-- | game/register.rpy | 122 | ||||
-rw-r--r-- | game/screens.rpy | 52 | ||||
-rw-r--r-- | game/script.rpy | 52 |
3 files changed, 124 insertions, 102 deletions
diff --git a/game/register.rpy b/game/register.rpy new file mode 100644 index 0000000..f5cd6f9 --- /dev/null +++ b/game/register.rpy @@ -0,0 +1,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 + + diff --git a/game/screens.rpy b/game/screens.rpy index 185ef08..98cc665 100644 --- a/game/screens.rpy +++ b/game/screens.rpy @@ -1707,55 +1707,3 @@ screen input_box(ib_message=_("Please write it down here: ")): size 26 copypaste True -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') - - diff --git a/game/script.rpy b/game/script.rpy index fede461..da20c6f 100644 --- a/game/script.rpy +++ b/game/script.rpy @@ -83,56 +83,6 @@ label start: jump login ############################################################################ -# 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 - # Login procedures label login: $message=login() @@ -204,6 +154,8 @@ label login: $stdout("This server doesn't have a MOTD") # TODO: Daily login rewards screen + jump loop + label loop: # Delete predictions, if possible $ renpy.free_memory() |