test-client-godot/assets/Scripts/Config/connexion.gd

64 lines
2.6 KiB
GDScript3
Raw Normal View History

2019-11-20 20:20:14 +00:00
# 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 = ""
var _url_register = ""
var _khaganat_host = "localhost"
var _khaganat_port = "40916"
var _language = "FR"
2019-11-20 20:20:14 +00:00
var _valid_certificate = true
2019-11-20 20:20:14 +00:00
func _init():
print("[config connexion] Load connexion config");
2019-11-20 20:20:14 +00:00
#var message = load("res://assets/Scripts/Models/nel_login_message.gd")
var config_file = ConfigFile.new()
2019-11-20 20:20:14 +00:00
# /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)
config_file.set_value("login", "url", "http://149.91.80.160/login/r2_login.php")
config_file.set_value("register", "url", "http://149.91.80.160/ams/index.php?page=register")
config_file.set_value("global", "valid_certificate", false)
config_file.save("user://connexion.cfg")
self._url_login = config_file.get_value("login", "url", "http://172.17.0.3/login/r2_login.php")
self._url_register = config_file.get_value("register", "url", "http://172.17.0.3/login/r2_login.php")
self._khaganat_host = config_file.get_value("server", "host", "172.17.0.3")
self._khaganat_port = config_file.get_value("server", "port", "47851")
self._language = config_file.get_value("global", "language", "fr")
self._valid_certificate = config_file.get_value("global", "valid_certificate", false)
2019-11-20 20:20:14 +00:00
config_file.save("user://connexion.cfg")
func get_khaganat_host():
return self._khaganat_host
func get_khaganat_port():
return int(self._khaganat_port)
2019-11-20 20:20:14 +00:00
func get_url_login():
return self._url_login
2019-11-20 20:20:14 +00:00
func get_url_register():
return self._url_register
2019-11-20 20:20:14 +00:00
func get_valid_certificate():
return self._valid_certificate
func get_language():
return self._language