test-client-godot/assets/Scripts/Config/connexion.gd
2020-01-24 19:56:51 +01:00

74 lines
2.8 KiB
GDScript

# Manage configuration to connect on khaganat
#
# Copyright (C) 2019 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class connexion:
# var _url_login = "http://http://149.91.80.160/login/r2_login.php"
var _url_login = "https://lirria.khaganat.net/login/r2_login.php"
# var _url_register = "http://149.91.80.160/ams/index.php?page=register"
var _url_register = "http://lirria.khaganat.net/ams/index.php?page=register"
var _language = "fr"
var _valid_certificate = true
func save():
print("[config connexion] Save connexion config")
var config_file = ConfigFile.new()
config_file.set_value("login", "url", _url_login)
config_file.set_value("register", "url", _url_register)
config_file.set_value("global", "valid_certificate", _valid_certificate)
config_file.set_value("global", "language", _language)
config_file.save("user://connexion.cfg")
func _init():
print("[config connexion] Load connexion config")
#var message = load("res://assets/Scripts/Models/nel_login_message.gd")
var config_file = ConfigFile.new()
# /home/<account>/.local/share/godot/app_userdata/Khanat/connexion.cfg
var err = config_file.load("user://connexion.cfg")
if err:
print("Error code when loading player config file khanat.cfg: ", err)
save()
self._url_login = config_file.get_value("login", "url", self._url_login)
self._url_register = config_file.get_value("register", "url", self._url_register)
self._language = config_file.get_value("global", "language", self._language)
self._valid_certificate = config_file.get_value("global", "valid_certificate", self._valid_certificate)
func get_url_login():
return self._url_login
func get_url_register():
return self._url_register
func get_valid_certificate():
return self._valid_certificate
func get_language():
return self._language
func set_url_login(url):
self._url_login = url
func set_url_register(url):
self._url_register = url
func set_valid_certificate(value):
self._valid_certificate = value
func set_language(value):
self._language = value