Compare commits

...

18 commits

Author SHA1 Message Date
eba1314eb3 adding login on gdnative [c++] 2020-01-19 20:13:57 +01:00
e7ba3d0d56 adding debug message 2020-01-05 16:36:41 +01:00
948f45bade merge 2020-01-05 16:19:46 +01:00
a740011745 try to build with gitlab-ci client, doesn't work 2020-01-05 16:16:47 +01:00
be7dbb08b6 adding loader msg.xml and correct message when login/register error are detected 2020-01-05 16:16:07 +01:00
6e5c854107 error typo 2019-12-17 10:01:10 +01:00
d8ccda03c0 adding import 2019-12-16 13:50:51 +01:00
74f4c31a8d adding import for png file 2019-12-16 10:57:07 +01:00
f07103d05e adding settings pannel to update connexion configuration 2019-12-15 21:52:55 +01:00
4e7dc77d95 update setting menu 2019-12-15 00:29:30 +01:00
f351bb3bf6 change to gdnative release 2019-12-12 17:44:10 +01:00
c8d9178937 read msg.xml 2019-12-12 17:32:49 +01:00
6619fd3f0f update network utp communication 2019-12-11 22:27:49 +01:00
fa0e971291 adding low level communication with server khaganat (UDP) 2019-12-10 21:40:32 +01:00
5d6160ee5a remove debug message and adding command to launch game with godot 2019-12-02 23:51:50 +01:00
06430e84ff adding authentification to khanagat [Send login & password with crypted method] 2019-12-02 23:34:04 +01:00
5c4b468da8 adding godot-cpp 2019-12-02 21:41:03 +01:00
d9d913b488 adding register function 2019-11-20 21:20:14 +01:00
102 changed files with 7109 additions and 3830 deletions

10
.gitignore vendored
View file

@ -11,3 +11,13 @@ export_presets.cfg
# System/tool-specific ignores
.directory
*~
# Ignore binary & package
*.bin
*.pck
# Ignore lib gdnaive
libgdnative.*.so
# Ignore temp
temp/

210
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,210 @@
# Configuration for Continous Integration
#
# 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/>.
#
# Example to execute locally:
# gitlab-runner exec docker --kubernetes-memory-limit="10g" --kubernetes-service-memory-limit="10g" --kubernetes-memory-request="10g" --kubernetes-helper-memory-limit="10g" 'Build Client Linux 64'
# gitlab-runner exec docker --timeout=3600 'Build Client Linux 64'
# gitlab-runner exec docker --timeout=3600 --kubernetes-memory-limit="10g" --kubernetes-service-memory-limit="10g" --kubernetes-memory-request="10g" --kubernetes-helper-memory-limit="10g" --docker-volumes $PWD/builds:/builds 'Build Client Linux 64'
stages:
- build
variables:
GODOT_VERSION: '3.1.2'
XDG_CACHE_HOME: '/tmp/cache'
XDG_DATA_HOME: '/tmp/data'
XDG_CONFIG_HOME: '/tmp/config'
DOCKER_GODOT_SOURCE: '/root/workspace/godot/'
Build Client Linux 64 (Ter):
# ERROR: _load: No loader found for resource: res://assets/GUI/images/Login-Khanat-background.png
stage: build
tags:
- Docker
image: ubuntu:xenial
script:
- export -p WORKDIR=$PWD
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y scons git g++ wget unzip ca-certificates python python-openssl
- git submodule update --init --recursive
- mkdir -p $DOCKER_GODOT_SOURCE $XDG_CACHE_HOME $XDG_DATA_HOME $XDG_CONFIG_HOME $XDG_DATA_HOME/godot/app_userdata/Khanat/logs
- wget -q https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_linux_server.64.zip
- wget -q https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_export_templates.tpz
- mkdir -p ~/.cache ~/.config/godot ~/.local/share/godot/templates/${GODOT_VERSION}.stable
- unzip Godot_v${GODOT_VERSION}-stable_linux_server.64.zip
- mv Godot_v${GODOT_VERSION}-stable_linux_server.64 /usr/local/bin/godot
- unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz
- mv templates/* ~/.local/share/godot/templates/${GODOT_VERSION}.stable
- rm -f Godot_v${GODOT_VERSION}-stable_export_templates.tpz Godot_v${GODOT_VERSION}-stable_linux_server.64.zip
# - godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json
- scons -j$(nproc) -C godot-cpp platform=linux target=release generate_bindings=yes custom_api_file=godot_headers/api.json bits=64
- scons -j$(nproc) -C gdnative platform=linux target=release bits=64
- /usr/local/bin/godot --editor --quit
- /usr/local/bin/godot --quit -v --path $WORKDIR --export khaganat.linux.64 khaganat.linux64.bin
- ls -la assets/GUI/images/
- ls -la .import/ || echo ""
- ls -la || echo ""
artifacts:
name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-client-linux-64"
paths:
- khaganat.linux64.*
when: manual
Build Client Linux 64 (Bis):
# ERROR: _load: No loader found for resource: res://assets/GUI/images/Login-Khanat-background.png
stage: build
tags:
- Docker
image: amd64/debian:10
script:
- export -p WORKDIR=$PWD
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y scons git g++ wget unzip
#- DEBIAN_FRONTEND=noninteractive apt-get install -y libxcursor1 libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1
#- DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libfreetype6-dev libudev-dev libxi-dev libxrandr-dev yasm
- DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libfreetype6-dev libssl-dev libudev-dev libxi-dev libxrandr-dev mingw-w64 git unzip upx vim wget ca-certificates
- git submodule update --init --recursive
- mkdir -p $DOCKER_GODOT_SOURCE $XDG_CACHE_HOME $XDG_DATA_HOME $XDG_CONFIG_HOME
- git clone -b $GODOT_VERSION --single-branch https://github.com/godotengine/godot.git $DOCKER_GODOT_SOURCE
- wget -q -P /tmp https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_export_templates.tpz
- mkdir -p ~/.cache ~/.config/godot ~/.local/share/godot/templates/${GODOT_VERSION}.stable ~/.godot/templates
- unzip /tmp/Godot_v${GODOT_VERSION}-stable_export_templates.tpz -d /tmp
- mv /tmp/templates/* ~/.local/share/godot/templates/${GODOT_VERSION}.stable
- ln -s ~/.local/share/godot/templates/${GODOT_VERSION}.stable ~/.godot/templates
- wget -q -P /tmp https://downloads.tuxfamily.org/godotengine/${DOCKER_GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_x11.64.zip
# - godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json
- scons -j$(nproc) -C godot-cpp platform=linux target=release generate_bindings=yes custom_api_file=godot_headers/api.json bits=64
- scons -j$(nproc) -C gdnative platform=linux target=release bits=64
- ls -la gdnative/bin
- wget -q -P /tmp https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_x11.64.zip
- unzip /tmp/Godot_v${GODOT_VERSION}-stable_x11.64.zip -d /tmp
- mv /tmp/Godot_v${GODOT_VERSION}-stable_x11.64 /usr/local/bin/godot
# Start Audio server
- pulseaudio -D
# Start X11 server (and launch build)
- pwd
- echo "WORKDIR:$WORKDIR"
- mkdir -p .import /tmp/data/godot/app_userdata/Khanat/logs
- ls -la assets/GUI/images/
- ls -la .import/ || echo ""
- ls $WORKDIR/assets/GUI/images/Login-Khanat-background.png
- xvfb-run -a -n 99 --server-args="-ac -screen 0 1024x768x24 +extension GLX" /usr/local/bin/godot --editor --quit
- ls -la assets/GUI/images/
- ls -la .import/ || echo ""
- xvfb-run -a -n 99 --server-args="-ac -screen 0 1024x768x24 +extension GLX" /usr/local/bin/godot --quit -v --path $WORKDIR --export khaganat.linux.64 khaganat.linux64.bin
- ls -la assets/GUI/images/
- ls -la .import/ || echo ""
- ls -la || echo ""
artifacts:
name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-client-linux-64"
paths:
- khaganat.linux64.*
when: manual
Build Client Linux 64:
# ERROR: _load: No loader found for resource: res://assets/GUI/images/Login-Khanat-background.png
stage: build
tags:
- Docker
image: amd64/debian:10
script:
- export -p WORKDIR=$PWD
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y scons git g++ wget unzip
#- DEBIAN_FRONTEND=noninteractive apt-get install -y libxcursor1 libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1
#- DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libfreetype6-dev libudev-dev libxi-dev libxrandr-dev yasm
- DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb libxcursor1 libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1 mesa-utils libgl1-mesa-dri libasound2 libasound2-plugins alsa-utils alsa-oss pulseaudio pulseaudio-utils
- DEBIAN_FRONTEND=noninteractive apt-get install -y xterm libxcursor1 xcursor-themes icon-slicer libpulse0
- DEBIAN_FRONTEND=noninteractive apt-get install -y lxde strace
- DEBIAN_FRONTEND=noninteractive apt-get install -y task-gnome-desktop
- DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb libxcursor-dev libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1-mesa-glx
- DEBIAN_FRONTEND=noninteractive apt-get install -y x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps
# libpng-tools libpng16-16 libpng-dev build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libfreetype6-dev libudev-dev libxi-dev libxrandr-dev yasm
- git submodule update --init --recursive
# - godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json
- scons -j$(nproc) -C godot-cpp platform=linux target=release generate_bindings=yes custom_api_file=godot_headers/api.json bits=64
- scons -j$(nproc) -C gdnative platform=linux target=release bits=64
- ls -la gdnative/bin
- wget -q -P /tmp https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_x11.64.zip
- unzip /tmp/Godot_v${GODOT_VERSION}-stable_x11.64.zip -d /tmp
- mv /tmp/Godot_v${GODOT_VERSION}-stable_x11.64 /usr/local/bin/godot
# Start Audio server
- pulseaudio -D
# Start X11 server (and launch build)
- pwd
- echo "WORKDIR:$WORKDIR"
- mkdir -p .import /tmp/data/godot/app_userdata/Khanat/logs
- ls -la assets/GUI/images/
- ls -la .import/ || echo ""
- ls $WORKDIR/assets/GUI/images/Login-Khanat-background.png
- xvfb-run -a -n 99 --server-args="-ac -screen 0 1024x768x24 +extension GLX +render -noreset" strace /usr/local/bin/godot -v --editor --quit
- ls -la assets/GUI/images/
- ls -la .import/ || echo ""
#- xvfb-run -a -n 99 --server-args="-ac -screen 0 1024x768x24 +extension GLX +render -noreset" /usr/local/bin/godot --quit -v --path $WORKDIR --export khaganat.linux.64 khaganat.linux64.bin
#- ls -la assets/GUI/images/
#- ls -la .import/ || echo ""
#- ls -la || echo ""
#- xvfb-run -a -n 99 --server-args="-ac -screen 0 1024x768x24 +extension GLX +render -noreset" xdpyinfo -display :99
artifacts:
name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-client-linux-64"
paths:
- khaganat.linux64.*
when: manual
Build Client Linux 64 (headless method):
# Other method to build, but currently doesn't work -> "X11 Display is not available"
stage: build
tags:
- Docker
image: amd64/debian:10
script:
- export -p WORKDIR=$PWD
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y scons git g++ wget unzip
#- DEBIAN_FRONTEND=noninteractive apt-get install -y libxcursor1 libxinerama1 libxrandr2 libxi6 libasound2 libpulse0 libgl1
#- DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libfreetype6-dev libudev-dev libxi-dev libxrandr-dev yasm
- git submodule update --init --recursive
# - godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json
- scons -j$(nproc) -C godot-cpp platform=linux target=release generate_bindings=yes custom_api_file=godot_headers/api.json bits=64
- scons -j$(nproc) -C gdnative platform=linux target=release bits=64
- wget -q -P /tmp https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip
- wget -q -P /tmp https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_export_templates.tpz
- mkdir -p ~/.cache ~/.config/godot ~/.local/share/godot/templates/${GODOT_VERSION}.stable
- unzip /tmp/Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip -d /tmp
- mv /tmp/Godot_v${GODOT_VERSION}-stable_linux_headless.64 /usr/local/bin/godot
- unzip /tmp/Godot_v${GODOT_VERSION}-stable_export_templates.tpz -d /tmp
- mv /tmp/templates/* ~/.local/share/godot/templates/${GODOT_VERSION}.stable
- rm -f Godot_v${GODOT_VERSION}-stable_export_templates.tpz Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip
- /usr/local/bin/godot -v --path . --export khaganat.linux.64 khaganat.linux64.bin
# - /usr/local/bin/godot -v --no-window --disable-render-loop --path . --export khaganat.linux.64 khaganat.linux64.bin
artifacts:
name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-client-linux-64"
paths:
- khaganat.linux64.*
when: manual

4
.gitmodules vendored Normal file
View file

@ -0,0 +1,4 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/GodotNativeTools/godot-cpp
branch = 3.1

View file

@ -0,0 +1,90 @@
# Build
Before build and launch client, we need build godot-cpp (lib to connect c++ code to godot engine) and build crypt (c++ module use to authentification with khaganat)
## Build godot-cpp
### Initialize
Load git submodule (godot-cpp & godot_header)
```
git submodule update --init --recursive
```
### Build on 64bits
```
godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json
scons -C godot-cpp platform=linux generate_bindings=yes custom_api_file=godot_headers/api.json bits=64
```
### Build on 32bits
```
godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json
scons -C godot-cpp platform=linux generate_bindings=yes custom_api_file=godot_headers/api.json bits=32
```
## Build gdnative (crypt / bitstream / bitset)
### Build on 64bits
```
scons -C gdnative platform=linux bits=64 target=debug
scons -C gdnative platform=linux bits=64 target=release
```
### Build on 32bits
```
scons -C gdnative platform=linux bits=32 target=debug
scons -C gdnative platform=linux bits=64 target=release
```
## Package client khaganat
### Configure export
Configure on project export (or edit file export_presets.cfg)
Ex.: export_presets.cfg
```
[preset.0]
name="khaganat.linux.64"
platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.0.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=true
custom_template/release=""
custom_template/debug=""
```
### Generate package
```
godot --path . --export khaganat.linux.64 khaganat.linux64.bin
```
## Launch client khaganat
### With godot
```
godot login_scene/login_scene.tsc
```

6
TODO Normal file
View file

@ -0,0 +1,6 @@
* Create a global scons configuration to launch all build
* Build project with godot command line (perhaps with scons)
* Disable login button when we have launch a login (or show other dialog with message wait [buton cancel if we want abort login])
* Execute next step - UDP module to communicate with khaganat
* Configuration panel to define all connexion parameter
* Path : check version and patch all file (we need generate path file for godot and method to reload data)

View file

@ -16,7 +16,7 @@ func _ready():
action_name = self.name
current_keyboard = $keyboard
load_from_config()
var key_found = false
var key_alt_found = false
for event in InputMap.get_action_list( action_name ):
@ -30,14 +30,14 @@ func _ready():
key_alt_found = true
elif event is InputEventJoypadButton:
$joypad.text = Input.get_joy_button_string( event.button_index )
$keyboard.connect( "pressed", self, "wait_for_input" )
$keyboard_alt.connect( "pressed", self, "wait_for_input_alt" )
$joypad.connect( "pressed", self, "wait_for_input" )
set_process_input(false)
func _enter_tree():
if not self.has_node( "description" ):
var new_label = Label.new()
new_label.name = "description"
@ -46,7 +46,7 @@ func _enter_tree():
new_label.size_flags_horizontal = SIZE_EXPAND_FILL
new_label.size_flags_vertical = SIZE_EXPAND
self.add_child( new_label )
new_label.set_owner( self )
new_label.set_owner( self )
if not self.has_node( "keyboard" ):
var new_button = Button.new()
@ -55,7 +55,7 @@ func _enter_tree():
new_button.size_flags_horizontal = SIZE_EXPAND_FILL
new_button.size_flags_vertical = SIZE_EXPAND
self.add_child( new_button )
new_button.set_owner( self )
new_button.set_owner( self )
if not self.has_node( "keyboard_alt" ):
var new_button = Button.new()
@ -64,7 +64,7 @@ func _enter_tree():
new_button.size_flags_horizontal = SIZE_EXPAND_FILL
new_button.size_flags_vertical = SIZE_EXPAND
self.add_child( new_button )
new_button.set_owner( self )
new_button.set_owner( self )
#
#
if not self.has_node( "joypad" ):
@ -74,8 +74,8 @@ func _enter_tree():
new_button_joypad.size_flags_horizontal = SIZE_EXPAND_FILL
new_button_joypad.size_flags_vertical = SIZE_EXPAND
self.add_child( new_button_joypad )
new_button_joypad.set_owner( self )
new_button_joypad.set_owner( self )
func get_event_with_modifier_from_string( scancode, type ):
if type == "keyboard":
var new_event = InputEventKey.new()
@ -94,28 +94,28 @@ func get_event_with_modifier_from_string( scancode, type ):
new_event.scancode = OS.find_scancode_from_string( scancode )
return new_event
elif type == "joypad":
elif type == "joypad":
var new_event = InputEventJoypadButton.new()
new_event.button_index = Input.get_joy_button_index_from_string( scancode )
return new_event
return null
func load_from_config():
var config = ConfigFile.new()
var err = config.load( config_file )
if err:# Assuming that file is missing, generate default config
config.save( config_file )
else:
# on initialise l'entrée, si elle n'existe pas déjà, par la valeur par defaut du projet.
if not config.has_section_key("keyboard", action_name):
for event in InputMap.get_action_list( action_name ):
if event is InputEventKey:
var scancode = OS.get_scancode_string( event.get_scancode_with_modifiers() )
config.set_value("keyboard", action_name, scancode)
break
break
# on initialise l'entrée alternative, si elle n'existe pas déjà, par la valeur par defaut du projet.
var is_first = true
if not config.has_section_key("keyboard_alt", action_name):
@ -126,19 +126,19 @@ func load_from_config():
break
if is_first and event is InputEventKey:
is_first = false
if not config.has_section_key("joypad", action_name):
for event in InputMap.get_action_list( action_name ):
if event is InputEventJoypadButton:
var scancode = Input.get_joy_button_string( event.button_index )
config.set_value("joypad", action_name, scancode)
break
break
# On efface toutes les touches de clavier de l'InputMap correspondants à l'action en cours.
for old_event in InputMap.get_action_list( action_name ):
if old_event is InputEventKey or old_event is InputEventJoypadButton:
InputMap.action_erase_event(action_name, old_event)
# on recupere les touches du fichier de config et on les ajoutes à l'input map.
if config.has_section("keyboard"):
var action_found = false
@ -148,7 +148,7 @@ func load_from_config():
var event = get_event_with_modifier_from_string( config.get_value("keyboard", action_name), "keyboard")
InputMap.action_add_event(action_name, event)
break
if config.has_section("keyboard_alt"):
var action_found = false
for action in config.get_section_keys("keyboard_alt"):
@ -157,7 +157,7 @@ func load_from_config():
var event = get_event_with_modifier_from_string( config.get_value("keyboard_alt", action_name), "keyboard")
InputMap.action_add_event(action_name, event)
break
if config.has_section("joypad"):
var action_found = false
for action in config.get_section_keys("joypad"):
@ -168,35 +168,35 @@ func load_from_config():
if old_event is InputEventJoypadButton:
InputMap.action_erase_event(action_name, old_event)
InputMap.action_add_event(action_name, event)
config.save( config_file )
config.save( config_file )
func save_to_config(section, key, value):
var config = ConfigFile.new()
var err = config.load( config_file )
if err:
print("Error code when loading config file: ", err)
print("[input_map_button_node:save_to_config] Error code when loading config file: ", err)
else:
config.set_value(section, key, value)
config.save( config_file )
# Input management
func wait_for_input():
current_keyboard = $keyboard
set_process_input(true)
func wait_for_input_alt():
current_keyboard = $keyboard_alt
set_process_input(true)
# Input management
func _input(event):
if event is InputEventKey and not event.pressed and not event.is_echo():
var input_string = OS.get_scancode_string( event.scancode )
if not event.is_action("ui_cancel") \
and not input_string == "Meta" \
and not input_string == "Control" \
@ -216,8 +216,8 @@ func _input(event):
if event.shift:
current_keyboard.text += "Shift+"
current_keyboard.text += input_string
var change_first_key = true
if current_keyboard.name == "keyboard_alt":
change_first_key = false
@ -233,17 +233,17 @@ func _input(event):
InputMap.action_add_event(action_name, event)
save_to_config(current_keyboard.name, action_name, current_keyboard.text)
elif event is InputEventJoypadButton and not event.pressed and not event.is_echo():
var input_string = Input.get_joy_button_string( event.button_index )
get_tree().set_input_as_handled()
set_process_input( false )
$joypad.text = input_string
for old_event in InputMap.get_action_list( action_name ):
if old_event is InputEventJoypadButton:
InputMap.action_erase_event(action_name, old_event)
InputMap.action_add_event(action_name, event)
save_to_config("joypad", action_name, $joypad.text)

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-87ce5392dc9cad89ee4d4b674c3718a9.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/ui_window/icon.png"
dest_files=[ "res://.import/icon.png-87ce5392dc9cad89ee4d4b674c3718a9.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -32,16 +32,16 @@ func add_child_to_content( node):
# else:
# .add_child( node )
# prints(self.get_name()+" just fathered", node.get_name())
func add_window_part( node ):
add_child( node )
func set_mouse_pass_to_children( node ):
for child in node.get_children():
set_mouse_pass_to_children( child )
if node is Control:
node.mouse_filter = MOUSE_FILTER_PASS
#func _ready():
func _enter_tree():
########
@ -49,7 +49,7 @@ func _enter_tree():
# The interal elements structure is:
# self - MarginContainer
# background - NinePatchRect
# parts - VBoxContainer
# parts - VBoxContainer
# header_box - MarginContainer
# header - HBoxContainer
# quit - TextureButton
@ -68,13 +68,13 @@ func _enter_tree():
# self
self.size_flags_horizontal = SIZE_EXPAND
self.size_flags_vertical = SIZE_EXPAND
self.set( "custom_constants/margin_right", 0)
self.set( "custom_constants/margin_top", 0)
self.set( "custom_constants/margin_left", 0)
self.set( "custom_constants/margin_bottom", 0)
self.connect ( "gui_input", self, "_on_window_gui_input" )
###
###
@ -85,30 +85,33 @@ func _enter_tree():
background.name = "background"
if not background_texture:
var background_image = Image.new()
if not background_image.load( "res://addons/ui_window/background_default.jpg" ) == OK :
var stream_texture = load('res://addons/ui_window/background_default.jpg')
if not stream_texture :
print("Erreur lors du chargement de l'image: "+str("res://addons/ui_window/background_default.jpg") )
else:
background_image = stream_texture.get_data()
background.texture = ImageTexture.new()
background.texture.create_from_image( background_image )
else:
background.texture = background_texture
background.texture.flags = Texture.FLAG_FILTER | Texture.FLAG_REPEAT
background.axis_stretch_horizontal = NinePatchRect.AXIS_STRETCH_MODE_TILE
background.axis_stretch_vertical = NinePatchRect.AXIS_STRETCH_MODE_TILE
background.size_flags_horizontal = SIZE_EXPAND_FILL
background.size_flags_vertical = SIZE_EXPAND_FILL
background.region_rect = Rect2( 0, 0, 0, 0 )
background.patch_margin_left = 4
background.patch_margin_top = 32
background.patch_margin_right = 4
background.patch_margin_bottom = 4
background.self_modulate = background_color
self.add_window_part( background )
# background.set_owner( self )
# background.set_owner( self )
###
###
# parts
@ -119,7 +122,7 @@ func _enter_tree():
parts.size_flags_horizontal = SIZE_EXPAND_FILL
parts.size_flags_vertical = SIZE_EXPAND_FILL
self.add_window_part( parts )
# parts.set_owner( self )
# parts.set_owner( self )
###
###
# header_box
@ -129,18 +132,18 @@ func _enter_tree():
header_box.name = "header_box"
header_box.size_flags_horizontal = SIZE_EXPAND_FILL
header_box.size_flags_vertical = SIZE_SHRINK_CENTER
header_box.set( "custom_constants/margin_right", 4)
header_box.set( "custom_constants/margin_top", 4)
header_box.set( "custom_constants/margin_left", 4)
header_box.set( "custom_constants/margin_bottom", 4)
if is_movable:
header_box.mouse_default_cursor_shape = CURSOR_MOVE
parts.add_child( header_box )
# header_box.set_owner( parts )
# header_box.set_owner( parts )
header_box.connect ( "gui_input", self, "_on_Header_gui_input" )
###
###
###
# header
var header
@ -152,7 +155,7 @@ func _enter_tree():
if is_movable:
header.mouse_default_cursor_shape = CURSOR_MOVE
header_box.add_child( header )
# header.set_owner( header_box )
# header.set_owner( header_box )
###
###
# quit
@ -162,15 +165,16 @@ func _enter_tree():
quit_button.name = "quit"
quit_button.size_flags_horizontal = SIZE_SHRINK_END
quit_button.size_flags_vertical = SIZE_SHRINK_CENTER
var tex_quit = ImageTexture.new()
var img_quit = Image.new()
img_quit.load( "res://assets/GUI/images/button_quit.png" )
var stream_texture = load( "res://assets/GUI/images/button_quit.png")
img_quit = stream_texture.get_data()
tex_quit.create_from_image( img_quit )
quit_button.texture_normal = tex_quit
header.add_child( quit_button )
# quit_button.set_owner( header )
# quit_button.set_owner( header )
quit_button.connect ( "pressed", self, "_on_Quit_pressed" )
###
# close
@ -180,15 +184,16 @@ func _enter_tree():
close_button.name = "close"
close_button.size_flags_horizontal = SIZE_SHRINK_END
close_button.size_flags_vertical = SIZE_SHRINK_CENTER
var tex_close = ImageTexture.new()
var img_close = Image.new()
img_close.load( "res://assets/GUI/images/button_close.png" )
var stream_texture = load("res://assets/GUI/images/button_close.png")
img_close = stream_texture.get_data()
tex_close.create_from_image( img_close )
close_button.texture_normal = tex_close
header.add_child( close_button )
# close_button.set_owner( header )
# close_button.set_owner( header )
close_button.connect ( "pressed", self, "_on_Close_pressed" )
###
# open
@ -198,15 +203,16 @@ func _enter_tree():
open_button.name = "open"
open_button.size_flags_horizontal = SIZE_SHRINK_END
open_button.size_flags_vertical = SIZE_SHRINK_CENTER
var tex_open = ImageTexture.new()
var img_open = Image.new()
img_open.load( "res://assets/GUI/images/button_open.png" )
var stream_texture = load("res://assets/GUI/images/button_open.png")
img_open = stream_texture.get_data()
tex_open.create_from_image( img_open )
open_button.texture_normal = tex_open
open_button.visible = false
header.add_child( open_button )
# open_button.set_owner( header )
# open_button.set_owner( header )
open_button.connect ( "pressed", self, "_on_Open_pressed" )
###
###
@ -221,7 +227,7 @@ func _enter_tree():
if is_movable:
title_label.mouse_default_cursor_shape = CURSOR_MOVE
header.add_child( title_label )
# title_label.set_owner( header )
# title_label.set_owner( header )
###
###
# Content
@ -236,8 +242,8 @@ func _enter_tree():
content_box.set( "custom_constants/margin_left", 8)
content_box.set( "custom_constants/margin_bottom", 8)
parts.add_child( content_box )
# content_box.set_owner( parts )
###
# content_box.set_owner( parts )
###
###
# content_box/scroll_container
var content_scroll_container
@ -248,7 +254,7 @@ func _enter_tree():
content_scroll_container.size_flags_vertical = SIZE_FILL
content_scroll_container.scroll_deadzone = 0
content_box.add_child( content_scroll_container )
# content_scroll_container.set_owner( content_box )
# content_scroll_container.set_owner( content_box )
###
###
# content
@ -259,10 +265,10 @@ func _enter_tree():
content.size_flags_horizontal = SIZE_EXPAND_FILL
content.size_flags_vertical = SIZE_EXPAND_FILL
content_scroll_container.add_child( content )
# content.set_owner( content_scroll_container )
###
# content.set_owner( content_scroll_container )
###
###
# Footer
var footer_box
@ -276,8 +282,8 @@ func _enter_tree():
footer_box.set( "custom_constants/margin_left", content_margin.position.x)
footer_box.set( "custom_constants/margin_bottom", content_margin.size.y)
parts.add_child( footer_box )
# footer_box.set_owner( parts )
###
# footer_box.set_owner( parts )
###
###
# footer_box/footer
var footer
@ -287,7 +293,7 @@ func _enter_tree():
footer.size_flags_horizontal = SIZE_EXPAND_FILL
footer.size_flags_vertical = SIZE_EXPAND_FILL
footer_box.add_child( footer )
# footer.set_owner( footer_box )
# footer.set_owner( footer_box )
###
###
# footer_label
@ -308,27 +314,28 @@ func _enter_tree():
resize_button.name = "resize"
resize_button.size_flags_horizontal = SIZE_FILL | SIZE_SHRINK_END
resize_button.size_flags_vertical = SIZE_SHRINK_END
var tex_resize = ImageTexture.new()
var img_resize = Image.new()
img_resize.load( "res://assets/GUI/images/button_resize.png" )
var stream_texture = load("res://assets/GUI/images/button_resize.png")
img_resize = stream_texture.get_data()
tex_resize.create_from_image( img_resize )
resize_button.texture_normal = tex_resize
resize_button.mouse_default_cursor_shape = CURSOR_FDIAGSIZE
resize_button.action_mode = Button.ACTION_MODE_BUTTON_PRESS
resize_button.action_mode = Button.ACTION_MODE_BUTTON_PRESS
footer.add_child( resize_button )
# resize_button.set_owner( footer )
# resize_button.set_owner( footer )
resize_button.connect ( "pressed", self, "_on_Resize_pressed" )
###er_label.set_owner( footer )
###er_label.set_owner( footer )
###
current_rect_size = self.rect_min_size
if is_borderless:
$background.region_rect = Rect2( $background.patch_margin_left-1
, $background.patch_margin_top-1
, 256-($background.patch_margin_left+$background.patch_margin_right)+2
, 256-($background.patch_margin_top+$background.patch_margin_bottom)+2 )
, 256-($background.patch_margin_top+$background.patch_margin_bottom)+2 )
$background.patch_margin_left = 1
$background.patch_margin_top = 1
$background.patch_margin_right = 1
@ -338,10 +345,10 @@ func _enter_tree():
open_button.visible = false
quit_button.visible = false
title_label.visible = false
if not is_resizable:
if not has_footer:
footer_box.visible = false
@ -355,21 +362,21 @@ func _ready():
if child.name.begins_with( "footer_" ):
if footer_box.get_node("footer").has_node("footer_label"):
footer_box.get_node("footer").remove_child( footer_box.get_node("footer").get_node("footer_label") )
self.remove_child( child )
get_footer().add_child( child )
get_footer().move_child( child, 0 )
else:
self.remove_child( child )
get_content().add_child( child )
set_mouse_pass_to_children( self )
func _process(delta):
if size_changed:
self.rect_size = Vector2( clamp( self.rect_size.x, min_size.x, self.rect_size.x ), clamp( self.rect_size.y, min_size.y, self.rect_size.y ) )
size_changed = false
func _on_Window_mouse_entered():
print("mouse_entered")
@ -403,8 +410,8 @@ func close():
footer_box.visible = false
current_rect_size = self.rect_size
self.rect_size = Vector2( 0, 0 )
func _on_Close_pressed():
close()
@ -421,7 +428,7 @@ func open():
content_box.visible = true
footer_box.visible = true
self.rect_size = current_rect_size
func _on_Open_pressed():
open()
@ -429,34 +436,34 @@ func _on_Resize_pressed():
is_resizing = true
func _input( event ):
if is_resizable:
if is_resizable:
if is_resizing and event is InputEventMouseButton and not event.pressed:
is_resizing = false
if event is InputEventMouseMotion and is_resizing:
var delta = event.relative
self.rect_size += delta
size_changed = true
func check_if_clicked( event ):
if not is_moving and event is InputEventMouseButton and event.is_pressed() and not event.is_echo() and event.button_index == 1 :
emit_signal( "window_clicked", self )
func _on_Header_gui_input( event ):
check_if_clicked( event )
if is_movable:
if is_movable:
if is_moving and event is InputEventMouseButton and not event.pressed:
is_moving = false
is_moving = false
elif not is_moving and event is InputEventMouseButton and event.pressed:
is_moving = true
is_moving = true
if event is InputEventMouseMotion and is_moving:
var delta = event.relative
self.rect_position += delta
func _on_window_gui_input( event ):
check_if_clicked( event )
func load_from_file( config_file ):
if config_file.has_section( self.name ):
self.rect_position = config_file.get_value( self.name, "position" )
@ -471,20 +478,19 @@ func load_from_file( config_file ):
func save_to_file( config_file ):
var is_open = content_box.visible
config_file.set_value(self.name, "position", self.rect_position)
if not is_open:
config_file.set_value(self.name, "size", current_rect_size)
else:
config_file.set_value(self.name, "size", self.rect_size)
if is_open:
config_file.set_value(self.name, "opened", true)
else:
config_file.set_value(self.name, "opened", false)
config_file.set_value(self.name, "borderless", is_borderless)

1165
assets/Definition/msg.xml Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-background-buttons.png-b443f38983d255c1fe39b9816237594c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-background-buttons.png"
dest_files=[ "res://.import/Login-Khanat-background-buttons.png-b443f38983d255c1fe39b9816237594c.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-background-loading.png-3aefd7172e23bd240bf5fe6dea6aa8ff.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-background-loading.png"
dest_files=[ "res://.import/Login-Khanat-background-loading.png-3aefd7172e23bd240bf5fe6dea6aa8ff.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-background.png-90c44773e31509ae9caf199d500bea34.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-background.png"
dest_files=[ "res://.import/Login-Khanat-background.png-90c44773e31509ae9caf199d500bea34.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-help-button.png-3bd9e471d0680a7c13ce0bd74f685cac.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-help-button.png"
dest_files=[ "res://.import/Login-Khanat-help-button.png-3bd9e471d0680a7c13ce0bd74f685cac.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-quit-button.png-8df8b5e58391c05b41172a9ef929ce93.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-quit-button.png"
dest_files=[ "res://.import/Login-Khanat-quit-button.png-8df8b5e58391c05b41172a9ef929ce93.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-settings-button.png-74be5eccf6fa82bf3f6d3cb2ccad7296.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-settings-button.png"
dest_files=[ "res://.import/Login-Khanat-settings-button.png-74be5eccf6fa82bf3f6d3cb2ccad7296.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-sound-button.png-13323f06c657d85fcbfdb6224dc4e60a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-sound-button.png"
dest_files=[ "res://.import/Login-Khanat-sound-button.png-13323f06c657d85fcbfdb6224dc4e60a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Login-Khanat-sound-muted-button.png-d1b2487aa993a007b3a8f0293531dc10.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/Login-Khanat-sound-muted-button.png"
dest_files=[ "res://.import/Login-Khanat-sound-muted-button.png-d1b2487aa993a007b3a8f0293531dc10.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/background_test.jpg-8677a1651113ccad58d76a4573b2a2e0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/background_test.jpg"
dest_files=[ "res://.import/background_test.jpg-8677a1651113ccad58d76a4573b2a2e0.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/background_test.png-973321a0ca479f0fb332b30e7cf911fc.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/background_test.png"
dest_files=[ "res://.import/background_test.png-973321a0ca479f0fb332b30e7cf911fc.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_light_off.png-220ca88bdfd86c5038a45b4c0051df25.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_light_off.png"
dest_files=[ "res://.import/button_light_off.png-220ca88bdfd86c5038a45b4c0051df25.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_light_on.png-a95f65fe335836dd89cd535b8703f319.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_light_on.png"
dest_files=[ "res://.import/button_light_on.png-a95f65fe335836dd89cd535b8703f319.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_turn_left.png-907c7a4fb562a0ce94149506587592d5.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_turn_left.png"
dest_files=[ "res://.import/button_turn_left.png-907c7a4fb562a0ce94149506587592d5.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_turn_left_up.png-e2db0733cebcda505a059cb34b4777a3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_turn_left_up.png"
dest_files=[ "res://.import/button_turn_left_up.png-e2db0733cebcda505a059cb34b4777a3.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_turn_right.png-c995de30a17ee7920c641590a08d2aa3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_turn_right.png"
dest_files=[ "res://.import/button_turn_right.png-c995de30a17ee7920c641590a08d2aa3.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_turn_right_up.png-66ed45648279c657a6cf9b60ce26f86c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_turn_right_up.png"
dest_files=[ "res://.import/button_turn_right_up.png-66ed45648279c657a6cf9b60ce26f86c.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_zoom_in.png-b2671e5d7cbdb76b38a0c37845578b52.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_zoom_in.png"
dest_files=[ "res://.import/button_zoom_in.png-b2671e5d7cbdb76b38a0c37845578b52.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_zoom_out.png-3d6fd29bd17d51fc3516aaf5648abdd5.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/button_zoom_out.png"
dest_files=[ "res://.import/button_zoom_out.png-3d6fd29bd17d51fc3516aaf5648abdd5.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/new_char.png-c3b9e7f0a6260c72c54f884c80215754.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/new_char.png"
dest_files=[ "res://.import/new_char.png-c3b9e7f0a6260c72c54f884c80215754.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/register-Khanat-background.png-70c2de866b921e60f82fe2a694d3555a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/register-Khanat-background.png"
dest_files=[ "res://.import/register-Khanat-background.png-70c2de866b921e60f82fe2a694d3555a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/settings-Khanat-background.png-11aa6eb3d995b8a062c2eb037178fca3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GUI/images/settings-Khanat-background.png"
dest_files=[ "res://.import/settings-Khanat-background.png-11aa6eb3d995b8a062c2eb037178fca3.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

View file

@ -3,68 +3,16 @@
[ext_resource path="res://assets/Game/textures/fire_01.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = false
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 2
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.390625, 0.390625, 0.390625, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = true
emission = Color( 1, 0.886353, 0.617188, 1 )
emission_energy = 1.0
emission_operator = 0
emission_on_uv2 = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Emission", "Flags", "Parameters", "Particles Anim" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 0.4, 0.4 )

View file

@ -1,65 +1,31 @@
[gd_resource type="ParticlesMaterial" load_steps=5 format=2]
[sub_resource type="Curve" id=1]
min_value = -360.0
max_value = 360.0
bake_resolution = 100
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.959245, 38.6719 ), 89.2918, 89.2918, 0, 0, Vector2( 1, 324.844 ), 17644.8, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=2]
flags = 4
width = 2048
curve = SubResource( 1 )
[sub_resource type="Gradient" id=3]
offsets = PoolRealArray( 0, 0.0788644, 0.514196, 0.851735, 1 )
colors = PoolColorArray( 1, 1, 1, 0.359098, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.911608, 1, 1, 1, 0 )
[sub_resource type="GradientTexture" id=4]
flags = 4
gradient = SubResource( 3 )
width = 2048
[resource]
render_priority = 0
trail_divisor = 1
emission_shape = 2
emission_box_extents = Vector3( 0.07, 0.07, 0.07 )
flag_align_y = false
flag_rotate_y = false
flag_disable_z = false
spread = 2.0
flatness = 0.0
gravity = Vector3( 0, 0.05, 0 )
initial_velocity = 0.0
initial_velocity_random = 0.0
angular_velocity = 35.0
angular_velocity_random = 1.0
angular_velocity_curve = SubResource( 2 )
linear_accel = 0.01
linear_accel_random = 0.0
radial_accel = 0.0
radial_accel_random = 0.0
tangential_accel = 0.0
tangential_accel_random = 0.06
damping = 0.0
damping_random = 0.0
angle = 10.0
angle_random = 0.0
scale = 1.0
scale_random = 0.0
color_ramp = SubResource( 4 )
hue_variation = 0.0
hue_variation_random = 0.0
anim_speed = 50.0
anim_speed_random = 0.0
anim_offset = 0.14
anim_offset_random = 0.0
anim_loop = true
_sections_unfolded = [ "Angle", "Angular Velocity", "Animation", "Color", "Damping", "Emission Shape", "Flags", "Gravity", "Hue Variation", "Initial Velocity", "Linear Accel", "Radial Accel", "Resource", "Scale", "Spread", "Tangential Accel", "Trail" ]

View file

@ -1,79 +1,40 @@
[gd_resource type="ParticlesMaterial" load_steps=7 format=2]
[sub_resource type="Gradient" id=1]
offsets = PoolRealArray( 0, 0.293375, 1 )
colors = PoolColorArray( 1, 1, 1, 0, 1, 1, 1, 1, 0.949527, 0.949527, 0.949527, 0 )
[sub_resource type="GradientTexture" id=2]
flags = 4
gradient = SubResource( 1 )
width = 128
[sub_resource type="Curve" id=3]
min_value = 0.0
max_value = 1.0
bake_resolution = 100
_data = [ Vector2( 0, 0.40332 ), 0.0, -0.404933, 0, 1, Vector2( 0.996017, 0 ), -2.26433, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=4]
flags = 4
width = 128
curve = SubResource( 3 )
[sub_resource type="Curve" id=5]
min_value = 0.0
max_value = 1.0
bake_resolution = 100
_data = [ Vector2( 0, 0 ), 0.0, 0.928107, 0, 0, Vector2( 0.365168, 0.618164 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.500372, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=6]
flags = 4
width = 128
curve = SubResource( 5 )
[resource]
render_priority = 0
trail_divisor = 1
emission_shape = 2
emission_box_extents = Vector3( 0.05, 0.05, 0.05 )
flag_align_y = false
flag_rotate_y = false
flag_disable_z = false
spread = 1.0
flatness = 0.0
gravity = Vector3( 0, 0.3, 0 )
initial_velocity = 0.0
initial_velocity_random = 0.0
angular_velocity = 50.0
angular_velocity_random = 1.0
linear_accel = 0.1
linear_accel_random = 0.0
linear_accel_curve = SubResource( 4 )
radial_accel = 0.01
radial_accel_random = 0.0
tangential_accel = 0.01
tangential_accel_random = 0.0
damping = 0.0
damping_random = 0.0
angle = 5.0
angle_random = 0.0
scale = 1.5
scale_random = 0.1
scale_curve = SubResource( 6 )
color_ramp = SubResource( 2 )
hue_variation = 0.0
hue_variation_random = 0.0
anim_speed = 0.0
anim_speed_random = 0.0
anim_offset = 0.0
anim_offset_random = 0.0
anim_loop = false
_sections_unfolded = [ "Angle", "Angular Velocity", "Animation", "Color", "Damping", "Emission Shape", "Flags", "Gravity", "Hue Variation", "Initial Velocity", "Linear Accel", "Radial Accel", "Scale", "Spread", "Tangential Accel", "Trail" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_1.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_2.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_4.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_5.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -0,0 +1,74 @@
# 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

View file

@ -0,0 +1,94 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var _msg_xml = XMLParser.new()
var _msg_md5sum
var _msg_data = {}
func open_message_xml():
var file = File.new()
# Calculate MD5SUM
file.open("res://assets/Definition/msg.xml", File.READ)
var content = file.get_as_text()
_msg_md5sum = content.md5_text()
file.close()
print("[res://assets/Scripts/Definition/msg.gd:open_message_xml] checksum for msg.xml:" + _msg_md5sum)
var NetworkConnexion = preload("res://networkconnexion.gdns").new()
NetworkConnexion.define_checksum_msg_xml(content.md5_buffer())
# Load XML data
_msg_xml.open("res://assets/Definition/msg.xml")
func is_correct_md5(value):
return (_msg_md5sum == value)
func read_all_node():
var i
_msg_xml.seek(0)
var ret = _msg_xml.read()
var branch = ""
var leaf = ""
var ibranch = 0
var ileaf = 0
while ret == OK:
#print("Node: Name:" + _msg_xml.get_node_name() + ", Type:" + str(_msg_xml.get_node_type()) + ", Data:" + str(_msg_xml.get_node_data()) + ", attribut count:" + str(_msg_xml.get_attribute_count()) )
#i = 0
#while i < _msg_xml.get_attribute_count():
# print(" -- Attribut Name:" + _msg_xml.get_attribute_name(i) + " Value:" + _msg_xml.get_attribute_value(i))
# i += 1
if _msg_xml.get_node_type() != XMLParser.NODE_ELEMENT:
ret = _msg_xml.read()
continue
match _msg_xml.get_node_name():
"branch":
i = 0
while i < _msg_xml.get_attribute_count() and _msg_xml.get_attribute_name(i) != "name":
i += 1
if i < _msg_xml.get_attribute_count():
branch = _msg_xml.get_attribute_value(i)
#print(branch + " " + str(_msg_xml.get_node_type()))
_msg_data[branch] = {"leaf": {}, "pos": ibranch}
ibranch += 1
ileaf = 0
"leaf":
i = 0
while i < _msg_xml.get_attribute_count() and _msg_xml.get_attribute_name(i) != "name":
i += 1
if i < _msg_xml.get_attribute_count():
leaf = _msg_xml.get_attribute_value(i)
#print(branch + ":" + leaf + str(_msg_xml.get_node_type()))
_msg_data[branch]["leaf"][leaf] = ileaf
ileaf += 1
ret = _msg_xml.read()
if ProjectSettings.get_setting("khaganat/debug_mode"):
#print("Branch:" + str(_msg_data.size()))
var sizebranch = _msg_data.size()
for key in _msg_data:
var sizeleaf = _msg_data[key]["leaf"].size()
print(" " + key + " -> " + str(_msg_data[key]["pos"]) + "/" + str(sizebranch))
for leaf in _msg_data[key]["leaf"]:
var opt = str(_msg_data[key]["pos"]) + "/" + str(sizebranch) + " : " + str(_msg_data[key]["leaf"][leaf]) + "/" + str(sizeleaf)
print(" " + key + ":" + leaf + " -> " + opt)
# Called when the node enters the scene tree for the first time.
func _ready():
open_message_xml()
read_all_node()
print("[res://assets/Scripts/Definition/msg.gd] ready")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func read_msg(msgin):
pass
func write_msg(value):
pass

View file

@ -14,12 +14,29 @@ class nel_login_message:
self._cp = cp;
self._lg = lg;
func get_request_string():
var request_string = "cmd=" + self._cmd;
func crypt_password(salt):
var crypt = preload("res://crypt.gdns").new()
var crypted = crypt.encrypt(self._password, salt)
return crypted
func get_request_salt():
# cmd = self.url + "?cmd=ask&cp=2&login=" + self.login + "&lg=" + self.LanguageCode
var request_string = "cmd=ask"
if self._cp != "":
request_string += "&cp=" + self._cp;
if self._login != "":
request_string += "&login=" + self._login;
if self._lg != "":
request_string += "&lg=" + self._lg;
return request_string;
func get_request_string(salt):
var request_string = "cmd=login"
if self._login != "":
request_string += "&login=" + self._login;
if self._password != "":
request_string += "&password=" + self._password;
request_string += "&password=" + self.crypt_password(salt);
if self._clientApplication != "":
request_string += "&clientApplication=" + self._clientApplication;
if self._cp != "":

View file

@ -0,0 +1,45 @@
# Class to send parameter to register a new account
#
# 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 nel_register:
var _username
var _password
var _confirmed
var _email
var _tac
var _url_encoding
func _init(username, password, confirmed, email, tac):
self._username = username
self._password = password
self._confirmed = confirmed
self._email = email
self._tac = tac
self._url_encoding = preload("res://assets/Scripts/Tools/url_encoding.gd").url_encoding.new()
func get_request():
return "/ams/index.php?page=register"
func get_headers():
return ["Content-Type: application/x-www-form-urlencoded", "User-Agent: Ryzom"]
func get_user_agent():
# HTTP_USER_AGENT
return "Ryzom"
func get_param_add_user_string():
return "Username=" + self._url_encoding.web_encode(self._username) + "&Password=" + self._url_encoding.web_encode(self._password) + "&ConfirmPass=" + self._url_encoding.web_encode(self._password) + "&Email=" + self._url_encoding.web_encode(self._email) + "&TaC=" + self._url_encoding.web_encode(self._tac) + "&function=add_user"

View file

@ -0,0 +1,52 @@
# Class to manage low level communication with 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/>.
# https://godotengine.org/qa/20026/to-send-a-udp-packet-godot-3
extends Control
onready var BitStream = preload("res://bitstream.gdns")
onready var BitSet = preload("res://bitset.gdns")
onready var NetworkConnexion = preload("res://networkconnexion.gdns")
var _networkconnexion
func _ready():
_networkconnexion = NetworkConnexion.new()
func send_system_login(host, port, user_addr, user_key, user_id, lang):
_networkconnexion.send_system_login(host, port, user_addr, user_key, user_id, lang)
func send_system_quit():
_networkconnexion.send_system_quit()
func send_systemm_disconnect():
_networkconnexion.send_systemm_disconnect()
func disconnect_server():
_networkconnexion.disconnect_server()
func connect_to_server(host, port, user_addr, user_key, user_id, lang):
send_system_login(host, port, user_addr, user_key, user_id, lang)
func _process(delta):
_networkconnexion.process(delta)
func _exit_tree():
print("[net_low_level] End")
disconnect_server()

View file

@ -0,0 +1,62 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func HexaArray(value):
match value:
0:
return "0"
1:
return "1"
2:
return "2"
3:
return "3"
4:
return "4"
5:
return "5"
6:
return "6"
7:
return "7"
8:
return "8"
9:
return "9"
10:
return "a"
11:
return "b"
12:
return "c"
13:
return "d"
14:
return "e"
15:
return "f"
_:
return "?"
func IntToStringHexa(value):
var ret = ""
ret += HexaArray(value >> 4)
ret += HexaArray(value & 15)
return ret
func ArrayIntToStringHexa(array_int):
var ret = ""
for data in array_int:
ret += IntToStringHexa(data)
return ret

View file

@ -0,0 +1,51 @@
# Class to encode string with escape web code
#
# 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 url_encoding:
func _init():
pass
func web_encode(value):
var ret = value
ret = ret.replace("%", "%25")
ret = ret.replace(" ", "%20")
ret = ret.replace("\"","%22")
ret = ret.replace("<", "%3C")
ret = ret.replace(">", "%3E")
ret = ret.replace("#", "%23")
ret = ret.replace("{", "%7B")
ret = ret.replace("}", "%7D")
ret = ret.replace("|", "%7C")
ret = ret.replace("\\","%5C")
ret = ret.replace("^", "%5E")
ret = ret.replace("~", "%7E")
ret = ret.replace("[", "%5B")
ret = ret.replace("]", "%5D")
ret = ret.replace("`", "%60")
ret = ret.replace("@", "%40")
ret = ret.replace("$", "%24")
ret = ret.replace("&", "%26")
ret = ret.replace("+", "%2B")
ret = ret.replace(",", "%2C")
ret = ret.replace("/", "%2F")
ret = ret.replace(":", "%3A")
ret = ret.replace(";", "%3B")
ret = ret.replace("=", "%3D")
ret = ret.replace("?", "%3F")
ret = ret.replace("'", "%27")
return ret

7
bitset.gdns Normal file
View file

@ -0,0 +1,7 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "BitSet"
library = ExtResource( 1 )

7
bitstream.gdns Normal file
View file

@ -0,0 +1,7 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "BitStream"
library = ExtResource( 1 )

7
crypt.gdns Normal file
View file

@ -0,0 +1,7 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "Crypt"
library = ExtResource( 1 )

49
export_presets.cfg Normal file
View file

@ -0,0 +1,49 @@
[preset.0]
name="khaganat.linux.64"
platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.0.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=true
custom_template/release=""
custom_template/debug=""
[preset.1]
name="khaganat.linux.32"
platform="Linux/X11"
runnable=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.1.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=false
custom_template/release=""
custom_template/debug=""

View file

@ -57,7 +57,7 @@ func set_default_values():
self.slot = 0
self.ears_size = 0.0
self.eyes_color = Color( 0.0, 1.0, 0.0, 1.0 )
func update( start_position = null ):
if start_position:
# self.translation = start_position.to_global( start_position.translation )
@ -65,7 +65,7 @@ func update( start_position = null ):
# self.translate( start_position.translation )
self.translation = start_position.translation
self.rotation = start_position.rotation
self.scale = Vector3( self.size, self.size, self.size )
# $infos_spatial.scale = Vector3( self.size, self.size, self.size )
# self.player_mesh.scale = Vector3( self.size, self.size, self.size )
@ -85,11 +85,11 @@ func update( start_position = null ):
self.player_mesh.mesh.get( "surface_2/material" ).set_shader_param( "albedo", self.color )
# eyes color (pupil)
self.player_mesh.mesh.get( "surface_4/material" ).set_shader_param( "albedo", self.eyes_color )
func _process(delta):
process_input(delta)
process_movement(delta)
@ -216,14 +216,13 @@ func _input(event):
self.hide()
else:
self.show()
func hide_infos():
$infos_spatial/character_infos_billboard.hide()
func show_infos():
$infos_spatial/character_infos_billboard.show()
########
#### Cameras
func show_third_person_camera():
$camera_rotation_helper/camera.make_current()

View file

@ -7,107 +7,45 @@
[sub_resource type="CapsuleShape" id=1]
radius = 1.0
height = 1.0
[node name="character" type="KinematicBody" index="0"]
[node name="character" type="KinematicBody"]
transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0 )
input_ray_pickable = false
input_capture_on_drag = false
collision_layer = 1
collision_mask = 1
axis_lock_linear_x = false
axis_lock_linear_y = false
axis_lock_linear_z = false
axis_lock_angular_x = false
axis_lock_angular_y = false
axis_lock_angular_z = false
collision/safe_margin = 0.001
script = ExtResource( 1 )
_sections_unfolded = [ "Axis Lock", "Transform", "collision" ]
[node name="infos_spatial" type="Spatial" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, -9.56715e-015, 0, 1, -4.65661e-010, 2.47932, -0.0688725 )
[node name="infos_spatial" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, -9.56715e-15, 0, 1, -4.65661e-10, 2.47932, -0.0688725 )
script = ExtResource( 2 )
[node name="character_infos_billboard" parent="infos_spatial" index="0" instance=ExtResource( 3 )]
[node name="character_infos_billboard" parent="infos_spatial" instance=ExtResource( 3 )]
visible = false
mouse_filter = 2
mouse_default_cursor_shape = 2
_sections_unfolded = [ "Mouse", "Rect", "Size Flags", "Visibility" ]
[node name="camera_rotation_helper" type="Spatial" parent="." index="1"]
[node name="camera_rotation_helper" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0730682, 0 )
[node name="camera" type="Camera" parent="camera_rotation_helper" index="0"]
[node name="camera" type="Camera" parent="camera_rotation_helper"]
transform = Transform( 1, 0, 0, 0, 0.981951, 0, 0, 0, 1.05023, 0, 2.5, 3 )
keep_aspect = 1
cull_mask = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0
doppler_tracking = 0
projection = 0
current = false
fov = 75.0
size = 1.0
near = 0.05
far = 10000.0
_sections_unfolded = [ "Transform" ]
[node name="face_camera" type="Camera" parent="camera_rotation_helper" index="1"]
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 1.91278, -2.96733 )
keep_aspect = 1
cull_mask = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0
doppler_tracking = 0
projection = 0
current = false
fov = 70.0
[node name="face_camera" type="Camera" parent="camera_rotation_helper"]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.91278, -2.96733 )
size = 2.0
near = 0.05
far = 10000.0
_sections_unfolded = [ "Transform" ]
[node name="suzanne" parent="." index="2" instance=ExtResource( 4 )]
[node name="suzanne" parent="." instance=ExtResource( 4 )]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.2572, -0.180126 )
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 1.2572, -0.180126 )
[node name="flashlight" type="SpotLight" parent="suzanne" index="1"]
transform = Transform( -0.718303, -4.51344e-010, 1.04295e-007, 0, 1.19299, 0.0148616, -6.27955e-008, 0.00516275, -1.19299, -0.020946, 0.599374, 0.0648584 )
layers = 1
light_color = Color( 1, 1, 1, 1 )
[node name="flashlight" type="SpotLight" parent="suzanne"]
transform = Transform( -0.718303, -4.51344e-10, 1.04295e-07, 0, 1.19299, 0.0148616, -6.27955e-08, 0.00516275, -1.19299, -0.020946, 0.599374, 0.0648584 )
light_energy = 2.0
light_indirect_energy = 2.0
light_negative = false
light_specular = 0.5
light_bake_mode = 1
light_cull_mask = -1
shadow_enabled = true
shadow_color = Color( 0, 0, 0, 1 )
shadow_bias = 0.15
shadow_contact = 0.0
shadow_reverse_cull_face = true
editor_only = false
spot_range = 9.90764
spot_attenuation = 1.0
spot_angle = 22.2473
spot_angle_attenuation = 1.0
_sections_unfolded = [ "Light", "Shadow" ]
[node name="collision_shape" type="CollisionShape" parent="." index="3"]
[node name="collision_shape" type="CollisionShape" parent="."]
transform = Transform( 0.430205, 0, 0, 0, 0.906621, 0, 0, 0, 0.294585, 0.00823072, 0.942657, -0.356263 )
shape = SubResource( 1 )
disabled = false

View file

@ -7,25 +7,25 @@ const WINDOW_TITLE_INPUT = "GUI/Settings/Menus/TabContainer/Test/ScrollContainer
func _ready():
get_tree().get_root().connect("size_changed", self, "on_window_size_changed")
global.get_node("GUI").show()
global.get_node("GUI").play()
character.show_third_person_camera()
character.get_node( "infos_spatial" ).show()
global.get_node( "audio_stream_player" ).stop()
func _process(delta):
pass
func on_window_size_changed():
change_title()
func change_title():
if has_node( WINDOW_TITLE_INPUT ):
var title_node = get_node( WINDOW_TITLE_INPUT )
var title = "Khanat"
var title = "Khanat"
if title_node and not title_node.text.strip_edges() == "":
title = title_node.text.strip_edges()
title += " (" + String(OS.get_window_size().x) + "x" + String(OS.get_window_size().y) + ")"

View file

@ -5,14 +5,9 @@
[ext_resource path="res://scenes/Game/markers/arrow_z.tscn" type="PackedScene" id=3]
[node name="game_scene" type="Node"]
script = ExtResource( 1 )
_sections_unfolded = [ "Pause" ]
[node name="Game" parent="." index="0" instance=ExtResource( 2 )]
[node name="start_position" parent="." index="1" instance=ExtResource( 3 )]
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 0, -15 )
[node name="Game" parent="." instance=ExtResource( 2 )]
[node name="start_position" parent="." instance=ExtResource( 3 )]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -15 )

14
gdnative.gdnlib Normal file
View file

@ -0,0 +1,14 @@
[general]
singleton=false
load_once=true
symbol_prefix="godot_"
reloadable=true
[entry]
X11.64="res://gdnative/bin/libgdnative.linux.release.64.so"
[dependencies]
X11.64=[ ]

2
gdnative/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
bin/
.sconsign.dblite

153
gdnative/SConstruct Normal file
View file

@ -0,0 +1,153 @@
#!python
#
# On root project
# scons -C gdnative platform=linux bits=64
#
import os, subprocess, platform, sys
# Local dependency paths, adapt them to your setup
godot_headers_path = "../godot-cpp/godot_headers/"
cpp_bindings_path = "../godot-cpp/"
cpp_library = "godot-cpp"
if not os.path.exists( 'bin' ):
os.mkdir( 'bin' )
def add_sources(sources, dir, extension):
for f in os.listdir(dir):
if f.endswith('.' + extension):
sources.append(dir + '/' + f)
# Try to detect the host platform automatically
# This is used if no `platform` argument is passed
if sys.platform.startswith('linux'):
host_platform = 'linux'
elif sys.platform == 'darwin':
host_platform = 'osx'
elif sys.platform == 'win32':
host_platform = 'windows'
else:
raise ValueError('Could not detect platform automatically, please specify with platform=<platform>')
opts = Variables([], ARGUMENTS)
opts.Add(EnumVariable('platform', 'Target platform', host_platform,
allowed_values=('linux', 'osx', 'windows'),
ignorecase=2))
opts.Add(EnumVariable('bits', 'Target platform bits', 'default', ('default', '32', '64')))
opts.Add(BoolVariable('use_llvm', 'Use the LLVM compiler - only effective when targeting Linux', False))
opts.Add(BoolVariable('use_mingw', 'Use the MinGW compiler - only effective on Windows', False))
# Must be the same setting as used for cpp_bindings
opts.Add(EnumVariable('target', 'Compilation target', 'debug',
allowed_values=('debug', 'release'),
ignorecase=2))
opts.Add(PathVariable('headers_dir', 'Path to the directory containing Godot headers', godot_headers_path, PathVariable.PathIsDir))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'bin'))
opts.Add(PathVariable('target_name', 'The library name.', 'libgdcrypt', PathVariable.PathAccept))
unknown = opts.UnknownVariables()
if unknown:
print("Unknown variables:" + unknown.keys())
Exit(1)
env = Environment()
opts.Update(env)
Help(opts.GenerateHelpText(env))
# sys.stderr.write("**** %s\n" % (cpp_library))
# This makes sure to keep the session environment variables on Windows
# This way, you can run SCons in a Visual Studio 2017 prompt and it will find all the required tools
if env['platform'] == 'windows':
if env['bits'] == '64':
env = Environment(TARGET_ARCH='amd64')
elif env['bits'] == '32':
env = Environment(TARGET_ARCH='x86')
else:
print("Warning: bits argument not specified, target arch is=" + env['TARGET_ARCH'])
opts.Update(env)
is64 = False
if (env['platform'] == 'osx' or env['TARGET_ARCH'] == 'amd64' or env['TARGET_ARCH'] == 'emt64' or env['TARGET_ARCH'] == 'x86_64'):
is64 = True
if env['bits'] == 'default':
env['bits'] = '64' if is64 else '32'
if env['platform'] == 'linux':
if env['use_llvm']:
env['CXX'] = 'clang++'
env.Append(CCFLAGS=['-fPIC', '-g', '-std=c++14', '-Wwrite-strings'])
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
if env['bits'] == '64':
env.Append(CCFLAGS=['-m64'])
env.Append(LINKFLAGS=['-m64'])
elif env['bits'] == '32':
env.Append(CCFLAGS=['-m32'])
env.Append(LINKFLAGS=['-m32'])
elif env['platform'] == 'osx':
if env['bits'] == '32':
raise ValueError('Only 64-bit builds are supported for the macOS target.')
env.Append(CCFLAGS=['-g', '-std=c++14', '-arch', 'x86_64'])
env.Append(LINKFLAGS=['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup'])
if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
elif env['platform'] == 'windows':
if host_platform == 'windows' and not env['use_mingw']:
# MSVC
env.Append(LINKFLAGS=['/WX'])
if env['target'] == 'debug':
env.Append(CCFLAGS=['/EHsc', '/D_DEBUG', '/MDd'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD'])
else:
# MinGW
if env['bits'] == '64':
env['CXX'] = 'x86_64-w64-mingw32-g++'
elif env['bits'] == '32':
env['CXX'] = 'i686-w64-mingw32-g++'
env.Append(CCFLAGS=['-g', '-O3', '-std=c++14', '-Wwrite-strings'])
env.Append(LINKFLAGS=['--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++'])
env.Append(CPPPATH=['.', env['headers_dir'], 'include', 'include/gen', 'include/core'])
# source to compile
sources = []
add_sources(sources, 'src', 'cpp')
#add_sources(sources, 'src/gen', 'cpp')
# make sure our binding library is properly includes
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
env.Append(LIBPATH=[cpp_bindings_path + 'bin/'])
libgodot = '{}.{}.{}.{}'.format(cpp_library, env['platform'], env['target'], env['bits'])
env.Append(LIBS=[libgodot])
# static = env.Command('libstdc++.a', None, Action('ln -s `g++ -print-file-name=libstdc++.a` $TARGET'));
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=['src/'])
srcgdnative = Glob('src/*.cpp')
libgdnative = env.SharedLibrary(target=os.path.join(env['target_path'], 'libgdnative.{}.{}.{}'.format(env['platform'], env['target'], env['bits'])), source=srcgdnative)
Default(libgdnative)
# Generates help for the -h scons option.
Help(opts.GenerateHelpText(env))

0
gdnative/src/.gdignore Normal file
View file

1
gdnative/src/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.os

155
gdnative/src/bitset.cpp Normal file
View file

@ -0,0 +1,155 @@
/*
* Class BitSet
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/>.
Build :
scons platform=linux bits=64
*/
#include <Godot.hpp>
#include <iostream>
#include "bitset.h"
using namespace godot;
#define BITSET_SIZE 32
void BitSet::_register_methods()
{
register_method("size", &BitSet::size);
register_method("resize", &BitSet::resize);
register_method("clear", &BitSet::clear);
register_method("clear_data", &BitSet::clear_data);
register_method("set_bit", &BitSet::set_bit);
register_method("clear_bit", &BitSet::clear_bit);
register_method("put", &BitSet::put);
register_method("get", &BitSet::get);
register_method("write_serial", &BitSet::write_serial);
register_method("read_serial", &BitSet::read_serial);
register_method("show", &BitSet::show);
}
BitSet::BitSet()
{
this->_num_bits = 8;
this->_size_byte = 1;
this->_mask_last = 0;
this->_data = new uint32_t[1];
}
BitSet::~BitSet()
{
// add your cleanup here
delete [] this->_data;
}
void BitSet::_init()
{
}
int BitSet::size()
{
return this->_size_byte;
}
void BitSet::resize(uint32_t num_bits)
{
uint32_t i;
uint32_t n_last_bits;
if (this->_num_bits != num_bits )
{
this->_num_bits = num_bits;
this->_size_byte = (num_bits + BITSET_SIZE - 1) / BITSET_SIZE;
delete [] this->_data;
this->_data = new uint32_t[this->_size_byte];
n_last_bits = this->_num_bits & (BITSET_SIZE - 1);
if ( n_last_bits == 0 )
this->_mask_last = ~0;
else
this->_mask_last = (1 << n_last_bits) - 1;
}
this->clear_data();
}
void BitSet::clear()
{
this->resize(1);
}
void BitSet::clear_data()
{
for(uint32_t i = 0;i < this->_size_byte; ++i)
this->_data[i] = 0;
}
void BitSet::set_bit(uint32_t bit_number)
{
uint32_t mask = bit_number & (BITSET_SIZE - 1);
mask = 1 << mask;
this->_data[bit_number>>5] |= mask;
}
void BitSet::clear_bit(uint32_t bit_number)
{
uint32_t mask = bit_number & (BITSET_SIZE - 1);
mask = 1 << mask;
this->_data[bit_number>>5] &= mask;
}
void BitSet::put(uint32_t bit_number, bool value)
{
if ( value )
this->set_bit(bit_number);
else
this->clear_bit(bit_number);
}
bool BitSet::get(uint32_t bit_number)
{
uint32_t mask = bit_number & (BITSET_SIZE - 1);
mask = 1 << mask;
return this->_data[bit_number>>5] & mask != 0;
}
void BitSet::write_serial(BitStream * msgout)
{
uint8_t current_version = 0;
msgout->put_uint8(current_version);
msgout->put_uint32(this->_num_bits);
// _size_byte est lié à _num_bits dommage que l'on envoie celui-la
msgout->put_uint32(this->_size_byte);
for(uint32_t i = 0;i < this->_size_byte; ++i)
msgout->put_uint32(this->_data[i]);
}
void BitSet::read_serial(BitStream * msgin)
{
uint8_t current_version = msgin->get_sint8();
uint8_t num_bits = msgin->get_uint32();
this->resize(num_bits);
for(uint32_t i = 0;i < this->_size_byte; ++i)
this->_data[i] = msgin->get_uint32();
}
String BitSet::show()
{
BitStream msgout;
this->write_serial(&msgout);
return msgout.show();
}

59
gdnative/src/bitset.h Normal file
View file

@ -0,0 +1,59 @@
/*
Header BitSet
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/>.
*/
#ifndef BIT_SET_H
#define BIT_SET_H
#include <Godot.hpp>
#include <Reference.hpp>
#include "bitstream.h"
namespace godot {
class BitSet : public Reference {
GODOT_CLASS(BitSet, Reference)
private:
uint32_t _num_bits;
uint32_t _size_byte;
uint32_t _mask_last;
uint32_t * _data;
public:
static void _register_methods();
BitSet();
~BitSet();
void _init(); // our initializer called by Godot
int size();
void resize(uint32_t num_bits);
void clear();
void clear_data();
void set_bit(uint32_t bit_number);
void clear_bit(uint32_t bit_number);
void put(uint32_t bit_number, bool value);
bool get(uint32_t bit_number);
void write_serial(BitStream * msgout);
void read_serial(BitStream * msgin);
String show();
};
}
#endif

457
gdnative/src/bitstream.cpp Normal file
View file

@ -0,0 +1,457 @@
/*
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/>.
Build :
scons platform=linux bits=64
*/
#include <Godot.hpp>
#include "bitstream.h"
using namespace godot;
bool little_endian = false;
void BitStream::_register_methods()
{
register_method("is_little_endian", &BitStream::is_little_endian);
register_method("size", &BitStream::size);
register_method("put_serial", &BitStream::put_serial);
register_method("put_bool", &BitStream::put_bool);
register_method("put_char", &BitStream::put_char);
register_method("put_uint8", &BitStream::put_uint8);
register_method("put_sint8", &BitStream::put_sint8);
register_method("put_sint16", &BitStream::put_sint16);
register_method("put_uint16", &BitStream::put_uint16);
register_method("put_sint32", &BitStream::put_sint32);
register_method("put_uint32", &BitStream::put_uint32);
register_method("put_sint64", &BitStream::put_sint64);
register_method("put_uint64", &BitStream::put_uint64);
register_method("put_string", &BitStream::put_string);
register_method("put_string_hexa32", &BitStream::put_string_hexa32);
register_method("put_array_uint8", &BitStream::put_array_uint8);
register_method("show", &BitStream::show);
register_method("show_detail", &BitStream::show_detail);
register_method("show_counter", &BitStream::show_counter);
register_method("get_data", &BitStream::get_data);
register_method("put_data", &BitStream::put_data);
register_method("get_serial", &BitStream::get_serial);
register_method("get_bool", &BitStream::get_bool);
register_method("get_sint8", &BitStream::get_sint8);
register_method("get_uint8", &BitStream::get_uint8);
register_method("get_sint16", &BitStream::get_sint16);
register_method("get_uint16", &BitStream::get_uint16);
register_method("get_sint32", &BitStream::get_sint32);
register_method("get_uint32", &BitStream::get_uint32);
register_method("get_sint64", &BitStream::get_sint64);
register_method("get_uint64", &BitStream::get_uint64);
register_method("get_array_uint8", &BitStream::get_array_uint8);
}
void BitStream::clear()
{
this->_pos = 0;
this->_read = 0;
}
BitStream::BitStream()
{
clear();
}
BitStream::~BitStream()
{
// add your cleanup here
}
void BitStream::_init()
{
uint32_t i=0x12345678;
if ( (*((uint8_t*)(&i))) == 0x78 )
little_endian = true;
else
little_endian = false;
}
bool BitStream::is_little_endian()
{
return little_endian;
}
int BitStream::size()
{
return (this->_pos + 7) / 8;
}
int BitStream::size_data()
{
return this->_pos;
}
void BitStream::put_serial(uint32_t value, uint32_t nbits)
{
uint32_t v;
uint32_t mask;
uint32_t freeBits;
uint32_t pos;
if ( nbits == 0 )
return;
else if ( nbits > 32 )
throw "Out of range";
if ( this->_pos % 8 == 0 ) // Increase node
this->_data.append(0);
if ( nbits != 32 )
{
mask = (1 << nbits) - 1;
v = value & mask;
}
else
{
v = value;
}
freeBits = 8 - (this->_pos % 8);
pos = this->_data.size() - 1;
if(nbits > freeBits)
{
this->_data.set(pos, this->_data[pos] | (v >> (nbits - freeBits)));
this->_pos += freeBits;
this->put_serial(v, nbits - freeBits);
}
else
{
this->_data.set(pos, this->_data[pos] | (v << (freeBits - nbits)));
this->_pos += nbits;
}
}
void BitStream::put_bool(bool value)
{
this->put_serial(value, 1);
}
void BitStream::put_sint8(int8_t value)
{
this->put_serial(value, 8);
}
void BitStream::put_uint8(uint8_t value)
{
this->put_serial(value, 8);
}
void BitStream::put_sint16(int16_t value)
{
this->put_serial(value, 16);
}
void BitStream::put_uint16(uint16_t value)
{
this->put_serial(value, 16);
}
void BitStream::put_sint32(int32_t value)
{
this->put_serial(value, 32);
}
void BitStream::put_uint32(uint32_t value)
{
this->put_serial(value, 32);
}
void BitStream::put_sint64(int64_t value)
{
if(little_endian)
{
this->put_serial(value>>32, 32);
this->put_serial(value, 32);
}
else
{
this->put_serial(value, 32);
this->put_serial(value>>32, 32);
}
}
void BitStream::put_uint64(uint64_t value)
{
if(little_endian)
{
this->put_serial(value>>32, 32);
this->put_serial(value, 32);
}
else
{
this->put_serial(value, 32);
this->put_serial(value>>32, 32);
}
}
void BitStream::put_string_hexa32(String hexa)
{
uint32_t res = 0;
CharString tmp = hexa.ascii();
for(const char * c = tmp.get_data(); *c != 0; c++)
{
res <<= 4;
if ( *c >= '0' && *c <= '9')
res += *c - '0';
else if ( *c >= 'A' && *c <= 'F')
res += *c - 'A' + 10;
}
this->put_serial(res,32);
}
void BitStream::put_char(String value)
{
if ( value.length() >= 1)
this->put_uint8( value[0] );
else
this->put_uint8( 0 );
}
void BitStream::put_string(String value)
{
uint32_t lenvalue = value.length();
this->put_uint32(lenvalue);
//CharString tmp = value.ascii();
for(uint32_t i = 0; i < lenvalue ; ++i)
{
this->put_char(value[i]);
}
}
void BitStream::put_array_uint8(PoolByteArray value)
{
uint32_t i;
for(i = 0; i < value.size() ; ++i)
this->put_serial(value[i], 8);
}
String BitStream::show()
{
String ret;
uint32_t pos = 0;
for(uint32_t i = 0; i < this->_data.size(); ++i)
{
uint8_t c = this->_data[i];
uint8_t mask = 0x80;
while(mask)
{
if ( (c & mask) != 0 )
ret += String('1');
else
ret += String('0');
mask >>= 1;
pos += 1;
if (pos >= this->_pos)
break;
}
if (pos >= this->_pos)
break;
}
return ret ;
}
String BitStream::show_detail()
{
String ret;
uint32_t pos = 0;
for(uint32_t i = 0; i < this->_data.size(); ++i)
{
uint8_t c = this->_data[i];
uint8_t mask = 0x80;
while(mask)
{
if ( (c & mask) != 0 )
ret += String('1');
else
ret += String('0');
mask >>= 1;
pos += 1;
if (pos >= this->_pos)
break;
}
if (pos >= this->_pos)
break;
}
String strsize;
uint32_t t = this->_data.size();
if ( t == 0) strsize = "0";
while ( t > 0 )
{
char c = '0' + ( t % 10 );
strsize = String(c) + strsize;
t /= 10;
}
String strpos;
t = this->_pos;
if ( t == 0) strpos = "0";
while ( t > 0 )
{
char c = '0' + ( t % 10 );
strpos = String(c) + strpos;
t /= 10;
}
return "[size:" + strsize + ", pos:" + strpos + "]" + ret ;
}
String BitStream::show_counter()
{
String ret = "[" + String::num_int64(this->_read) + " / " + String::num_int64(this->_pos) + "]";
return ret;
}
PoolByteArray BitStream::get_data()
{
return this->_data;
}
void BitStream::put_data(PoolByteArray value)
{
this->_data = value;
this->_pos = value.size() * 8;
}
uint32_t BitStream::get_serial(uint32_t nbits)
{
uint32_t value;
uint32_t pos;
uint32_t freeBits;
uint32_t v;
if ( nbits == 0 )
return 0;
else if ( nbits > 32 )
{
ERR_PRINT("Out of range (BitStream::get_serial)");
throw "Out of range";
}
if (this->_read + nbits > this->_pos)
{
ERR_PRINT("Out of range (BitStream::get_serial)");
throw "Out of range";
}
value = 0;
pos = this->_read / 8;
freeBits = 8 - (this->_read % 8);
v = this->_data[pos] & ((1 << freeBits) - 1);
if(nbits > freeBits)
{
value |= (v << (nbits-freeBits));
this->_read += freeBits;
value |= this->get_serial(nbits - freeBits);
}
else
{
value |= (v >> (freeBits-nbits));
this->_read += nbits;
}
return value;
}
bool BitStream::get_bool()
{
if(this->get_serial(1) == 0)
return false;
return true;
}
int8_t BitStream::get_sint8()
{
return this->get_serial(8);
}
uint8_t BitStream::get_uint8()
{
return this->get_serial(8);
}
int16_t BitStream::get_sint16()
{
return this->get_serial(16);
}
uint16_t BitStream::get_uint16()
{
return this->get_serial(16);
}
int32_t BitStream::get_sint32()
{
return this->get_serial(32);
}
uint32_t BitStream::get_uint32()
{
return this->get_serial(32);
}
int64_t BitStream::get_sint64()
{
int64_t v1;
int64_t v2;
if(little_endian)
{
v1 = this->get_serial(32);
v2 = this->get_serial(32);
}
else
{
v2 = this->get_serial(32);
v1 = this->get_serial(32);
}
return (v1 << 32) | v2;
}
uint64_t BitStream::get_uint64()
{
int64_t v1;
int64_t v2;
if(little_endian)
{
v1 = this->get_serial(32);
v2 = this->get_serial(32);
}
else
{
v2 = this->get_serial(32);
v1 = this->get_serial(32);
}
return (v1 << 32) | v2;
}
PoolByteArray BitStream::get_array_uint8(uint32_t length)
{
PoolByteArray ret;
while(length != 0)
{
ret.append(this->get_serial(8));
--length;
}
return ret;
}

86
gdnative/src/bitstream.h Normal file
View file

@ -0,0 +1,86 @@
/*
Header BitStream
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/>.
*/
#ifndef BIT_STREAM_H
#define BIT_STREAM_H
#include <Godot.hpp>
#include <Reference.hpp>
namespace godot {
class BitStream : public Reference {
GODOT_CLASS(BitStream, Reference)
private:
uint32_t _pos;
uint32_t _read;
PoolByteArray _data;
public:
static void _register_methods();
void clear();
BitStream();
~BitStream();
void _init(); // our initializer called by Godot
bool is_little_endian();
int size();
int size_data();
void put_serial(uint32_t value, uint32_t nbits);
void put_bool(bool value);
void put_sint8(int8_t value);
void put_uint8(uint8_t value);
void put_sint16(int16_t value);
void put_uint16(uint16_t value);
void put_sint32(int32_t value);
void put_uint32(uint32_t value);
void put_sint64(int64_t value);
void put_uint64(uint64_t value);
void put_string_hexa32(String hexa);
void put_char(String value);
void put_string(String value);
void put_array_uint8(PoolByteArray value);
String show();
String show_detail();
String show_counter();
PoolByteArray get_data();
void put_data(PoolByteArray value);
uint32_t get_serial(uint32_t nbits);
bool get_bool();
int8_t get_sint8();
uint8_t get_uint8();
int16_t get_sint16();
uint16_t get_uint16();
int32_t get_sint32();
uint32_t get_uint32();
int64_t get_sint64();
uint64_t get_uint64();
PoolByteArray get_array_uint8(uint32_t length);
};
}
#endif

42
gdnative/src/clfecommon.h Normal file
View file

@ -0,0 +1,42 @@
/*
Header CLFECOMMON : message send by server
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/>.
*/
#ifndef CLFECOMMON_H
#define CLFECOMMON_H
namespace godot {
enum CLFECOMMON {
SYSTEM_LOGIN_CODE = 0,
SYSTEM_SYNC_CODE = 1,
SYSTEM_ACK_SYNC_CODE = 2,
SYSTEM_PROBE_CODE = 3,
SYSTEM_ACK_PROBE_CODE = 4,
SYSTEM_DISCONNECTION_CODE = 5,
SYSTEM_STALLED_CODE = 6,
SYSTEM_SERVER_DOWN_CODE = 7,
SYSTEM_QUIT_CODE = 8,
SYSTEM_ACK_QUIT_CODE = 9,
NUMBITSINLONGACK = 512
};
}
#endif // CLFECOMMON_H

34
gdnative/src/crypt.cpp Normal file
View file

@ -0,0 +1,34 @@
/*
Build :
scons platform=linux bits=64
*/
#include "crypt.h"
#include "sha512crypt.h"
using namespace godot;
void Crypt::_register_methods() {
register_method("encrypt", &Crypt::encrypt);
}
Crypt::Crypt() {
}
Crypt::~Crypt() {
// add your cleanup here
}
void Crypt::_init() {
// initialize any variables here
}
String Crypt::encrypt(String key, String salt) {
String out = "";
char * res = sha512_crypt (key.ascii().get_data(), salt.ascii().get_data());
out = res;
return out;
}

25
gdnative/src/crypt.h Normal file
View file

@ -0,0 +1,25 @@
#ifndef CRYPT_H
#define CRYPT_H
#include <Godot.hpp>
#include <Reference.hpp>
namespace godot {
class Crypt : public Object {
GODOT_CLASS(Crypt, Object)
public:
static void _register_methods();
Crypt();
~Crypt();
void _init(); // our initializer called by Godot
String encrypt(String key, String salt);
};
}
#endif

View file

@ -0,0 +1,45 @@
/*
Header to link with Godot
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/>.
*/
#include "bitstream.h"
#include "bitset.h"
#include "crypt.h"
#include "network_connection.h"
/** GDNative Initialize **/
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
godot::Godot::gdnative_init(o);
}
/** GDNative Terminate **/
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
terminate_network_connection();
godot::Godot::gdnative_terminate(o);
}
/** NativeScript Initialize **/
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);
godot::register_class<godot::BitStream>();
godot::register_class<godot::BitSet>();
godot::register_class<godot::Crypt>();
godot::register_class<godot::NetworkConnection>();
}

View file

@ -0,0 +1,93 @@
/*
Library to present all functions of NetworkConnectionCore (network)
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/>.
*/
#include <Godot.hpp>
#include "network_connection.h"
#include "bitstream.h"
#include "network_connection_core.h"
using namespace godot;
NetworkConnectionCore *NetworkConnectionCore::singleton = NULL;
void NetworkConnection::_register_methods()
{
register_method("define_checksum_msg_xml", &NetworkConnection::define_checksum_msg_xml);
register_method("define_socket_udp", &NetworkConnection::define_socket_udp);
register_method("send_system_login", &NetworkConnection::send_system_login);
register_method("send_system_disconnect", &NetworkConnection::send_system_disconnect);
register_method("send_system_quit", &NetworkConnection::send_system_quit);
register_method("disconnect_server", &NetworkConnection::disconnect_server);
register_method("process", &NetworkConnection::process);
register_method("get_state", &NetworkConnection::get_state);
}
NetworkConnection::NetworkConnection()
{
}
NetworkConnection::~NetworkConnection()
{
}
int NetworkConnection::get_state()
{
return NetworkConnectionCore::get_singleton()->get_state();
}
void NetworkConnection::define_checksum_msg_xml(Array checksum_msg_xml)
{
NetworkConnectionCore::get_singleton()->define_checksum_msg_xml(checksum_msg_xml);
}
void NetworkConnection::define_socket_udp(PacketPeerUDP * socketUDP)
{
NetworkConnectionCore::get_singleton()->define_socket_udp(socketUDP);
}
void NetworkConnection::send_system_login(String host, int64_t port, String user_addr, String user_key, String user_id, String lang)
{
NetworkConnectionCore::get_singleton()->send_system_login(host, port, user_addr, user_key, user_id, lang);
}
void NetworkConnection::send_system_disconnect()
{
NetworkConnectionCore::get_singleton()->send_system_disconnect();
}
void NetworkConnection::send_system_quit()
{
NetworkConnectionCore::get_singleton()->send_system_quit();
}
void NetworkConnection::disconnect_server()
{
NetworkConnectionCore::get_singleton()->disconnect_server();
}
void NetworkConnection::process(int delta)
{
NetworkConnectionCore::get_singleton()->process(delta);
}
void terminate_network_connection()
{
NetworkConnectionCore::get_singleton()->terminate_connexion();
}

View file

@ -0,0 +1,62 @@
/*
Header NetworkConnection
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/>.
*/
#ifndef NETWORK_CONNECTION_H
#define NETWORK_CONNECTION_H
#include <Godot.hpp>
#include <gen/PacketPeerUDP.hpp>
#include <Reference.hpp>
#include "bitstream.h"
#include "clfecommon.h"
#include "store_message.h"
#include "network_connection_core.h"
namespace godot {
class NetworkConnection : public Object {
GODOT_CLASS(NetworkConnection, Object)
private:
static void _bind_methods();
public:
NetworkConnection();
~NetworkConnection();
static void _register_methods();
/* _init must exist as it is called by Godot */
void _init() {};
void define_checksum_msg_xml(Array checksum_msg_xml);
void define_socket_udp(PacketPeerUDP * socketUDP); // Not necessary, but you can define network directly on GdScript
void send_system_login(String host, int64_t port, String user_addr, String user_key, String user_id, String lang);
void send_system_disconnect();
void send_system_quit();
void disconnect_server();
void process(int delta);
int get_state();
};
}
void terminate_network_connection();
#endif // NETWORK_CONNECTION_H

View file

@ -0,0 +1,482 @@
/*
Library to manage network
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/>.
*/
#define DEBUG_ENABLED
#include <Godot.hpp>
#include <core/Defs.hpp>
#include <gen/PacketPeerUDP.hpp>
#include "tools.h"
#include "bitset.h"
#include "bitstream.h"
#include "network_connection_core.h"
#include "state.h"
using namespace godot;
NetworkConnectionCore *NetworkConnectionCore::get_singleton()
{
if ( NetworkConnectionCore::singleton == NULL )
NetworkConnectionCore::singleton = new NetworkConnectionCore();
return NetworkConnectionCore::singleton;
}
NetworkConnectionCore::NetworkConnectionCore()
{
this->_socketUDP = NULL;
this->_state = STATE::NotInitialised ;
}
NetworkConnectionCore::~NetworkConnectionCore()
{
NetworkConnectionCore::singleton = NULL;
this->_state = STATE::NotInitialised ;
}
int NetworkConnectionCore::get_state()
{
return this->_state;
}
void NetworkConnectionCore::define_checksum_msg_xml(Array & checksum_msg_xml)
{
DEBUG_PRINT("Received msg.xml checksum");
this->_checksum_msg_xml = checksum_msg_xml;
DEBUG_PRINT("Received msg.xml checksum " + itos(checksum_msg_xml.size()));
DEBUG_PRINT("Received msg.xml checksum " + itos(this->_checksum_msg_xml.size()));
}
void NetworkConnectionCore::define_socket_udp(PacketPeerUDP * socketUDP)
{
// Use if you define PacketPeerUDP on other script
if ( this->_socketUDP == NULL)
this->_socketUDP = socketUDP;
}
void NetworkConnectionCore::autodefine_socket_udp()
{
// Create socket udp if not defined (If you don't use define_socket_udp)
if ( this->_socketUDP == NULL)
{
PacketPeerUDP::___init_method_bindings();
this->_socketUDP = PacketPeerUDP::_new();
if ( this->_socketUDP == NULL)
throw "Failed to open network";
}
}
void NetworkConnectionCore::send_system_login(String host, int64_t port, String user_addr, String user_key, String user_id, String lang)
{
// Configure socket UDP
this->autodefine_socket_udp();
if ( this->_state != STATE::NotInitialised )
{
DEBUG_PRINT("Close old network socket");
this->_socketUDP->close();
}
INFO_PRINT("Connect to " + host + ":" + itos(port));
this->_socketUDP->set_dest_address(host, port);
// Open connection and send ID
BitStream msgout;
msgout.put_sint32(_current_received_number);
msgout.put_bool(true);
msgout.put_uint8(CLFECOMMON::SYSTEM_LOGIN_CODE);
msgout.put_string_hexa32(user_addr);
msgout.put_string_hexa32(user_key);
msgout.put_string_hexa32(user_id);
msgout.put_string(lang);
godot::Error ret;
ret = this->_socketUDP->put_packet(msgout.get_data());
if ( ret != Error::OK)
{
this->_socketUDP->close();
switch(ret)
{
case Error::ERR_CANT_CONNECT:
ERR_PRINT("network connexion - Can't connect");
default:
ERR_PRINT("network connexion - Unknown error");
}
return;
}
INFO_PRINT("Connected to khganat");
this->_state = STATE::Connected;
// Initialize counter
this->_current_received_number = 0;
this->_last_received_number = 0;
this->_quit_id = 0;
this->_long_ack_bit_field.resize(NUM_BITS_IN_LONG_ACK);
this->_latest_probes.clear();
this->_ack_bit_mask = 0;
this->_last_ack_bit = 0;
this->_last_ack_in_long_ack = 0;
}
void NetworkConnectionCore::send_system_quit()
{
// TODO - check why we send quit_id
if ( this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize )
return;
DEBUG_PRINT("send quit to server");
BitStream msgout;
msgout.put_sint32(this->_current_received_number);
msgout.put_bool(true);
msgout.put_uint8(CLFECOMMON::SYSTEM_QUIT_CODE);
msgout.put_sint32(this->_quit_id);
if ( this->_socketUDP->put_packet(msgout.get_data()) != Error::OK )
{
ERR_PRINT("Error to send disconnect");
}
this->_state = STATE::Quit;
}
void NetworkConnectionCore::send_system_disconnect()
{
if ( this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize )
return;
DEBUG_PRINT("send disconnect to server");
BitStream msgout;
msgout.put_sint32(this->_current_received_number);
msgout.put_bool(true);
msgout.put_uint8(CLFECOMMON::SYSTEM_DISCONNECTION_CODE);
if ( this->_socketUDP->put_packet(msgout.get_data()) != Error::OK )
{
ERR_PRINT("Error to send disconnect");
}
this->_socketUDP->close();
this->_state = STATE::Disconnect;
}
void NetworkConnectionCore::send_system_ack_probe()
{
// khanat-opennel-code/code/ryzom/server/src/frontend_service/fe_receive_sub.cpp:1121 void CFeReceiveSub::handleReceivedMsg( CClientHost *clienthost )
if (this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize)
return;
int max = this->_latest_probes.size();
if (max == 0 )
return;
if (this->_state == STATE::ForceSynchronize && max < 5)
return;
DEBUG_PRINT("send system ACK PROBE to server");
BitStream msgout;
msgout.put_sint32(this->_current_received_number);
msgout.put_bool(true);
msgout.put_uint8(CLFECOMMON::SYSTEM_ACK_PROBE_CODE);
msgout.put_sint32(max);
for(int i=0; i < max ; ++i )
{
//DEBUG_PRINT("i:" + itos(i));
int data = this->_latest_probes[i];
//DEBUG_PRINT("data:" + itos(data));
msgout.put_sint32(data);
//DEBUG_PRINT("updated");
}
if (this->_socketUDP->put_packet(msgout.get_data()) != Error::OK)
{
ERR_PRINT("Error to send disconnect");
return;
}
this->_latest_probes.clear();
if (this->_state == STATE::ForceSynchronize && max >= 5)
{
// We have send ACK, so now we clean all queue and received all message to synchronize
this->queue.clear();
this->_state = STATE::Connected;
}
}
void NetworkConnectionCore::disconnect_server()
{
if (this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize)
return;
send_system_disconnect();
}
void NetworkConnectionCore::decode_system_message(BitStream *msgin)
{
int message = msgin->get_uint8();
switch (message)
{
case CLFECOMMON::SYSTEM_LOGIN_CODE:
DEBUG_PRINT("SYSTEM_LOGIN_CODE");
break;
case CLFECOMMON::SYSTEM_SYNC_CODE:
this->receive_system_sync(msgin);
break;
case CLFECOMMON::SYSTEM_STALLED_CODE:
DEBUG_PRINT("SYSTEM_STALLED_CODE");
break;
case CLFECOMMON::SYSTEM_SERVER_DOWN_CODE:
DEBUG_PRINT("SYSTEM_SERVER_DOWN_CODE");
break;
case CLFECOMMON::SYSTEM_PROBE_CODE:
this->receive_system_probe(msgin);
break;
default:
ERR_PRINT("Received unknown message [" + itos(message) + "]");
break;
}
}
void NetworkConnectionCore::decode_normal_message(BitStream *msgin)
{
DEBUG_PRINT("Decode normal message");
}
void NetworkConnectionCore::receive_system_sync(BitStream * msgin)
{
int i;
bool valide = true;
DEBUG_PRINT("SYSTEM_SYNC_CODE");
uint32_t synchronize = msgin->get_uint32();
int64_t stime = msgin->get_sint64();
uint32_t latestsync = msgin->get_uint32();
PoolByteArray msg_xml = msgin->get_array_uint8(16);
PoolByteArray database_xml = msgin->get_array_uint8(16);
if ( msg_xml.size() != this->_checksum_msg_xml.size() )
{
valide = false;
DEBUG_PRINT("MSG XML is incorrect (server:" + itos(msg_xml.size()) +", client:" + itos(this->_checksum_msg_xml.size()) + ")");
}
else
{
for(i=0; i<msg_xml.size(); ++i)
{
if ( (int) msg_xml[i] != (int) this->_checksum_msg_xml[i] )
{
valide = false;
DEBUG_PRINT("MSG XML is incorrect (pos:" + itos(i) +")");
}
}
}
if ( valide == true )
DEBUG_PRINT("MSG XML is correct");
else
DEBUG_PRINT("MSG.XML is wrong");
/*
self._Synchronize = msg.readUint32('Synchronize')
stime = msg.readSint64('stime')
self._LatestSync = msg.readUint32('LatestSync')
logging.getLogger(LOGGER).debug("%d %d %d" %(self._Synchronize, stime, self._LatestSync))
# khanat-opennel-code/code/ryzom/client/src/network_connection.cpp : void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin)
MsgData = msg.readArrayUint8(16, 'MsgData')
DatabaseData = msg.readArrayUint8(16, 'DatabaseData')
logging.getLogger(LOGGER).debug("MsgData:" + str(MsgData))
logging.getLogger(LOGGER).debug("DatabaseData:" + str(DatabaseData))
md5Msg = bytes(MsgData)
md5Database = bytes(DatabaseData)
if md5Msg == self._MsgXmlMD5:
logging.getLogger(LOGGER).info("Check MD5 msg.xml : OK")
else:
logging.getLogger(LOGGER).error("Check MD5 msg.xml : KO")
if md5Database == self._DatabaseXmlMD5:
logging.getLogger(LOGGER).info("Check MD5 database.xml : OK")
else:
logging.getLogger(LOGGER).error("Check MD5 database.xml : KO")
logging.getLogger(LOGGER).debug("Msg Received:" + msg.showAllData())
self._MsPerTick = 100
self._CurrentServerTick = self._Synchronize + self._CurrentReceivedNumber + 2
self._CurrentClientTick = self._CurrentServerTick - ( self._LCT + self._MsPerTick ) / self._MsPerTick
self._CurrentClientTime = self._UpdateTime - (self._LCT + self._MsPerTick)
*/
}
void NetworkConnectionCore::receive_system_probe(BitStream * msgin)
{
DEBUG_PRINT("SYSTEM_PROBE_CODE size:" + itos(this->_latest_probes.size()));
this->_latest_probes.append(msgin->get_sint32());
}
void NetworkConnectionCore::wait_resynchronize(int32_t current_received_number, BitStream * msgin)
{
bool system_mode;
this->_current_received_number = current_received_number;
system_mode = msgin->get_bool();
if ( system_mode == true )
{
int message = msgin->get_uint8();
switch (message)
{
case CLFECOMMON::SYSTEM_LOGIN_CODE:
DEBUG_PRINT("SYSTEM_LOGIN_CODE");
break;
case CLFECOMMON::SYSTEM_SYNC_CODE:
DEBUG_PRINT("SYSTEM_SYNC_CODE");
break;
case CLFECOMMON::SYSTEM_STALLED_CODE:
DEBUG_PRINT("SYSTEM_STALLED_CODE");
break;
case CLFECOMMON::SYSTEM_SERVER_DOWN_CODE:
DEBUG_PRINT("SYSTEM_SERVER_DOWN_CODE");
break;
case CLFECOMMON::SYSTEM_PROBE_CODE:
this->receive_system_probe(msgin);
break;
default:
ERR_PRINT("Received unknown message [" + itos(message) + "]");
break;
}
}
this->_last_received_number = current_received_number;
}
void NetworkConnectionCore::analyze_message_receieved(int32_t current_received_number, BitStream * msgin)
{
bool system_mode;
bool ackBool = false;
int ackBit = 0;
int i;
this->_current_received_number = current_received_number;
system_mode = msgin->get_bool();
if ( system_mode == true )
{
INFO_PRINT("Received system message");
if (this->_current_received_number == this->_last_received_number + 1)
{
INFO_PRINT("Received message");
}
else if (this->_current_received_number < this->_last_received_number + 1)
{
INFO_PRINT("Received old message");
return;
}
else if (this->_current_received_number > this->_last_received_number + 1)
{
INFO_PRINT("Received message in future (lost some message)");
}
}
else
{
INFO_PRINT("Received normal message");
}
if ( system_mode != true )
{
ackBool = true;
ackBit = 1;
}
if ( current_received_number - this->_last_received_number < 32 )
{
this->_ack_bit_mask <<= current_received_number - this->_last_received_number;
this->_ack_bit_mask |= this->_last_ack_bit << (current_received_number - this->_last_received_number - 1);
}
else if (((current_received_number - this->_last_received_number) == 32) && (this->_last_ack_bit != 0))
this->_ack_bit_mask = 0x80000000;
else
this->_ack_bit_mask = 0x00000000;
this->_last_ack_bit = ackBit;
for(i=this->_last_received_number + 1 ;i < _current_received_number; ++i)
this->_long_ack_bit_field.clear_bit(i & (NUM_BITS_IN_LONG_ACK -1) );
// TODO - what's action when we have rotate onthis number (max -> 0)
if( this->_last_received_number > 0x08000000 )
{
if(this->_last_ack_in_long_ack <= (this->_last_received_number - NUM_BITS_IN_LONG_ACK))
this->_last_ack_in_long_ack = this->_last_received_number - NUM_BITS_IN_LONG_ACK + 1;
this->_last_received_number = current_received_number;
}
else
{
if(this->_last_ack_in_long_ack - 0x80000000 <= (this->_last_received_number - NUM_BITS_IN_LONG_ACK - 0x80000000))
this->_last_ack_in_long_ack = this->_last_received_number - NUM_BITS_IN_LONG_ACK + 1;
this->_last_received_number = current_received_number;
}
if ( system_mode == true )
this->decode_system_message(msgin);
else
this->decode_normal_message(msgin);
}
void NetworkConnectionCore::store_message_received(PoolByteArray & msgbytes)
{
int pos = this->queue.put_msgbytes(msgbytes);
BitStream * msgin = this->queue.get_msg(pos);
int32_t current_received_number = this->queue.get_received_number(pos);
/// TODO - check if max int execeded current_received_number < 1000 this->_last_received_number > 0x80000000
if ( this->_state == STATE::ForceSynchronize )
{
// We have detected a problem of synchro, we wait message ack probe and after server launch a re-sync
wait_resynchronize(current_received_number, msgin);
}
else if ( current_received_number - this->_last_received_number <= 0 ) // Received old message
{
INFO_PRINT("current_received_number : " + itos(current_received_number) + " / queue size : " + itos(this->queue.length()));
this->queue.erase(pos);
return;
}
else if ( this->_last_received_number + 1 == current_received_number ) // Received next message
{
INFO_PRINT("current_received_number : " + itos(current_received_number) + " / queue size : " + itos(this->queue.length()));
analyze_message_receieved(current_received_number, msgin);
this->queue.erase(pos);
}
else // Received new message (but missing some message between) -> go to queue and cross finger to received the next message (for _last_received_number)
{
INFO_PRINT("current_received_number : " + itos(current_received_number) + " / queue size : " + itos(this->queue.length()));
if (this->queue.length() >= SIZE_QUEUE_MESSAGE)
{
ERR_PRINT("Network queue is full / wait re-synchronize");
this->_state = STATE::ForceSynchronize ;
return;
}
}
}
void NetworkConnectionCore::send_message()
{
if ( this->_latest_probes.size() > 0 )
send_system_ack_probe();
}
void NetworkConnectionCore::process(int delta)
{
if (this->_state != STATE::Connected && this->_state != STATE::ForceSynchronize)
return;
//INFO_PRINT( "Process - delta : " + itos(delta));
for(int i = 0; (this->_socketUDP->get_available_packet_count() > 0) && (i < MAX_LOOP_READ_BY_STEP) ; ++i)
{
PoolByteArray msgbytes ;
msgbytes = this->_socketUDP->get_packet();
DEBUG_PRINT("Size msg received : " + itos(msgbytes.size()) );
store_message_received(msgbytes);
}
send_message();
}
void NetworkConnectionCore::terminate_connexion()
{
DEBUG_PRINT("Terminate network connexion");
if ( this->_socketUDP == NULL )
return;
delete this-> _socketUDP;
this->_socketUDP = NULL;
}

View file

@ -0,0 +1,88 @@
/*
Header NetworkConnectionCore
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/>.
*/
#ifndef NETWORK_CONNECTION_CORE_H
#define NETWORK_CONNECTION_CORE_H
#include <Godot.hpp>
#include <gen/PacketPeerUDP.hpp>
#include "bitset.h"
#include "bitstream.h"
#include "clfecommon.h"
#include "store_message.h"
#include "state.h"
#define MAX_LOOP_READ_BY_STEP 10
#define NUM_BITS_IN_LONG_ACK 512
namespace godot {
class NetworkConnectionCore : public Object {
GODOT_CLASS(NetworkConnectionCore, Object)
private:
static NetworkConnectionCore *singleton;
bool _force_resynchronize;
STATE _state;
PacketPeerUDP * _socketUDP;
int32_t _current_received_number;
int32_t _last_received_number;
int32_t _quit_id;
BitSet _long_ack_bit_field;
Array _latest_probes;
Array _checksum_msg_xml;
uint32_t _ack_bit_mask;
int32_t _last_ack_bit;
int32_t _last_ack_in_long_ack;
StoreMessage queue;
public:
static NetworkConnectionCore * get_singleton();
NetworkConnectionCore();
~NetworkConnectionCore();
int get_state();
void define_checksum_msg_xml(Array & checksum_msg_xml);
void define_socket_udp(PacketPeerUDP * socketUDP);
void autodefine_socket_udp();
void send_system_login(String host, int64_t port, String user_addr, String user_key, String user_id, String lang);
void send_system_disconnect();
void send_system_quit();
void disconnect_server();
void send_system_ack_probe();
void decode_system_message(BitStream *msgin);
void decode_normal_message(BitStream *msgin);
void receive_system_sync(BitStream * msgin);
void receive_system_probe(BitStream * msgin);
void wait_resynchronize(int32_t current_received_number, BitStream * msgin);
void analyze_message_receieved(int32_t, BitStream *msgin);
void store_message_received(PoolByteArray & msgbytes);
void send_message();
void process(int delta);
bool connected();
void terminate_connexion();
};
}
#endif

View file

@ -0,0 +1,622 @@
/* SHA512-based Unix crypt implementation.
Released into the Public Domain by Ulrich Drepper <drepper@redhat.com>. */
#include <endian.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/types.h>
/* Structure to save state of computation between the single steps. */
struct sha512_ctx
{
uint64_t H[8];
uint64_t total[2];
uint64_t buflen;
char buffer[256]; /* NB: always correctly aligned for uint64_t. */
};
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define SWAP(n) \
(((n) << 56) \
| (((n) & 0xff00) << 40) \
| (((n) & 0xff0000) << 24) \
| (((n) & 0xff000000) << 8) \
| (((n) >> 8) & 0xff000000) \
| (((n) >> 24) & 0xff0000) \
| (((n) >> 40) & 0xff00) \
| ((n) >> 56))
#else
# define SWAP(n) (n)
#endif
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (FIPS 180-2:5.1.2) */
static const unsigned char fillbuf[128] = { 0x80, 0 /* , 0, 0, ... */ };
/* Constants for SHA512 from FIPS 180-2:4.2.3. */
static const uint64_t K[80] =
{
UINT64_C (0x428a2f98d728ae22), UINT64_C (0x7137449123ef65cd),
UINT64_C (0xb5c0fbcfec4d3b2f), UINT64_C (0xe9b5dba58189dbbc),
UINT64_C (0x3956c25bf348b538), UINT64_C (0x59f111f1b605d019),
UINT64_C (0x923f82a4af194f9b), UINT64_C (0xab1c5ed5da6d8118),
UINT64_C (0xd807aa98a3030242), UINT64_C (0x12835b0145706fbe),
UINT64_C (0x243185be4ee4b28c), UINT64_C (0x550c7dc3d5ffb4e2),
UINT64_C (0x72be5d74f27b896f), UINT64_C (0x80deb1fe3b1696b1),
UINT64_C (0x9bdc06a725c71235), UINT64_C (0xc19bf174cf692694),
UINT64_C (0xe49b69c19ef14ad2), UINT64_C (0xefbe4786384f25e3),
UINT64_C (0x0fc19dc68b8cd5b5), UINT64_C (0x240ca1cc77ac9c65),
UINT64_C (0x2de92c6f592b0275), UINT64_C (0x4a7484aa6ea6e483),
UINT64_C (0x5cb0a9dcbd41fbd4), UINT64_C (0x76f988da831153b5),
UINT64_C (0x983e5152ee66dfab), UINT64_C (0xa831c66d2db43210),
UINT64_C (0xb00327c898fb213f), UINT64_C (0xbf597fc7beef0ee4),
UINT64_C (0xc6e00bf33da88fc2), UINT64_C (0xd5a79147930aa725),
UINT64_C (0x06ca6351e003826f), UINT64_C (0x142929670a0e6e70),
UINT64_C (0x27b70a8546d22ffc), UINT64_C (0x2e1b21385c26c926),
UINT64_C (0x4d2c6dfc5ac42aed), UINT64_C (0x53380d139d95b3df),
UINT64_C (0x650a73548baf63de), UINT64_C (0x766a0abb3c77b2a8),
UINT64_C (0x81c2c92e47edaee6), UINT64_C (0x92722c851482353b),
UINT64_C (0xa2bfe8a14cf10364), UINT64_C (0xa81a664bbc423001),
UINT64_C (0xc24b8b70d0f89791), UINT64_C (0xc76c51a30654be30),
UINT64_C (0xd192e819d6ef5218), UINT64_C (0xd69906245565a910),
UINT64_C (0xf40e35855771202a), UINT64_C (0x106aa07032bbd1b8),
UINT64_C (0x19a4c116b8d2d0c8), UINT64_C (0x1e376c085141ab53),
UINT64_C (0x2748774cdf8eeb99), UINT64_C (0x34b0bcb5e19b48a8),
UINT64_C (0x391c0cb3c5c95a63), UINT64_C (0x4ed8aa4ae3418acb),
UINT64_C (0x5b9cca4f7763e373), UINT64_C (0x682e6ff3d6b2b8a3),
UINT64_C (0x748f82ee5defb2fc), UINT64_C (0x78a5636f43172f60),
UINT64_C (0x84c87814a1f0ab72), UINT64_C (0x8cc702081a6439ec),
UINT64_C (0x90befffa23631e28), UINT64_C (0xa4506cebde82bde9),
UINT64_C (0xbef9a3f7b2c67915), UINT64_C (0xc67178f2e372532b),
UINT64_C (0xca273eceea26619c), UINT64_C (0xd186b8c721c0c207),
UINT64_C (0xeada7dd6cde0eb1e), UINT64_C (0xf57d4f7fee6ed178),
UINT64_C (0x06f067aa72176fba), UINT64_C (0x0a637dc5a2c898a6),
UINT64_C (0x113f9804bef90dae), UINT64_C (0x1b710b35131c471b),
UINT64_C (0x28db77f523047d84), UINT64_C (0x32caab7b40c72493),
UINT64_C (0x3c9ebe0a15c9bebc), UINT64_C (0x431d67c49c100d4c),
UINT64_C (0x4cc5d4becb3e42b6), UINT64_C (0x597f299cfc657e2a),
UINT64_C (0x5fcb6fab3ad6faec), UINT64_C (0x6c44198c4a475817)
};
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 128 == 0. */
static void
sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
{
const uint64_t *words = (uint64_t *)buffer;
size_t nwords = len / sizeof (uint64_t);
uint64_t a = ctx->H[0];
uint64_t b = ctx->H[1];
uint64_t c = ctx->H[2];
uint64_t d = ctx->H[3];
uint64_t e = ctx->H[4];
uint64_t f = ctx->H[5];
uint64_t g = ctx->H[6];
uint64_t h = ctx->H[7];
/* First increment the byte count. FIPS 180-2 specifies the possible
length of the file up to 2^128 bits. Here we only compute the
number of bytes. Do a double word increment. */
ctx->total[0] += len;
if (ctx->total[0] < len)
++ctx->total[1];
/* Process all bytes in the buffer with 128 bytes in each round of
the loop. */
while (nwords > 0)
{
uint64_t W[80];
uint64_t a_save = a;
uint64_t b_save = b;
uint64_t c_save = c;
uint64_t d_save = d;
uint64_t e_save = e;
uint64_t f_save = f;
uint64_t g_save = g;
uint64_t h_save = h;
/* Operators defined in FIPS 180-2:4.1.2. */
#define Ch(x, y, z) ((x & y) ^ (~x & z))
#define Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
#define S0(x) (CYCLIC (x, 28) ^ CYCLIC (x, 34) ^ CYCLIC (x, 39))
#define S1(x) (CYCLIC (x, 14) ^ CYCLIC (x, 18) ^ CYCLIC (x, 41))
#define R0(x) (CYCLIC (x, 1) ^ CYCLIC (x, 8) ^ (x >> 7))
#define R1(x) (CYCLIC (x, 19) ^ CYCLIC (x, 61) ^ (x >> 6))
/* It is unfortunate that C does not provide an operator for
cyclic rotation. Hope the C compiler is smart enough. */
#define CYCLIC(w, s) ((w >> s) | (w << (64 - s)))
/* Compute the message schedule according to FIPS 180-2:6.3.2 step 2. */
for (unsigned int t = 0; t < 16; ++t)
{
W[t] = SWAP (*words);
++words;
}
for (unsigned int t = 16; t < 80; ++t)
W[t] = R1 (W[t - 2]) + W[t - 7] + R0 (W[t - 15]) + W[t - 16];
/* The actual computation according to FIPS 180-2:6.3.2 step 3. */
for (unsigned int t = 0; t < 80; ++t)
{
uint64_t T1 = h + S1 (e) + Ch (e, f, g) + K[t] + W[t];
uint64_t T2 = S0 (a) + Maj (a, b, c);
h = g;
g = f;
f = e;
e = d + T1;
d = c;
c = b;
b = a;
a = T1 + T2;
}
/* Add the starting values of the context according to FIPS 180-2:6.3.2
step 4. */
a += a_save;
b += b_save;
c += c_save;
d += d_save;
e += e_save;
f += f_save;
g += g_save;
h += h_save;
/* Prepare for the next round. */
nwords -= 16;
}
/* Put checksum in context given as argument. */
ctx->H[0] = a;
ctx->H[1] = b;
ctx->H[2] = c;
ctx->H[3] = d;
ctx->H[4] = e;
ctx->H[5] = f;
ctx->H[6] = g;
ctx->H[7] = h;
}
/* Initialize structure containing state of computation.
(FIPS 180-2:5.3.3) */
static void
sha512_init_ctx (struct sha512_ctx *ctx)
{
ctx->H[0] = UINT64_C (0x6a09e667f3bcc908);
ctx->H[1] = UINT64_C (0xbb67ae8584caa73b);
ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b);
ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1);
ctx->H[4] = UINT64_C (0x510e527fade682d1);
ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f);
ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b);
ctx->H[7] = UINT64_C (0x5be0cd19137e2179);
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
}
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
static void *
sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
{
/* Take yet unprocessed bytes into account. */
uint64_t bytes = ctx->buflen;
size_t pad;
/* Now count remaining bytes. */
ctx->total[0] += bytes;
if (ctx->total[0] < bytes)
++ctx->total[1];
pad = bytes >= 112 ? 128 + 112 - bytes : 112 - bytes;
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 128-bit file length in *bits* at the end of the buffer. */
*(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP (ctx->total[0] << 3);
*(uint64_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
(ctx->total[0] >> 61));
/* Process last bytes. */
sha512_process_block (ctx->buffer, bytes + pad + 16, ctx);
/* Put result from CTX in first 64 bytes following RESBUF. */
for (unsigned int i = 0; i < 8; ++i)
((uint64_t *) resbuf)[i] = SWAP (ctx->H[i]);
return resbuf;
}
static void
sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
{
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
if (ctx->buflen != 0)
{
size_t left_over = ctx->buflen;
size_t add = 256 - left_over > len ? len : 256 - left_over;
memcpy (&ctx->buffer[left_over], buffer, add);
ctx->buflen += add;
if (ctx->buflen > 128)
{
sha512_process_block (ctx->buffer, ctx->buflen & ~127, ctx);
ctx->buflen &= 127;
/* The regions in the following copy operation cannot overlap. */
memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~127],
ctx->buflen);
}
buffer = (const char *) buffer + add;
len -= add;
}
/* Process available complete blocks. */
if (len >= 128)
{
#if !_STRING_ARCH_unaligned
/* To check alignment gcc has an appropriate operator. Other
compilers don't. */
# if __GNUC__ >= 2
# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint64_t) != 0)
# else
# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (uint64_t) != 0)
# endif
if (UNALIGNED_P (buffer))
while (len > 128)
{
sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128,
ctx);
buffer = (const char *) buffer + 128;
len -= 128;
}
else
#endif
{
sha512_process_block (buffer, len & ~127, ctx);
buffer = (const char *) buffer + (len & ~127);
len &= 127;
}
}
/* Move remaining bytes into internal buffer. */
if (len > 0)
{
size_t left_over = ctx->buflen;
memcpy (&ctx->buffer[left_over], buffer, len);
left_over += len;
if (left_over >= 128)
{
sha512_process_block (ctx->buffer, 128, ctx);
left_over -= 128;
memcpy (ctx->buffer, &ctx->buffer[128], left_over);
}
ctx->buflen = left_over;
}
}
/* Define our magic string to mark salt for SHA512 "encryption"
replacement. */
static const char sha512_salt_prefix[] = "$6$";
/* Prefix for optional rounds specification. */
static const char sha512_rounds_prefix[] = "rounds=";
/* Maximum salt string length. */
#define SALT_LEN_MAX 16
/* Default number of rounds if not explicitly specified. */
#define ROUNDS_DEFAULT 5000
/* Minimum number of rounds. */
#define ROUNDS_MIN 1000
/* Maximum number of rounds. */
#define ROUNDS_MAX 999999999
/* Table with characters for base64 transformation. */
static const char b64t[65] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static char *
sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen)
{
unsigned char alt_result[64]
__attribute__ ((__aligned__ (__alignof__ (uint64_t))));
unsigned char temp_result[64]
__attribute__ ((__aligned__ (__alignof__ (uint64_t))));
struct sha512_ctx ctx;
struct sha512_ctx alt_ctx;
size_t salt_len;
size_t key_len;
size_t cnt;
char *cp;
char *copied_key = NULL;
char *copied_salt = NULL;
char *p_bytes;
char *s_bytes;
/* Default number of rounds. */
size_t rounds = ROUNDS_DEFAULT;
bool rounds_custom = false;
/* Find beginning of salt string. The prefix should normally always
be present. Just in case it is not. */
if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0)
/* Skip salt prefix. */
salt += sizeof (sha512_salt_prefix) - 1;
if (strncmp (salt, sha512_rounds_prefix, sizeof (sha512_rounds_prefix) - 1)
== 0)
{
const char *num = salt + sizeof (sha512_rounds_prefix) - 1;
char *endp;
unsigned long int srounds = strtoul (num, &endp, 10);
if (*endp == '$')
{
salt = endp + 1;
rounds = MAX (ROUNDS_MIN, MIN (srounds, ROUNDS_MAX));
rounds_custom = true;
}
}
salt_len = MIN (strcspn (salt, "$"), SALT_LEN_MAX);
key_len = strlen (key);
if ((key - (char *) 0) % __alignof__ (uint64_t) != 0)
{
char *tmp = (char *) alloca (key_len + __alignof__ (uint64_t));
key = copied_key = (char *)
memcpy (tmp + __alignof__ (uint64_t)
- (tmp - (char *) 0) % __alignof__ (uint64_t),
key, key_len);
}
if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0)
{
char *tmp = (char *) alloca (salt_len + __alignof__ (uint64_t));
salt = copied_salt = (char *)
memcpy (tmp + __alignof__ (uint64_t)
- (tmp - (char *) 0) % __alignof__ (uint64_t),
salt, salt_len);
}
/* Prepare for the real work. */
sha512_init_ctx (&ctx);
/* Add the key string. */
sha512_process_bytes (key, key_len, &ctx);
/* The last part is the salt string. This must be at most 16
characters and it ends at the first `$' character (for
compatibility with existing implementations). */
sha512_process_bytes (salt, salt_len, &ctx);
/* Compute alternate SHA512 sum with input KEY, SALT, and KEY. The
final result will be added to the first context. */
sha512_init_ctx (&alt_ctx);
/* Add key. */
sha512_process_bytes (key, key_len, &alt_ctx);
/* Add salt. */
sha512_process_bytes (salt, salt_len, &alt_ctx);
/* Add key again. */
sha512_process_bytes (key, key_len, &alt_ctx);
/* Now get result of this (64 bytes) and add it to the other
context. */
sha512_finish_ctx (&alt_ctx, alt_result);
/* Add for any character in the key one byte of the alternate sum. */
for (cnt = key_len; cnt > 64; cnt -= 64)
sha512_process_bytes (alt_result, 64, &ctx);
sha512_process_bytes (alt_result, cnt, &ctx);
/* Take the binary representation of the length of the key and for every
1 add the alternate sum, for every 0 the key. */
for (cnt = key_len; cnt > 0; cnt >>= 1)
if ((cnt & 1) != 0)
sha512_process_bytes (alt_result, 64, &ctx);
else
sha512_process_bytes (key, key_len, &ctx);
/* Create intermediate result. */
sha512_finish_ctx (&ctx, alt_result);
/* Start computation of P byte sequence. */
sha512_init_ctx (&alt_ctx);
/* For every character in the password add the entire password. */
for (cnt = 0; cnt < key_len; ++cnt)
sha512_process_bytes (key, key_len, &alt_ctx);
/* Finish the digest. */
sha512_finish_ctx (&alt_ctx, temp_result);
/* Create byte sequence P. */
cp = p_bytes = (char *)alloca (key_len);
for (cnt = key_len; cnt >= 64; cnt -= 64)
cp = (char *)mempcpy (cp, temp_result, 64);
memcpy (cp, temp_result, cnt);
/* Start computation of S byte sequence. */
sha512_init_ctx (&alt_ctx);
/* For every character in the password add the entire password. */
for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
sha512_process_bytes (salt, salt_len, &alt_ctx);
/* Finish the digest. */
sha512_finish_ctx (&alt_ctx, temp_result);
/* Create byte sequence S. */
cp = s_bytes = (char *)alloca (salt_len);
for (cnt = salt_len; cnt >= 64; cnt -= 64)
cp = (char *)mempcpy ( cp, temp_result, 64);
memcpy (cp, temp_result, cnt);
/* Repeatedly run the collected hash value through SHA512 to burn
CPU cycles. */
for (cnt = 0; cnt < rounds; ++cnt)
{
/* New context. */
sha512_init_ctx (&ctx);
/* Add key or last result. */
if ((cnt & 1) != 0)
sha512_process_bytes (p_bytes, key_len, &ctx);
else
sha512_process_bytes (alt_result, 64, &ctx);
/* Add salt for numbers not divisible by 3. */
if (cnt % 3 != 0)
sha512_process_bytes (s_bytes, salt_len, &ctx);
/* Add key for numbers not divisible by 7. */
if (cnt % 7 != 0)
sha512_process_bytes (p_bytes, key_len, &ctx);
/* Add key or last result. */
if ((cnt & 1) != 0)
sha512_process_bytes (alt_result, 64, &ctx);
else
sha512_process_bytes (p_bytes, key_len, &ctx);
/* Create intermediate result. */
sha512_finish_ctx (&ctx, alt_result);
}
/* Now we can construct the result string. It consists of three
parts. */
cp = __stpncpy (buffer, sha512_salt_prefix, MAX (0, buflen));
buflen -= sizeof (sha512_salt_prefix) - 1;
if (rounds_custom)
{
int n = snprintf (cp, MAX (0, buflen), "%s%zu$",
sha512_rounds_prefix, rounds);
cp += n;
buflen -= n;
}
cp = __stpncpy (cp, salt, MIN ((size_t) MAX (0, buflen), salt_len));
buflen -= MIN ((size_t) MAX (0, buflen), salt_len);
if (buflen > 0)
{
*cp++ = '$';
--buflen;
}
#define b64_from_24bit(B2, B1, B0, N) \
do { \
unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0); \
int n = (N); \
while (n-- > 0 && buflen > 0) \
{ \
*cp++ = b64t[w & 0x3f]; \
--buflen; \
w >>= 6; \
} \
} while (0)
b64_from_24bit (alt_result[0], alt_result[21], alt_result[42], 4);
b64_from_24bit (alt_result[22], alt_result[43], alt_result[1], 4);
b64_from_24bit (alt_result[44], alt_result[2], alt_result[23], 4);
b64_from_24bit (alt_result[3], alt_result[24], alt_result[45], 4);
b64_from_24bit (alt_result[25], alt_result[46], alt_result[4], 4);
b64_from_24bit (alt_result[47], alt_result[5], alt_result[26], 4);
b64_from_24bit (alt_result[6], alt_result[27], alt_result[48], 4);
b64_from_24bit (alt_result[28], alt_result[49], alt_result[7], 4);
b64_from_24bit (alt_result[50], alt_result[8], alt_result[29], 4);
b64_from_24bit (alt_result[9], alt_result[30], alt_result[51], 4);
b64_from_24bit (alt_result[31], alt_result[52], alt_result[10], 4);
b64_from_24bit (alt_result[53], alt_result[11], alt_result[32], 4);
b64_from_24bit (alt_result[12], alt_result[33], alt_result[54], 4);
b64_from_24bit (alt_result[34], alt_result[55], alt_result[13], 4);
b64_from_24bit (alt_result[56], alt_result[14], alt_result[35], 4);
b64_from_24bit (alt_result[15], alt_result[36], alt_result[57], 4);
b64_from_24bit (alt_result[37], alt_result[58], alt_result[16], 4);
b64_from_24bit (alt_result[59], alt_result[17], alt_result[38], 4);
b64_from_24bit (alt_result[18], alt_result[39], alt_result[60], 4);
b64_from_24bit (alt_result[40], alt_result[61], alt_result[19], 4);
b64_from_24bit (alt_result[62], alt_result[20], alt_result[41], 4);
b64_from_24bit (0, 0, alt_result[63], 2);
if (buflen <= 0)
{
errno = ERANGE;
buffer = NULL;
}
else
*cp = '\0'; /* Terminate the string. */
/* Clear the buffer for the intermediate result so that people
attaching to processes or reading core dumps cannot get any
information. We do it in this way to clear correct_words[]
inside the SHA512 implementation as well. */
sha512_init_ctx (&ctx);
sha512_finish_ctx (&ctx, alt_result);
memset (temp_result, '\0', sizeof (temp_result));
memset (p_bytes, '\0', key_len);
memset (s_bytes, '\0', salt_len);
memset (&ctx, '\0', sizeof (ctx));
memset (&alt_ctx, '\0', sizeof (alt_ctx));
if (copied_key != NULL)
memset (copied_key, '\0', key_len);
if (copied_salt != NULL)
memset (copied_salt, '\0', salt_len);
return buffer;
}
/* This entry point is equivalent to the `crypt' function in Unix
libcs. */
char *
sha512_crypt (const char *key, const char *salt)
{
/* We don't want to have an arbitrary limit in the size of the
password. We can compute an upper bound for the size of the
result in advance and so we can prepare the buffer we pass to
`sha512_crypt_r'. */
static char *buffer = NULL;
static int buflen = 0;
int needed = (sizeof (sha512_salt_prefix) - 1
+ sizeof (sha512_rounds_prefix) + 9 + 1
+ strlen (salt) + 1 + 86 + 1);
if (buflen < needed)
{
char *new_buffer = (char *) realloc (buffer, needed);
if (new_buffer == NULL)
return NULL;
buffer = new_buffer;
buflen = needed;
}
return sha512_crypt_r (key, salt, buffer, buflen);
}

View file

@ -0,0 +1,6 @@
#ifndef SHA512CRYPT_H
#define SHA512CRYPT_H
char * sha512_crypt (const char *key, const char *salt);
#endif

38
gdnative/src/state.h Normal file
View file

@ -0,0 +1,38 @@
/*
Header STATE : to know state of client
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/>.
*/
#ifndef STATE_H
#define STATE_H
enum STATE {
NotInitialised = 0,
//NotConnected = 1, // When received a cookie - not used here
//Authenticate = 2,
//Login = 3,
// Synchronize = 4,
Connected = 5, // State when we are connecte
//Probe = 6,
//Stalled = 7,
Disconnect = 8,
Quit = 9,
ForceSynchronize = 10
};
#endif // STATE_H

View file

@ -0,0 +1,127 @@
/*
StoreMessage : class to manage packet received by khaganat
If we received message with bad order, with this class we can manage (with limit storage)
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/>.
*/
#include <Godot.hpp>
#include <core/Defs.hpp>
#include "bitstream.h"
#include "tools.h"
#include "store_message.h"
using namespace godot;
StoreMessage::StoreMessage()
{
this->clear();
}
StoreMessage::~StoreMessage()
{
}
void StoreMessage::clear()
{
for(int i = 0 ; i < SIZE_QUEUE_MESSAGE ; ++i )
{
//this->_empty[i] = true;
this->_received_number[i] = 0;
this->_msgin[i].clear();
}
this->_size = 0;
}
int StoreMessage::length()
{
return this->_size;
}
int StoreMessage::put_msgbytes(PoolByteArray & msgbytes)
{
int i = 0;
int ii ;
//while((this->_empty[i] != true)&&(i < SIZE_QUEUE_MESSAGE))
while((i < SIZE_QUEUE_MESSAGE)&&(this->_msgin[i].size_data() != 0))
++i;
if(i >= SIZE_QUEUE_MESSAGE) // Out of memory
{
ERR_PRINT("Network queue is full (" + itos(i) + " / " + itos(SIZE_QUEUE_MESSAGE) + ")");
throw "Out of memory";
}
//INFO_PRINT("-> i:" + itos(i) + "/" + itos(this->_size) + " State:" + itos(this->_msgin[i].size_data()) + " num:" + itos(this->_received_number[i]));
//INFO_PRINT("i:" + itos(i) + " / " + itos(SIZE_QUEUE_MESSAGE) );
this->_msgin[i].put_data(msgbytes);
int32_t current_received_number = this->_msgin[i].get_sint32();
this->_received_number[i] = current_received_number;
// Check we don't have other message with same _received_number (also remove it)
ii = i + 1;
while(ii < SIZE_QUEUE_MESSAGE)
{
if ( this->_received_number[ii] == current_received_number)
this->erase(ii);
++ii;
}
this->_size ++;
/*
for(int ii = 0 ; ii < SIZE_QUEUE_MESSAGE ; ++ii)
{
INFO_PRINT(itos(ii) + ") i:" + itos(i) + "/" + itos(this->_size) + " State:" + itos(this->_msgin[ii].size_data()) + " num:" + itos(this->_received_number[ii]));
}
*/
return i;
}
BitStream * StoreMessage::get_msg(int pos)
{
if ( pos >= SIZE_QUEUE_MESSAGE )
{
ERR_PRINT("Try to get data out of memory");
throw "Out of memory";
}
return & this->_msgin[pos];
}
int32_t StoreMessage::get_received_number(int pos)
{
if ( pos >= SIZE_QUEUE_MESSAGE )
{
ERR_PRINT("Try to get data out of memory");
throw "Out of memory";
}
return this->_received_number[pos];
}
void StoreMessage::erase(int pos)
{
if ( pos >= SIZE_QUEUE_MESSAGE )
{
ERR_PRINT("Try to erase data out of memory");
return;
}
//this->_empty[pos] = true;
this->_received_number[pos] = 0;
this->_msgin[pos].clear();
this->_size -- ;
}

View file

@ -0,0 +1,47 @@
/*
Header StoreMessage : message send by server
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/>.
*/
#ifndef STORE_MESSAGE_H
#define STORE_MESSAGE_H
#define SIZE_QUEUE_MESSAGE 6
namespace godot {
class StoreMessage
{
// bool _empty[SIZE_QUEUE_MESSAGE];
int32_t _received_number[SIZE_QUEUE_MESSAGE];
BitStream _msgin[SIZE_QUEUE_MESSAGE];
int _size;
public:
StoreMessage();
~StoreMessage();
void clear();
int length();
int put_msgbytes(PoolByteArray & msgbytes);
BitStream * get_msg(int pos);
int32_t get_received_number(int pos);
void erase(int pos);
};
}
#endif // STORE_MESSAGE_H

29
gdnative/src/tools.cpp Normal file
View file

@ -0,0 +1,29 @@
/*
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/>.
*/
#include <Godot.hpp>
#include <core/Defs.hpp>
#include "tools.h"
using namespace godot;
String godot::itos(int64_t p_val)
{
return String::num_int64(p_val);
}

44
gdnative/src/tools.h Normal file
View file

@ -0,0 +1,44 @@
/*
Header Tools
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/>.
*/
#ifndef TOOLS_H
#define TOOLS_H
#include <Godot.hpp>
namespace godot {
String itos(int64_t p_val);
#define INFO_PRINT(msg) Godot::print( String(__FUNCTION__) + ":" + String(__FILE__) + ":" + itos( __LINE__) + " " + String(msg))
#ifdef DEBUG_ENABLED
#define DEBUG_PRINT(msg) Godot::print( String(__FUNCTION__) + ":" + String(__FILE__) + ":" + itos( __LINE__) + " " + String(msg))
#else
#define DEBUG_PRINT(msg)
#endif
}
#endif // STORE_MESSAGE_H

52
gdnative/test/bitset.gd Normal file
View file

@ -0,0 +1,52 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func test_resize():
var bitset = preload("res://bitset.gdns").new()
print ("[bitset:test_resize]")
bitset.resize(1024)
func test_put():
var bitset = preload("res://bitset.gdns").new()
print ("[bitset:test_init]")
bitset.resize(1024)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
bitset.put(1, 1)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
bitset.put(2, 1)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
bitset.put(1, 0)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
func test_alloc():
var BitSet = preload("res://bitset.gdns")
print ("[bitset:test_alloc]")
var tab = {}
tab[1478] = BitSet.new()
assert( tab.size() == 1 )
tab[1479] = BitSet.new()
assert( tab.size() == 2 )
tab.erase(1478)
assert( tab.size() == 1 )
func test():
print("[bitset] Start check -> start")
test_resize()
test_put()
test_alloc()
print("[bitset] Start check -> end")

219
gdnative/test/bitstream.gd Normal file
View file

@ -0,0 +1,219 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func test_bool_true():
var bitstream = preload("res://bitstream.gdns").new()
bitstream.put_bool(true)
var res = bitstream.show()
assert(res == "1")
func test_bool_false():
var bitstream = preload("res://bitstream.gdns").new()
bitstream.put_bool(false)
var res = bitstream.show()
assert(res == "0")
func test_uint8():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_uint8(18)
res = bitstream.show()
#print(res)
assert(res == "00010010")
bitstream.put_uint8(255)
res = bitstream.show()
#print(res)
assert(res == "0001001011111111")
# trunc number if more 255 (1205 -> 226)
bitstream.put_uint8(1250)
res = bitstream.show()
#print(res)
assert(res == "000100101111111111100010")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_uint8("A")
res = bitstream.show()
#print(res)
assert(res == "00010010111111111110001000000000")
func test_sint8():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_sint8(-18)
res = bitstream.show()
#print(res)
assert(res == "11101110")
bitstream.put_sint8(-1)
res = bitstream.show()
#print(res)
assert(res == "1110111011111111")
# trunc number, reduce number bit
bitstream.put_sint8(-1250)
res = bitstream.show()
#print(res)
assert(res == "111011101111111100011110")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_sint8("A")
res = bitstream.show()
#print(res)
assert(res == "11101110111111110001111000000000")
func test_uint16():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_uint16(18)
res = bitstream.show()
#print(res)
assert(res == "0000000000010010")
bitstream.put_uint16(65535)
res = bitstream.show()
#print(res)
assert(res == "00000000000100101111111111111111")
# trunc number, reduce number bit
bitstream.put_uint16(14597)
res = bitstream.show()
#print(res)
assert(res == "000000000001001011111111111111110011100100000101")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_uint16("A")
res = bitstream.show()
#print(res)
assert(res == "0000000000010010111111111111111100111001000001010000000000000000")
func test_sint16():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_sint16(-18)
res = bitstream.show()
#print(res)
assert(res == "1111111111101110")
bitstream.put_sint16(-1)
res = bitstream.show()
#print(res)
assert(res == "11111111111011101111111111111111")
# trunc number, reduce number bit
bitstream.put_sint16(-1250)
res = bitstream.show()
#print(res)
assert(res == "111111111110111011111111111111111111101100011110")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_sint16("A")
res = bitstream.show()
#print(res)
assert(res == "1111111111101110111111111111111111111011000111100000000000000000")
func test_uint32():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_uint32(1459747891)
res = bitstream.show()
#print(res)
assert(res == "01010111000000011111110000110011")
bitstream.put_uint32(4294967295)
res = bitstream.show()
#print(res)
assert(res == "0101011100000001111111000011001111111111111111111111111111111111")
# trunc number, reduce number bit
bitstream.put_uint32(14597)
res = bitstream.show()
#print(res)
assert(res == "010101110000000111111100001100111111111111111111111111111111111100000000000000000011100100000101")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_uint32("A")
res = bitstream.show()
#print(res)
assert(res == "01010111000000011111110000110011111111111111111111111111111111110000000000000000001110010000010100000000000000000000000000000000")
func test_sint32():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_sint32(-18)
res = bitstream.show()
#print(res)
assert(res == "11111111111111111111111111101110")
bitstream.put_sint32(-1)
res = bitstream.show()
#print(res)
assert(res == "1111111111111111111111111110111011111111111111111111111111111111")
# trunc number, reduce number bit
bitstream.put_sint32(-1250)
res = bitstream.show()
#print(res)
assert(res == "111111111111111111111111111011101111111111111111111111111111111111111111111111111111101100011110")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_sint32("A")
res = bitstream.show()
#print(res)
assert(res == "11111111111111111111111111101110111111111111111111111111111111111111111111111111111110110001111000000000000000000000000000000000")
func test_string_hexa32():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_string_hexa32(1)
res = bitstream.show()
#print(res)
assert(res == "00000000000000000000000000000001")
bitstream.put_string_hexa32("DEADBEAF")
res = bitstream.show()
#print(res)
assert(res == "0000000000000000000000000000000111011110101011011011111010101111")
bitstream = preload("res://bitstream.gdns").new()
bitstream.put_string_hexa32("010011AC")
res = bitstream.show()
#print(res)
assert(res == "00000001000000000001000110101100")
func test_char():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_char(1)
res = bitstream.show()
#print(res)
assert(res == "00110001")
bitstream.put_char("A")
res = bitstream.show()
#print(res)
assert(res == "0011000101000001")
func test_string():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_string(1)
res = bitstream.show()
#print(res)
assert(res == "0000000000000000000000000000000100110001")
bitstream.put_string("FR")
res = bitstream.show()
#print(res)
assert(res == "0000000000000000000000000000000100110001000000000000000000000000000000100100011001010010")
func test_little_endian():
var bitstream = preload("res://bitstream.gdns").new()
var res = bitstream.is_little_endian()
print ("[bitstream] little endian : " + str(res))
func test():
print("[bitstream] Start check -> start")
test_little_endian()
test_bool_true()
test_bool_false()
test_uint8()
test_sint8()
test_uint16()
test_sint16()
test_uint32()
test_sint32()
test_string_hexa32()
test_char()
test_string()
print("[bitstream] Start check -> end")

22
gdnative/test/crypt.gd Normal file
View file

@ -0,0 +1,22 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func test():
print("[crypt] Start check -> start")
var crypt = load("res://crypt.gdns").new()
var salt = "$6$mZ3k4xrnvjLM8dV6"
var password = "tester"
var crypted = crypt.encrypt(password, salt)
assert(crypted == "$6$mZ3k4xrnvjLM8dV6$EbOqHNpkzyniUgcf19E2JZHB3bl9.7sWN.ChIjtUiuMtsJIbINbYA0//HRWiKB2U6c7NniJgiACmidYBtsnJ71")
print("[crypt] Start check -> end")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View file

@ -23,15 +23,27 @@ var old_scene = null
var parent_scene = null
var current_map = null
var current_start_position = "start_position"
var current_state = "login"
var font_size= 14
func launch_gdscript_test():
print("[global] Launch test gdscript -> Start")
var crypt = preload("res://gdnative/test/crypt.gd").new()
crypt.test()
var bitstream = preload("res://gdnative/test/bitstream.gd").new()
bitstream.test()
var bitset = preload("res://gdnative/test/bitset.gd").new()
bitset.test()
print("[global] Launch test gdscript -> End")
return true
func _ready():
var root = get_tree().get_root()
# current_scene = root.get_child(root.get_child_count() -1)
assert(launch_gdscript_test() == true)
change_title()
get_tree().get_root().connect("size_changed", self, "on_window_size_changed")
@ -43,15 +55,15 @@ func _ready():
#### change title ####
func on_window_size_changed():
change_title()
func change_title():
var title = "Khanat"
var title = "Khanat"
if has_node( WINDOW_TITLE_INPUT ):
var title_node = get_node( WINDOW_TITLE_INPUT )
if title_node and not title_node.text.strip_edges() == "":
title = title_node.text.strip_edges()
title += " (" + String(OS.get_window_size().x) + "x" + String(OS.get_window_size().y) + ")"
OS.set_window_title( title )
########
@ -68,25 +80,25 @@ func load_scene( scene_path ):
if loader == null: # check for errors
return false
return true
func change_level( p_next_state, p_next_scene_path, p_parent_next_scene = null, p_old_scene = null, p_start_position = "start_position" ):
if not load_scene( p_next_scene_path ):
print( "Erreur lors du chargement de la scene: "+str(p_next_scene_path) )
return
character.hide()
# get_node("background_loader/center_container").rect_min_size = get_viewport().size
progress_texture.rect_min_size = get_viewport().size
get_node("background_loader").show()
self.current_start_position = p_start_position
parent_scene = p_parent_next_scene
old_scene = p_old_scene
set_process(true)
if old_scene:
unload_scene( old_scene )
@ -94,7 +106,7 @@ func change_level( p_next_state, p_next_scene_path, p_parent_next_scene = null,
self.current_state = p_next_state
########
func _process( time ):
########
#### LOADER
@ -108,7 +120,7 @@ func _process( time ):
return
var t = OS.get_ticks_msec()
while OS.get_ticks_msec() < t + time_max: # use "time_max" to control how much time we block this thread
while OS.get_ticks_msec() < t + time_max: # use "time_max" to control how much time we block this thread
# poll your loader
var err = loader.poll()
# update_progress()
@ -127,7 +139,7 @@ func _process( time ):
loader = null
break
########
func _input( event ):
if current_state == "game" and event is InputEventKey and not event.is_echo():
@ -138,43 +150,43 @@ func _input( event ):
elif event.is_action_pressed("test_change_map_3"):
global.change_level( "game", "res://game_scene/game_scene.tscn", null, current_map )
func update_progress():
var progress = (float(loader.get_stage()) / loader.get_stage_count()) * (progress_texture.max_value-progress_texture.min_value)
progress_texture.value = progress_texture.min_value+progress
func set_new_scene( scene_resource ):
func set_new_scene( scene_resource ):
progress_texture.value = 0
var scene = scene_resource.instance()
# current_scene = scene_resource.instance()
if parent_scene:
parent_scene.add_child(scene)
else:
get_tree().get_root().add_child(scene)
print( "scene: "+str(scene.name) )
print( "start position: " + str(self.current_start_position ) )
if scene.has_node( self.current_start_position ):
print( "OK" )
character.update( scene.get_node( self.current_start_position ) )
current_map = scene
get_node("background_loader").hide()
character.show()
func _on_login_scene_character_creation_finished():
self.change_level( "game", "res://game_scene/game_scene.tscn", null, get_tree().get_root().get_node("login_scene") )
func _on_logout_button_pressed():
self.change_level( "login", "res://login_scene/login_scene.tscn", null, current_map )
get_tree().paused = false

View file

@ -14,4 +14,3 @@ script = ExtResource( 1 )
visible = false
[node name="audio_stream_player" type="AudioStreamPlayer" parent="."]

1
godot-cpp Submodule

@ -0,0 +1 @@
Subproject commit 123d9f0e9264dcc7206888fc96419b32feef00c8

View file

@ -7,7 +7,7 @@ func _ready():
var config_file = ConfigFile.new()
var err = config_file.load( HUD_config_file )
if err:
print("Error code when loading config file: ", err)
print("[res://gui_scene/GUI/HUD/HUD.gd:_ready] Error code when loading config file: ", err)
else:
for child in get_node("Windows" ).get_children():
child.load_from_file( config_file )
@ -15,13 +15,13 @@ func _ready():
func _input( event ):
if event.is_action_pressed( "ui_music_controls" ):
$Windows/Music.visible = not $Windows/Music.visible
func _on_SaveHUD_pressed():
var config_file = ConfigFile.new()
var err = config_file.load( HUD_config_file )
if err:
print("Error code when loading config file: ", err)
print("[res://gui_scene/GUI/HUD/HUD.gd:_on_SaveHUD_pressed] Error code when loading config file: ", err)
for child in get_node("Windows" ).get_children():

View file

@ -5,12 +5,12 @@ var current_song = ""
var current_position = 0.0
var popup
func _ready():
for song in $Songs.get_children():
func _ready():
for song in $Songs.get_children():
songs_list.append( song.name )
if $Songs.get_child_count() > 0:
current_song = songs_list[0]
popup = $SongsSelector.get_popup()
for song in songs_list:
@ -30,7 +30,7 @@ func set_pause():
get_node( "Songs" ).get_node( current_song ).stop()
else:
current_position = 0.0
$Buttons/Pause.text = "Play"
$Title.text = "Musiques (Paused):"
@ -41,7 +41,7 @@ func set_stop():
$Buttons/Pause.pressed = false
$Buttons/Pause.text = "Play"
$Title.text = "Musiques (Stopped):"
func _on_Pause_toggled(button_pressed):
if button_pressed:
set_play()
@ -56,7 +56,7 @@ func _on_SongsSelector_item_selected(ID):
if not current_song == new_song:
set_stop()
current_song = popup.get_item_text(ID)
func _on_song_finished():
print("test")
set_stop()

View file

@ -64,7 +64,6 @@ custom_colors/font_color = Color( 0.494118, 0.411765, 0.658824, 1 )
custom_colors/font_color_hover = Color( 0.863051, 0.203209, 1, 1 )
custom_colors/font_color_pressed = Color( 0.673295, 0.508021, 1, 1 )
text = "Stop"
[connection signal="item_selected" from="SongsSelector" to="." method="_on_SongsSelector_item_selected"]
[connection signal="toggled" from="Buttons/Pause" to="." method="_on_Pause_toggled"]
[connection signal="pressed" from="Buttons/Stop" to="." method="_on_Stop_pressed"]

View file

@ -9,8 +9,10 @@ func _ready():
$Menus/TabContainer/Display/ScrollContainer/VBoxContainer/Resizable/CheckBox.pressed = ProjectSettings.get_setting( "display/window/size/resizable" )
$Menus/TabContainer/Display/ScrollContainer/VBoxContainer/CurrentScreen/SpinBox.value = OS.current_screen
$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.add_item("fr")
$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.add_item("en")
load_settings()
func _on_font_size_bar_value_changed(value):
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size/font_size_value.text = str( value )
@ -26,34 +28,44 @@ func load_settings():
config_file.set_value( "theme", "font_size", 14 )
config_file.save( "user://settings.cfg" )
elif not err == OK:
print("Error code when loading config file: ", err)
print("[res://gui_scene/GUI/Settings/Settings.gd:load_settings] Error code when loading config file: ", err)
global.font_size = config_file.get_value( "theme", "font_size" )
if $Menus.get_theme():
$Menus.get_theme().default_font.size = global.font_size
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size_bar.value = global.font_size
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size/font_size_value.text = str( global.font_size )
#var connexion = load("res://assets/Scripts/Config/connexion.gd").new()
var script_connexion = preload("res://assets/Scripts/Config/connexion.gd")
var connexion = script_connexion.connexion.new()
var language = connexion.get_language()
$Menus/TabContainer/connexion/v_box_container/h_box_container/register.text = connexion.get_url_register()
$Menus/TabContainer/connexion/v_box_container/h_box_container2/connexion.text = connexion.get_url_login()
$Menus/TabContainer/connexion/v_box_container/h_box_container3/certificate_valid.pressed = connexion.get_valid_certificate()
# language
for i in range(0, $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_item_count()):
if $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_item_text(i) == language:
$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.select(i)
break
#$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.
#.selected = language
#$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.selected
func _on_ReturnButton_pressed():
var config_file = ConfigFile.new()
var err = config_file.load( "user://settings.cfg" )
if err:
print("Error code when loading config file: ", err)
config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
config_file.save( "user://settings.cfg" )
emit_signal( "return_pressed" )
#func _on_ReturnButton_pressed():
# var config_file = ConfigFile.new()
# var err = config_file.load( "user://settings.cfg" )
# if err:
# print("[Settings:_on_ReturnButton_pressed] Error code when loading config file: ", err)
# config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
# config_file.save( "user://settings.cfg" )
# emit_signal( "return_pressed" )
func _on_Title_text_changed(new_text):
# ----------------------------------
# Changing windows title
var new_title = "Khanat"
var new_title = "Khanat"
new_text = new_text.strip_edges()
if not new_text == "":
new_title = new_text
@ -65,7 +77,7 @@ func _on_Fullscreen_toggled(button_pressed):
if ProjectSettings.has_setting( "display/window/size/fullscreen" ):
ProjectSettings.set_setting("display/window/size/fullscreen", button_pressed)
OS.window_fullscreen = ProjectSettings.get_setting("display/window/size/fullscreen")
func _on_Borderless_toggled(button_pressed):
if ProjectSettings.has_setting( "display/window/size/borderless" ):
ProjectSettings.set_setting("display/window/size/borderless", button_pressed)
@ -84,3 +96,31 @@ func _on_AlwaysOnTop_toggled(button_pressed):
func _on_SpinBox_value_changed(value):
OS.current_screen = value
func _on_ApplyButton_pressed():
var config_file = ConfigFile.new()
var err = config_file.load( "user://settings.cfg" )
if err:
print("[res://gui_scene/GUI/Settings/Settings.gd:_on_ApplyButton_pressed] Error code when loading config file: ", err)
config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
config_file.save( "user://settings.cfg" )
# Save Connexion
var script_connexion = preload("res://assets/Scripts/Config/connexion.gd")
var connexion = script_connexion.connexion.new()
connexion.set_url_register($Menus/TabContainer/connexion/v_box_container/h_box_container/register.text)
connexion.set_url_login($Menus/TabContainer/connexion/v_box_container/h_box_container2/connexion.text)
var id = $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_selected_id()
var language = $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_item_text(id)
connexion.set_language(language)
connexion.set_valid_certificate($Menus/TabContainer/connexion/v_box_container/h_box_container3/certificate_valid.pressed)
connexion.save()
emit_signal( "return_pressed" )
func _on_CancelButton_pressed():
emit_signal( "return_pressed" )
func _unhandled_input(event):
if event is InputEventKey:
if event.pressed and event.scancode == KEY_ESCAPE:
emit_signal( "return_pressed" )

File diff suppressed because it is too large Load diff

View file

@ -12,394 +12,144 @@
[sub_resource type="CanvasItemMaterial" id=1]
render_priority = 0
blend_mode = 0
light_mode = 0
[sub_resource type="Gradient" id=2]
offsets = PoolRealArray( 0 )
colors = PoolColorArray( 1, 1, 1, 0.8 )
_sections_unfolded = [ "Resource" ]
[sub_resource type="GradientTexture" id=3]
flags = 4
gradient = SubResource( 2 )
width = 2048
[node name="register_menu" type="Control" index="0"]
[node name="register_menu" type="Control"]
material = SubResource( 1 )
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
theme = ExtResource( 1 )
script = ExtResource( 2 )
_sections_unfolded = [ "Material", "Theme", "Visibility", "custom_styles" ]
[node name="HTTPRequest" type="HTTPRequest" parent="." index="0"]
[node name="HTTPRequest" type="HTTPRequest" parent="."]
download_file = ""
use_threads = false
body_size_limit = -1
max_redirects = 8
_sections_unfolded = [ "Pause" ]
[node name="background" type="TextureRect" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
[node name="background" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
texture = ExtResource( 3 )
expand = true
stretch_mode = 7
_sections_unfolded = [ "Visibility" ]
[node name="text_background" type="TextureRect" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
[node name="text_background" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 248.0
margin_top = 128.0
margin_right = -120.0
margin_bottom = -120.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
texture = SubResource( 3 )
expand = true
stretch_mode = 7
_sections_unfolded = [ "Margin", "Visibility" ]
[node name="buttons_background" type="TextureRect" parent="." index="3"]
[node name="buttons_background" type="TextureRect" parent="."]
anchor_left = 1.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 0.0
margin_left = -307.0
margin_bottom = 65.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
texture = ExtResource( 4 )
stretch_mode = 7
_sections_unfolded = [ "Size Flags" ]
[node name="h_box_container" type="HBoxContainer" parent="." index="4"]
anchor_left = 0.0
anchor_top = 0.0
[node name="h_box_container" type="HBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="v_box_container" type="VBoxContainer" parent="h_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="v_box_container" type="VBoxContainer" parent="h_box_container"]
margin_right = 1280.0
margin_bottom = 720.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 1
alignment = 0
_sections_unfolded = [ "Margin", "Size Flags", "custom_constants" ]
[node name="buttons_box" type="HBoxContainer" parent="h_box_container/v_box_container" index="0"]
[node name="buttons_box" type="HBoxContainer" parent="h_box_container/v_box_container"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 1064.0
margin_right = 1280.0
margin_bottom = 61.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 10
size_flags_vertical = 1
custom_constants/separation = 0
alignment = 2
_sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="help_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="help_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"]
margin_right = 54.0
margin_bottom = 61.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 10
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 5 )
_sections_unfolded = [ "Margin", "Size Flags", "Textures" ]
[node name="settings_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="settings_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"]
margin_left = 54.0
margin_right = 108.0
margin_bottom = 61.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 10
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 6 )
_sections_unfolded = [ "Size Flags", "Textures" ]
[node name="quit_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="quit_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"]
margin_left = 108.0
margin_right = 162.0
margin_bottom = 61.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 10
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 7 )
_sections_unfolded = [ "Size Flags", "Textures" ]
[node name="sound_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="sound_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"]
margin_left = 162.0
margin_right = 216.0
margin_bottom = 61.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 10
size_flags_vertical = 1
toggle_mode = true
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 8 )
texture_pressed = ExtResource( 9 )
_sections_unfolded = [ "Size Flags", "Textures" ]
[node name="margin_container" type="MarginContainer" parent="h_box_container/v_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="margin_container" type="MarginContainer" parent="h_box_container/v_box_container"]
margin_top = 65.0
margin_right = 1280.0
margin_bottom = 720.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/margin_right = 128
custom_constants/margin_top = 128
custom_constants/margin_left = 256
custom_constants/margin_bottom = 128
_sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container" index="0"]
[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 256.0
margin_top = 128.0
margin_right = 1152.0
margin_bottom = 527.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container"]
margin_right = 896.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container"]
margin_right = 46.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "From: "
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="license_url_link" type="LinkButton" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="license_url_link" type="LinkButton" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container"]
margin_left = 50.0
margin_right = 375.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 2
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 0
shortcut = null
group = null
text = "https://www.gnu.org/licenses/agpl-3.0.en.html"
[node name="scroll_container" type="ScrollContainer" parent="h_box_container/v_box_container/margin_container/v_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="scroll_container" type="ScrollContainer" parent="h_box_container/v_box_container/margin_container/v_box_container"]
margin_top = 21.0
margin_right = 896.0
margin_bottom = 362.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = true
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
scroll_horizontal_enabled = true
scroll_horizontal = 0
scroll_vertical_enabled = true
scroll_vertical = 0
scroll_deadzone = 0
_sections_unfolded = [ "Margin", "Scroll", "Size Flags" ]
[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container"]
margin_right = 884.0
margin_bottom = 8557.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 0
_sections_unfolded = [ "Size Flags" ]
[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container/v_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container/v_box_container"]
margin_right = 884.0
margin_bottom = 8557.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_colors/font_color = Color( 0.0627451, 0.0313726, 0.45098, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
@ -617,46 +367,19 @@ If your software can interact with users remotely through a computer network, yo
You should also get your employer (if you work as a programmer) or school, if any, to sign a \"copyright disclaimer\" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>."
autowrap = true
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Size Flags", "custom_colors" ]
[node name="return_button" type="Button" parent="h_box_container/v_box_container/margin_container/v_box_container" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="return_button" type="Button" parent="h_box_container/v_box_container/margin_container/v_box_container"]
margin_left = 384.0
margin_top = 366.0
margin_right = 512.0
margin_bottom = 399.0
rect_min_size = Vector2( 128, 0 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 6
size_flags_vertical = 0
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Retour"
flat = false
align = 1
_sections_unfolded = [ "Size Flags" ]
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
[connection signal="pressed" from="h_box_container/v_box_container/buttons_box/quit_button" to="." method="_on_quit_button_pressed"]
[connection signal="toggled" from="h_box_container/v_box_container/buttons_box/sound_button" to="." method="_on_sound_button_toggled"]
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/v_box_container/h_box_container/license_url_link" to="." method="_on_license_url_link_pressed"]
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/v_box_container/return_button" to="." method="_on_return_button_pressed"]

View file

@ -3,36 +3,158 @@ extends Control
signal login_button_pressed
signal register_button_pressed
var _username
var _password
func _on_login_button_pressed():
emit_signal( "login_button_pressed" )
func _on_play_button_pressed():
var username = get_node("h_box_container/v_box_container/margin_container/login_box/email_box/email_edit").get_text();
var password = get_node("h_box_container/v_box_container/margin_container/login_box/password_box/password_edit").get_text();
var username = $h_box_container/v_box_container/margin_container/login_box/email_box/email_edit.get_text();
var password = $h_box_container/v_box_container/margin_container/login_box/password_box/password_edit.get_text();
if username != null and username != "" and password != null and password != "":
do_request(username, password)
do_request_salt(username, password)
func _on_play_without_connexion_pressed():
emit_signal( "login_button_pressed" )
# Step get salt
func do_request_salt(username, password):
#var message = load("res://assets/Scripts/Models/nel_login_message.gd")
var connexion = preload("res://assets/Scripts/Config/connexion.gd").connexion.new()
#if message:
_username = username
_password = password
var message = preload("res://assets/Scripts/Models/nel_login_message.gd").nel_login_message.new("https-login", _username, _password, "Lirria", "2", "en")
#message = message.nel_login_message.new("https-login", _username, _password, "Lirria", "2", "en")
var url_login = connexion.get_url_login();
$HTTPSalt.request(url_login + "?" + message.get_request_salt());
#$HTTPRequest.request(url_login + "?" + message.get_request_salt());
print("[login_menu] URL:" + url_login + "?" + message.get_request_salt());
func _on_HTTPSalt_request_completed(result, response_code, headers, body):
print("[login_menu:_on_HTTPSalt_request_completed] response_code:" + str(response_code))
if response_code != 200: # || ProjectSettings.get_setting("khaganat/debug_mode"):
print("[login_menu:_on_HTTPSalt_request_completed] Impossible to connect")
#emit_signal( "login_button_pressed" )
$error_dialog/v_box_container/label.text = "Impossible to connect"
$error_dialog.popup_centered()
else:
var text = str2var(body.get_string_from_utf8())
var s = body.get_string_from_utf8().split(":")
print("[login_menu:_on_HTTPSalt_request_completed] return:'" + str(text) + "'")
if(s[0] == "1"):
print("[login_menu] salt:'" + str(s[1]) + "'")
var message = preload("res://assets/Scripts/Models/nel_login_message.gd").nel_login_message.new("https-login", _username, _password, "Lirria", "2", "en")
var connexion = preload("res://assets/Scripts/Config/connexion.gd").connexion.new()
var url_login = connexion.get_url_login();
print("[login_menu] URL:" + url_login + "?" + message.get_request_string(str(s[1])));
$HTTPRequest.request(url_login + "?" + message.get_request_string(str(s[1])));
else:
print("[login_menu:_on_HTTPSalt_request_completed] error to connect")
var regex = RegEx.new()
regex.compile("^(\\d+)[:](?<comment>.+)$")
var search = regex.search(s[0])
if search:
$error_dialog/v_box_container/label.text = "Impossible to connect\n" + search.get_string("comment")
$error_dialog.popup_centered()
else:
$error_dialog/v_box_container/label.text = "Impossible to connect\n" + str(s[0])
$error_dialog.popup_centered()
return
# Step Login
func do_request(username, password):
var message = load("res://assets/Scripts/Models/nel_login_message.gd")
var message = preload("res://assets/Scripts/Models/nel_login_message.gd")
var connexion = preload("res://assets/Scripts/Config/connexion.gd").connexion.new()
if message:
message = message.nel_login_message.new("https-login", username, password, "Lirria", "2", "en");
# $HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string());
$HTTPRequest.request("http://149.91.80.160/login/r2_login.php?" + message.get_request_string());
var url_login
message = message.nel_login_message.new("https-login", username, password, "Lirria", "2", "en")
url_login = connexion.get_url_login();
$HTTPRequest.request(url_login + "?" + message.get_request_string());
print("Login to URL:" + url_login + "?" + message.get_request_string());
func _on_HTTPRequest_request_completed(result, response_code, headers, body):
if response_code != 200 || ProjectSettings.get_setting("kaghanat/debug_mode"):
emit_signal( "login_button_pressed" )
print("[login_menu:_on_HTTPRequest_request_completed] response_code:" + str(response_code))
if response_code != 200: # || ProjectSettings.get_setting("khaganat/debug_mode"):
# emit_signal( "login_button_pressed" )
print("[login_menu:_on_HTTPRequest_request_completed] Impossible to connect")
$error_dialog/v_box_container/label.text = "Impossible to connect"
$error_dialog.popup_centered()
else:
var s = body.get_string_from_utf8().split(":")
if(s[0] != "0"):
var server_info_script = load("res://assets/Scripts/Models/nel_server_info.gd");
var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8());
emit_signal( "login_button_pressed" )
# No error so login was successful.
var text = str2var(body.get_string_from_utf8())
var lines = body.get_string_from_utf8().split("\n")
if lines.size() != 2:
print("[login_menu] Impossible to connect (bad return)")
$error_dialog/v_box_container/label.text = "Impossible to connect (bad return)"
$error_dialog.popup_centered()
return
var line1 = lines[0].split("#")
var line2 = lines[1].split("#")
#print("[login_menu:_on_HTTPRequest_request_completed] return:'" + str(text) + "'" + str(lines.size()) + "'" + str(line1.size()) + "'" + str(line2.size()))
if line1[0] != "1":
print("[login_menu] Impossible to connect (return" + line1[0] + ")")
var regex = RegEx.new()
regex.compile("^(\\d+)[:](?<comment>.+)$")
var search = regex.search(line1[0])
if search:
$error_dialog/v_box_container/label.text = "Impossible to connect\n" + search.get_string("comment")
$error_dialog.popup_centered()
else:
$error_dialog/v_box_container/label.text = "Impossible to connect\n" + str(line1[0])
$error_dialog.popup_centered()
return
if line1.size() < 5:
print("[login_menu] Impossible to connect (bad return 1st line, size:" + str(line1.size()) + ")")
$error_dialog/v_box_container/label.text = "Impossible to connect (bad return 1st line, size:" + str(line1.size()) + ")"
$error_dialog.popup_centered()
return
if line2.size() != 3:
print("[login_menu] Impossible to connect (bad return 2nd line, size:" + str(line2.size()) + ")")
$error_dialog/v_box_container/label.text = "Impossible to connect (bad return 2nd line, size:" + str(line2.size()) + ")"
$error_dialog.popup_centered()
return
var server_info_script = preload("res://assets/Scripts/Models/nel_server_info.gd");
print("[login_menu] " + str(body.get_string_from_utf8()))
var state = line1[0]
var cookie = line1[1]
var fsaddr = line1[2]
var khaganat = fsaddr.split(":")
var khaganat_host = khaganat[0]
var khaganat_port = int(khaganat[1])
var ringmainurl = line1[3]
var fartp = line1[4]
var stat = "0"
if line1.size() >= 6:
stat = line1[5]
var r2serverversion = line2[0]
var r2backuppatchurl = line2[1]
var r2patchurl = line2[2]
var cookieSplit = cookie.split("|")
if cookieSplit.size() != 3:
$error_dialog/v_box_container/label.text = "Impossible de se connecter (bad cookies size:" + str(cookieSplit.size()) + ")"
$error_dialog.popup_centered()
return
var UserAddr = cookieSplit[0]
var UserKey = cookieSplit[1]
var UserId = cookieSplit[2]
print("[login_menu:_on_HTTPRequest_request_completed] state:" + state + ", cookie:" + cookie + ", fsaddr:" + fsaddr + ", ringmainurl:" + ringmainurl + ", fartp:" + fartp + ", stat:" + stat + ", r2serverversion:" + r2serverversion + ", r2backuppatchurl:" + r2backuppatchurl + ", r2patchurl:" + r2patchurl)
var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8());
var connexion = load("res://assets/Scripts/Config/connexion.gd").connexion.new()
var lang = connexion.get_language()
print("[login_menu:_on_HTTPRequest_request_completed] khaganat_host:" + khaganat_host + ", khaganat_port:" + str(khaganat_port))
net_low_level.connect_to_server(khaganat_host, khaganat_port, UserAddr, UserKey, UserId, lang)
emit_signal( "login_button_pressed" )
func _make_post_request(url, data_to_send, use_ssl):
# Convert data to json string:
@ -41,7 +163,10 @@ func _make_post_request(url, data_to_send, use_ssl):
var headers = ["Content-Type: application/json"]
$HTTPRequest.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)
func _on_register_button_pressed():
emit_signal( "register_button_pressed" )
func _on_error_dialog_button_pressed():
get_node("error_dialog").hide()

View file

@ -22,6 +22,8 @@ anchor_bottom = 1.0
theme = ExtResource( 1 )
script = ExtResource( 2 )
[node name="HTTPSalt" type="HTTPRequest" parent="."]
[node name="HTTPRequest" type="HTTPRequest" parent="."]
[node name="background" type="TextureRect" parent="."]
@ -185,7 +187,37 @@ rect_min_size = Vector2( 128, 0 )
size_flags_horizontal = 10
custom_fonts/font = SubResource( 3 )
text = "Tester sans se connecter"
[node name="error_dialog" type="PopupDialog" parent="."]
margin_right = 400.0
margin_bottom = 150.0
size_flags_horizontal = 7
size_flags_vertical = 7
popup_exclusive = true
[node name="v_box_container" type="VBoxContainer" parent="error_dialog"]
margin_right = 400.0
margin_bottom = 150.0
size_flags_horizontal = 7
size_flags_vertical = 7
alignment = 1
[node name="label" type="Label" parent="error_dialog/v_box_container"]
margin_right = 400.0
margin_bottom = 17.0
text = "Error detected"
align = 1
valign = 1
[node name="button" type="Button" parent="error_dialog/v_box_container"]
margin_right = 16.0
margin_bottom = 33.0
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Ok"
[connection signal="request_completed" from="HTTPSalt" to="." method="_on_HTTPSalt_request_completed"]
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/email_box/email_label_box/register_button" to="." method="_on_register_button_pressed"]
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/h_box_container/play_button" to="." method="_on_play_button_pressed"]
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/h_box_container/play_without_connexion" to="." method="_on_play_without_connexion_pressed"]
[connection signal="pressed" from="error_dialog/v_box_container/button" to="." method="_on_error_dialog_button_pressed"]

View file

@ -3,6 +3,7 @@ extends Control
signal sound_button_toggled( button_pressed )
signal cancel_button_pressed
signal license_button_pressed
signal register_account_created
func _on_sound_button_toggled( button_pressed ):
@ -15,3 +16,188 @@ func _on_cancel_button_pressed():
func _on_license_button_pressed():
emit_signal( "license_button_pressed" )
func _on_check_box_pressed():
do_enable_register_button();
func do_enable_register_button():
var username = get_node("h_box_container/v_box_container/center_container/register_box/login_box/login_edit").get_text();
var register = get_node('h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2')
var password = get_node("h_box_container/v_box_container/center_container/register_box/password_box/password_edit").get_text();
var confirmed = get_node("h_box_container/v_box_container/center_container/register_box/password_confirm_box/password_edit").get_text();
var email = get_node("h_box_container/v_box_container/center_container/register_box/email_box/email_edit").get_text();
var cur_state = get_node('h_box_container/v_box_container/center_container/register_box/license_box/check_box').is_pressed()
if username == null or username == "":
#print("Register : username empty");
register.disabled = true
elif password == null or password == "":
#print("Register : password empty");
register.disabled = true
elif confirmed == null or confirmed == "":
#print("Register : confirmed empty");
register.disabled = true
elif password != confirmed:
#print("Register : password != confirmed");
register.disabled = true
elif email == null or email == "":
#print("Register : email empty");
register.disabled = true
elif cur_state == false:
#print("Register : unchecked condition");
register.disabled = true
else:
register.disabled = false
func _on_play_button_pressed():
var username = $h_box_container/v_box_container/center_container/register_box/login_box/login_edit.get_text();
var password = $h_box_container/v_box_container/center_container/register_box/password_box/password_edit.get_text();
var confirmed = $h_box_container/v_box_container/center_container/register_box/password_confirm_box/password_edit.get_text();
var email = $h_box_container/v_box_container/center_container/register_box/email_box/email_edit.get_text();
var cur_state = $h_box_container/v_box_container/center_container/register_box/license_box/check_box.is_pressed()
var enregister = $h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2
var tac = "off";
if cur_state == true:
tac = "on";
if username != null and username != "" and password != null and password != "" and confirmed != null and confirmed != "" and email != null and email != "":
do_request(username, password, confirmed, email, tac)
func do_request(username, password, confirmed, email, tac):
var script_register = load("res://assets/Scripts/Models/nel_register.gd")
var script_connexion = load("res://assets/Scripts/Config/connexion.gd")
var connexion = script_connexion.connexion.new()
var url_register = connexion.get_url_register()
var valid_certificate = connexion.get_valid_certificate()
var request_data = script_register.nel_register.new(username, password, confirmed, email, tac)
#print("url:" + str(url_register))
#print("headers:" + str(request_data.get_headers()))
#print("data:" + str(request_data.get_param_add_user_string()))
# Ignore redirect 302 (because khaganat response 302 when account is created !)
$HTTPRequest.set_max_redirects(0)
var err = $HTTPRequest.request(url_register,
request_data.get_headers(),
valid_certificate,
HTTPClient.METHOD_POST,
request_data.get_param_add_user_string()
);
match err:
0:
print("[Register] Send command")
get_node("wait_dialog").popup_centered()
_:
print("[Register] Command not sended : Failure! (code:" + str(err) + ")")
var comment_last = get_node('h_box_container/v_box_container/center_container/register_box/comment_last')
comment_last.text = "Impossible de créer votre compte (Erreur dans l'envoie de la requette)"
comment_last.add_color_override("font_color", "b51111")
get_node("wait_dialog").hide()
get_node("error_dialog/v_box_container/label").text = "Impossible de créer votre compte\nErreur dans l'envoie de la requette\n"
get_node("error_dialog").popup_centered()
func _on_HTTPRequest_request_completed( result, response_code, headers, body ):
var pos
var search
var enregister = $h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2
var comment_last = $h_box_container/v_box_container/center_container/register_box/comment_last
var comment_username = $h_box_container/v_box_container/center_container/register_box/login_box/comment
var comment_password = $h_box_container/v_box_container/center_container/register_box/password_box/comment
var comment_confirm_password = $h_box_container/v_box_container/center_container/register_box/password_confirm_box/comment
var comment_email = $h_box_container/v_box_container/center_container/register_box/email_box/comment
var regex = RegEx.new()
comment_username.text = ""
comment_password.text = ""
comment_confirm_password.text = ""
comment_email.text = ""
comment_last.text = ""
comment_last.add_color_override("font_color", "000000")
print("[Register] result:" + str(result) + ", response_code:" + str(response_code))
if result == HTTPRequest.RESULT_REDIRECT_LIMIT_REACHED and response_code == 302:
get_node("wait_dialog").hide()
get_node("info_dialog/v_box_container/label").text = "Compte créé"
get_node("info_dialog").popup_centered()
return
if result == HTTPRequest.RESULT_SUCCESS and response_code != 200:
comment_last.text = "Serveur a renvoyé une erreur (code retour HTTP:" + str(response_code) + ")"
comment_last.add_color_override("font_color", "b51111")
get_node("wait_dialog").hide()
get_node("error_dialog/v_box_container/label").text = "Impossible de créer le compte\nCode retour HTTP:" + str(response_code)
get_node("error_dialog").popup_centered()
return
get_node("wait_dialog").hide()
var text = str2var(body.get_string_from_utf8())
regex.compile("^(\\d+)[:]")
var tab = text.split(":", true,2)
if tab.size() > 1 :
if regex.search(tab[0]):
if int(tab[0]) != 1:
comment_last.text = "Serveur a renvoyé une erreur (Code retour:" + str(tab[0]) + ", message:" + tab[1] +")"
comment_last.add_color_override("font_color", "b51111")
get_node("wait_dialog").hide()
get_node("error_dialog/v_box_container/label").text = "Serveur a renvoyé une erreur\nCode retour:" + str(tab[0]) + "\nMessage:" + tab[1]
get_node("error_dialog").popup_centered()
print("[Register] Failed to register (Code retour:" + str(tab[0]) + ", message:" + tab[1] +")")
return
tab = text.rsplit("\n")
regex.compile(">(?<comment>.+)</")
for item in tab:
pos = item.find("comment-Username")
search = regex.search(item)
if pos > 0 and search:
comment_username.text = search.get_string("comment")
print("[Register] Username issue : " + comment_username.text)
pos = item.find("comment-Password")
if pos > 0 and search:
comment_password.text = search.get_string("comment")
print("[Register] Password issue : " + comment_password.text)
pos = item.find("comment-ConfirmPass")
if pos > 0 and search:
comment_confirm_password.text = search.get_string("comment")
print("[Register] ConfirmPass issue : " + comment_confirm_password.text)
pos = item.find("comment-Email")
if pos > 0 and search:
comment_email.text = search.get_string("comment")
print("[Register] Email issue : " + comment_email.text)
pos = item.find("comment-Tac")
if pos > 0 and search:
comment_last.text = search.get_string("comment")
comment_last.add_color_override("font_color", "b51111")
print("[Register] Issue : " + comment_last.text)
func _on_login_edit_text_changed(new_text):
do_enable_register_button();
func _on_password_edit_text_changed(new_text):
do_enable_register_button();
func _on_email_edit_text_changed(new_text):
do_enable_register_button();
func _on_button_pressed():
$HTTPRequest.cancel_request()
get_node("wait_dialog").hide()
func _on_info_dialog_button_pressed():
get_node("info_dialog").hide()
hide()
# _on_register_menu_register_button_pressed
emit_signal( "register_account_created" )
func _on_error_dialog_button_pressed():
get_node("error_dialog").hide()

View file

@ -7,576 +7,349 @@
[sub_resource type="CanvasItemMaterial" id=1]
render_priority = 0
blend_mode = 0
light_mode = 0
[sub_resource type="DynamicFont" id=2]
size = 20
use_mipmaps = false
use_filter = false
font_data = ExtResource( 4 )
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
[node name="register_menu" type="Control"]
material = SubResource( 1 )
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
theme = ExtResource( 1 )
script = ExtResource( 2 )
_sections_unfolded = [ "Material", "Theme", "Visibility", "custom_styles" ]
[node name="HTTPRequest" type="HTTPRequest" parent="." index="0"]
[node name="HTTPRequest" type="HTTPRequest" parent="."]
download_file = ""
use_threads = false
body_size_limit = -1
max_redirects = 8
_sections_unfolded = [ "Pause" ]
[node name="background" type="TextureRect" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
[node name="background" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
texture = ExtResource( 3 )
expand = true
stretch_mode = 7
_sections_unfolded = [ "Visibility" ]
[node name="h_box_container" type="HBoxContainer" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
[node name="h_box_container" type="HBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="v_box_container" type="VBoxContainer" parent="h_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="v_box_container" type="VBoxContainer" parent="h_box_container"]
margin_right = 1280.0
margin_bottom = 720.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 1
alignment = 0
_sections_unfolded = [ "Margin", "Size Flags", "custom_constants" ]
[node name="center_container" type="CenterContainer" parent="h_box_container/v_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="center_container" type="CenterContainer" parent="h_box_container/v_box_container"]
margin_right = 1280.0
margin_bottom = 720.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
use_top_left = false
_sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="register_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="register_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container"]
margin_left = 509.0
margin_top = 159.0
margin_top = 92.0
margin_right = 771.0
margin_bottom = 561.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
margin_bottom = 627.0
custom_constants/separation = 16
alignment = 0
_sections_unfolded = [ "Margin", "custom_constants" ]
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box"]
margin_right = 262.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 0.0627451, 0.0313726, 0.45098, 1 )
text = "INSCRIPTION"
align = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "custom_colors" ]
[node name="login_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="1"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="login_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"]
margin_top = 33.0
margin_right = 262.0
margin_bottom = 91.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
margin_bottom = 116.0
custom_constants/separation = 8
alignment = 0
_sections_unfolded = [ "custom_constants" ]
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/login_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/login_box"]
margin_right = 262.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Login"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "custom_colors" ]
[node name="login_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/login_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="login_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/login_box"]
margin_top = 25.0
margin_right = 262.0
margin_bottom = 58.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
focus_mode = 2
context_menu_enabled = true
placeholder_text = "Entrez votre login ici."
placeholder_alpha = 0.6
caret_blink = false
caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ]
[node name="password_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="2"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 107.0
[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/login_box"]
margin_top = 66.0
margin_right = 262.0
margin_bottom = 165.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
margin_bottom = 83.0
custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 )
[node name="password_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"]
margin_top = 132.0
margin_right = 262.0
margin_bottom = 215.0
custom_constants/separation = 8
alignment = 0
_sections_unfolded = [ "custom_constants" ]
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_box"]
margin_right = 262.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Mot de passe"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "custom_colors" ]
[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_box"]
margin_top = 25.0
margin_right = 262.0
margin_bottom = 58.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
secret = true
focus_mode = 2
context_menu_enabled = true
placeholder_text = "Entrez votre mot de passe ici."
placeholder_alpha = 0.6
caret_blink = false
caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ]
[node name="password_confirm_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="3"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 181.0
[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_box"]
margin_top = 66.0
margin_right = 262.0
margin_bottom = 239.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
margin_bottom = 83.0
custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 )
[node name="password_confirm_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"]
margin_top = 231.0
margin_right = 262.0
margin_bottom = 314.0
custom_constants/separation = 8
alignment = 0
_sections_unfolded = [ "custom_constants" ]
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box"]
margin_right = 262.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Confirmation du ot de passe"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "custom_colors" ]
text = "Confirmation du mot de passe"
[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box"]
margin_top = 25.0
margin_right = 262.0
margin_bottom = 58.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
secret = true
focus_mode = 2
context_menu_enabled = true
placeholder_text = "Entrez votre mot de passe ici."
placeholder_alpha = 0.6
caret_blink = false
caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ]
[node name="email_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="4"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 255.0
[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box"]
margin_top = 66.0
margin_right = 262.0
margin_bottom = 313.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
margin_bottom = 83.0
custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 )
[node name="email_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"]
margin_top = 330.0
margin_right = 262.0
margin_bottom = 413.0
custom_constants/separation = 8
alignment = 0
_sections_unfolded = [ "custom_constants" ]
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/email_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/email_box"]
margin_right = 262.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "e-mail"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "custom_colors" ]
[node name="email_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/email_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="email_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/email_box"]
margin_top = 25.0
margin_right = 262.0
margin_bottom = 58.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
focus_mode = 2
context_menu_enabled = true
placeholder_text = "Entrez votre adresse email ici."
placeholder_alpha = 0.6
caret_blink = false
caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ]
[node name="license_box" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="5"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 329.0
[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/email_box"]
margin_top = 66.0
margin_right = 262.0
margin_bottom = 346.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
margin_bottom = 83.0
custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 )
[node name="check_box" type="CheckBox" parent="h_box_container/v_box_container/center_container/register_box/license_box" index="0"]
[node name="license_box" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"]
margin_top = 429.0
margin_right = 262.0
margin_bottom = 446.0
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="check_box" type="CheckBox" parent="h_box_container/v_box_container/center_container/register_box/license_box"]
margin_right = 16.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = true
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/license_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/license_box"]
margin_left = 20.0
margin_right = 109.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "j'accepte les"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="license_button" type="LinkButton" parent="h_box_container/v_box_container/center_container/register_box/license_box" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="license_button" type="LinkButton" parent="h_box_container/v_box_container/center_container/register_box/license_box"]
margin_left = 113.0
margin_right = 262.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 2
size_flags_horizontal = 1
size_flags_vertical = 1
custom_colors/font_color = Color( 0.0627451, 0.0313726, 0.45098, 1 )
custom_colors/font_color_hover = Color( 0.305882, 0.294118, 0.454902, 1 )
custom_colors/font_color_pressed = Color( 0.0627451, 0.0313726, 0.45098, 1 )
toggle_mode = false
enabled_focus_mode = 0
shortcut = null
group = null
text = "termes et conditions."
_sections_unfolded = [ "custom_colors" ]
[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="6"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 362.0
[node name="comment_last" type="Label" parent="h_box_container/v_box_container/center_container/register_box"]
margin_top = 462.0
margin_right = 262.0
margin_bottom = 402.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
margin_bottom = 479.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
[node name="cancel_button" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container" index="0"]
[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"]
margin_top = 495.0
margin_right = 262.0
margin_bottom = 535.0
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="cancel_button" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container"]
margin_right = 128.0
margin_bottom = 40.0
rect_min_size = Vector2( 128, 0 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 6
size_flags_vertical = 1
custom_fonts/font = SubResource( 2 )
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Annuler"
flat = false
align = 1
_sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ]
[node name="register_button2" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="register_button2" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container"]
margin_left = 133.0
margin_right = 261.0
margin_bottom = 40.0
rect_min_size = Vector2( 128, 0 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 6
size_flags_vertical = 1
custom_fonts/font = SubResource( 2 )
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
disabled = true
text = "S'inscrire"
flat = false
[node name="wait_dialog" type="PopupDialog" parent="."]
modulate = Color( 0.972549, 0.929412, 0.929412, 1 )
self_modulate = Color( 0.929412, 0.847059, 0.847059, 1 )
margin_left = 500.0
margin_top = 300.0
margin_right = 740.0
margin_bottom = 420.0
grow_horizontal = 2
grow_vertical = 2
hint_tooltip = "Server create your account"
mouse_default_cursor_shape = 4
size_flags_horizontal = 2
size_flags_vertical = 2
popup_exclusive = true
[node name="v_box_container" type="VBoxContainer" parent="wait_dialog"]
margin_right = 240.0
margin_bottom = 120.0
size_flags_horizontal = 2
size_flags_vertical = 2
custom_constants/separation = 10
alignment = 1
[node name="label" type="Label" parent="wait_dialog/v_box_container"]
margin_left = 80.0
margin_top = 27.0
margin_right = 159.0
margin_bottom = 44.0
grow_horizontal = 2
grow_vertical = 2
hint_tooltip = "Server will create your account"
mouse_default_cursor_shape = 5
size_flags_horizontal = 4
text = "Please wait"
align = 1
_sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ]
valign = 1
[node name="button" type="Button" parent="wait_dialog/v_box_container"]
margin_left = 87.0
margin_top = 81.0
margin_right = 152.0
margin_bottom = 114.0
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Cancel"
[node name="info_dialog" type="PopupDialog" parent="."]
modulate = Color( 0.972549, 0.929412, 0.929412, 1 )
self_modulate = Color( 0.929412, 0.847059, 0.847059, 1 )
margin_left = 500.0
margin_top = 300.0
margin_right = 740.0
margin_bottom = 420.0
grow_horizontal = 2
grow_vertical = 2
hint_tooltip = "Server create your account"
mouse_default_cursor_shape = 4
size_flags_horizontal = 2
size_flags_vertical = 2
popup_exclusive = true
[node name="v_box_container" type="VBoxContainer" parent="info_dialog"]
margin_right = 240.0
margin_bottom = 120.0
custom_constants/separation = 10
alignment = 1
[node name="label" type="Label" parent="info_dialog/v_box_container"]
margin_right = 117.0
margin_bottom = 17.0
grow_horizontal = 2
grow_vertical = 2
hint_tooltip = "Server will create your account"
mouse_default_cursor_shape = 5
size_flags_horizontal = 4
text = "Account created"
align = 1
valign = 1
[node name="button" type="Button" parent="info_dialog/v_box_container"]
margin_left = 102.0
margin_top = 81.0
margin_right = 137.0
margin_bottom = 114.0
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Ok"
[node name="error_dialog" type="PopupDialog" parent="."]
modulate = Color( 0.972549, 0.929412, 0.929412, 1 )
self_modulate = Color( 0.929412, 0.847059, 0.847059, 1 )
margin_left = 500.0
margin_top = 300.0
margin_right = 900.0
margin_bottom = 450.0
grow_horizontal = 2
grow_vertical = 2
hint_tooltip = "Server create your account"
mouse_default_cursor_shape = 4
size_flags_horizontal = 7
size_flags_vertical = 7
popup_exclusive = true
[node name="v_box_container" type="VBoxContainer" parent="error_dialog"]
margin_right = 400.0
margin_bottom = 140.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 7
size_flags_vertical = 7
custom_constants/separation = 10
alignment = 1
[node name="label" type="Label" parent="error_dialog/v_box_container"]
margin_right = 400.0
margin_bottom = 17.0
grow_horizontal = 2
grow_vertical = 2
hint_tooltip = "Server will create your account"
mouse_default_cursor_shape = 5
size_flags_horizontal = 7
size_flags_vertical = 7
text = "Error Detected"
align = 1
valign = 1
[node name="button" type="Button" parent="error_dialog/v_box_container"]
margin_left = 102.0
margin_top = 81.0
margin_right = 137.0
margin_bottom = 114.0
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Ok"
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/login_box/login_edit" to="." method="_on_login_edit_text_changed"]
[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/password_box/password_edit" to="." method="_on_password_edit_text_changed"]
[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/password_confirm_box/password_edit" to="." method="_on_password_edit_text_changed"]
[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/email_box/email_edit" to="." method="_on_email_edit_text_changed"]
[connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/license_box/check_box" to="." method="_on_check_box_pressed"]
[connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/license_box/license_button" to="." method="_on_license_button_pressed"]
[connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/h_box_container/cancel_button" to="." method="_on_cancel_button_pressed"]
[connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2" to="." method="_on_play_button_pressed"]
[connection signal="pressed" from="wait_dialog/v_box_container/button" to="." method="_on_button_pressed"]
[connection signal="pressed" from="info_dialog/v_box_container/button" to="." method="_on_info_dialog_button_pressed"]
[connection signal="pressed" from="error_dialog/v_box_container/button" to="." method="_on_error_dialog_button_pressed"]

View file

@ -17,15 +17,15 @@ var zoom_direction = null
func _ready():
# $viewport/character/face_camera.make_current()
self.character_preview = $viewport/character
self.character_preview.set_default_values()
# self.character_preview.get_node( "Camera_rotation_helper/face_camera" ).make_current()
self.character_preview.get_node( "face_camera" ).make_current()
self.character_mesh = $viewport/character.get_node("suzanne/mesh")
# self.character_face_camera = $viewport/character/Camera_rotation_helper/face_camera
self.character_box = $margin_container/character_box
@ -37,25 +37,25 @@ func _ready():
update_character_slots()
func update_character_slots():
var config_file = ConfigFile.new()
var err = config_file.load( "user://player.cfg" )
if err:
print("Error code when loading player config file: ", err)
var useds_slot = []
var last_slot = 0
for section in config_file.get_sections():
useds_slot.append( int(section) )
if not self.character_box.has_node( "character_slots/slots_box/slot_box_"+section ):
last_slot = int(section)
var character_name = config_file.get_value( section, "name" )
if not character_name:
character_name = "NameNotFound"
var slot_box = HBoxContainer.new()
slot_box.name = "slot_box_"+section
slot_box.size_flags_horizontal = SIZE_FILL
@ -63,29 +63,29 @@ func update_character_slots():
slot_box.set( "custom_constants/separation", 8)
self.character_box.get_node( "character_slots/slots_box/" ).add_child( slot_box )
slot_box.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
var label_name = Label.new()
label_name.text = character_name
label_name.size_flags_horizontal = SIZE_EXPAND
slot_box.add_child( label_name )
var choose_button = Button.new()
choose_button.text = "Choisir"
slot_box.add_child( choose_button )
choose_button.connect( "pressed", self, "_on_choose_pressed", [int(section)] )
choose_button.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
var delete_button = Button.new()
delete_button.text = "Supprimer"
slot_box.add_child( delete_button )
delete_button.connect( "pressed", self, "_on_delete_pressed", [int(section), slot_box] )
delete_button.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
if self.character_box.has_node( "character_slots/creation_button" ):
self.character_box.get_node( "character_slots/creation_button" ).free()
var index = 0
var index = 0
while index in useds_slot:
index += 1
var next_slot = index
@ -101,49 +101,49 @@ func _on_create_pressed( slot ):
self.character_box.get_node( "character_slots" ).hide()
self.character_box.get_node( "character_creation_box" ).show()
self.character_preview.update()
func _on_choose_pressed( slot ):
emit_signal( "character_selected", slot )
func _on_delete_pressed( slot, node_to_delete ):
func _on_delete_pressed( slot, node_to_delete ):
var config_file = ConfigFile.new()
var err = config_file.load( "user://player.cfg" )
if err:
print("Error code when loading player config file: ", err)
config_file.erase_section( str(slot) )
config_file.save( "user://player.cfg" )
var parent = node_to_delete.get_parent()
parent.remove_child( node_to_delete )
update_character_slots()
func _on_name_mouse_entered_pressed( slot ):
$viewport/character.show()
preview_slot = slot
update_preview()
func update_preview():
var slot = preview_slot
var config_file = ConfigFile.new()
var err = config_file.load( "user://player.cfg" )
if err:
print("Error code when loading player config file: ", err)
if config_file.has_section( str(slot) ):
self.character_preview.slot = slot
# name
var pseudo = config_file.get_value( str(slot), "name", "Player" )
self.character_preview.pseudo = pseudo
# gender
var gender = config_file.get_value( str(slot), "gender", 1 )
self.character_preview.gender = gender
# Color
var color = config_file.get_value( str(slot), "color", Color( 1, 0.25, 0.25, 1 ) )
self.character_preview.color = color
@ -151,21 +151,21 @@ func update_preview():
# Size
var size = config_file.get_value( str(slot), "size", 1.0 )
self.character_preview.size = size
# Ears size
var ears_size = config_file.get_value( str(slot), "ears_size", 0.0 )
self.character_preview.ears_size = ears_size
# Eyes color
var eyes_color = config_file.get_value( str(slot), "eyes_color", Color( 0.0, 1.0, 0.0, 1.0 ) )
self.character_preview.eyes_color = eyes_color
self.character_preview.update()
func _on_character_slots_return_button_pressed():
emit_signal( "return_button_pressed" )
func _on_character_creation_box_return_button_pressed():
self.character_box.get_node( "character_slots" ).show()
self.character_box.get_node( "character_creation_box" ).hide()
@ -186,9 +186,9 @@ func _on_character_creation_box_creation_button_pressed():
config_file.set_value( str(self.character_preview.slot), "size", self.character_preview.size)
config_file.set_value( str(self.character_preview.slot), "ears_size", self.character_preview.ears_size)
config_file.set_value( str(self.character_preview.slot), "eyes_color", self.character_preview.eyes_color)
config_file.save( "user://player.cfg" )
self.character_box.get_node( "character_slots" ).show()
self.character_box.get_node( "character_creation_box" ).hide()
update_character_slots()
@ -225,10 +225,10 @@ func _on_character_creation_box_ears_size_bar_changed( value ):
func _on_character_creation_box_eyes_color_changed(value):
self.character_preview.eyes_color = value
self.character_preview.update()
self.character_preview.update()
func _process( delta ):
if turn_direction == "left":
self.character_mesh.rotation.y -= delta
elif turn_direction == "right":
@ -238,7 +238,7 @@ func _process( delta ):
$viewport/character/face_camera.size += delta
elif zoom_direction == "back":
$viewport/character/face_camera.size -= delta
func _on_turn_left_button_down():
turn_direction = "left"
func _on_turn_left_button_up():
@ -271,6 +271,6 @@ func _on_lights_toggled(button_pressed):
$viewport/character/face_lights.show()
else:
$viewport/character/face_lights.hide()
func _on_character_preview_image_resized():
$viewport.size = $margin_container/character_box/v_box_container/character_preview_image.rect_size

View file

@ -13,8 +13,10 @@ func _ready():
$login_menu.show()
$register_menu.hide()
$license_menu.hide()
$settings_menu.hide()
func _on_login_menu_login_button_pressed():
print("[login_scene] Launch game")
$login_menu.hide()
$character_selection_menu.show()
@ -26,8 +28,8 @@ func _on_character_selection_menu_character_selected( slot ):
var config_file = ConfigFile.new()
var err = config_file.load( "user://player.cfg" )
if err:
print("Error code when loading player config file: ", err)
print("Error code when loading player config file player.cfg: ", err)
character.slot = slot
character.pseudo = config_file.get_value( str(slot), "name", "player" )
character.gender = config_file.get_value( str(slot), "gender", 1 )
@ -36,11 +38,13 @@ func _on_character_selection_menu_character_selected( slot ):
character.ears_size = config_file.get_value( str(slot), "ears_size", 0.0 )
character.eyes_color = config_file.get_value( str(slot), "eyes_color", Color( 0.0, 1.0, 0.0, 1.0 ) )
character.update()
emit_signal( "character_creation_finished" )
func _on_quit_button_pressed():
print("[login_scene:_on_quit_button_pressed] Stop application")
net_low_level.disconnect_server()
self.get_tree().quit()
@ -55,22 +59,41 @@ func _on_login_menu_register_button_pressed():
$login_menu.hide()
$register_menu.show()
$license_menu.hide()
$settings_menu.hide()
func _on_register_menu_cancel_button_pressed():
$login_menu.show()
$register_menu.hide()
$license_menu.hide()
$settings_menu.hide()
func _on_register_menu_license_button_pressed():
$login_menu.hide()
$register_menu.hide()
$license_menu.show()
$settings_menu.hide()
func _on_license_menu_return_button_pressed():
$login_menu.hide()
$register_menu.show()
$license_menu.hide()
$settings_menu.hide()
func _on_register_menu_register_account_created():
$login_menu.show()
$register_menu.hide()
$license_menu.hide()
$settings_menu.hide()
func _on_Settings_menu_return_pressed():
$login_menu.show()
$register_menu.hide()
$license_menu.hide()
$settings_menu.hide()
func _on_settings_button_pressed():
$login_menu.hide()
$register_menu.hide()
$license_menu.hide()
$settings_menu.load_settings()
$settings_menu.show()

View file

@ -1,16 +1,17 @@
[gd_scene load_steps=12 format=2]
[gd_scene load_steps=13 format=2]
[ext_resource path="res://login_scene/login_scene.gd" type="Script" id=1]
[ext_resource path="res://login_scene/character_selection_menu.tscn" type="PackedScene" id=2]
[ext_resource path="res://gui_scene/GUI/login/login_menu.tscn" type="PackedScene" id=3]
[ext_resource path="res://gui_scene/GUI/login/register_menu.tscn" type="PackedScene" id=4]
[ext_resource path="res://gui_scene/GUI/login/license_menu.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/GUI/images/Login-Khanat-background-buttons.png" type="Texture" id=6]
[ext_resource path="res://assets/GUI/images/Login-Khanat-sound-button.png" type="Texture" id=7]
[ext_resource path="res://assets/GUI/images/Login-Khanat-sound-muted-button.png" type="Texture" id=8]
[ext_resource path="res://assets/GUI/images/Login-Khanat-help-button.png" type="Texture" id=9]
[ext_resource path="res://assets/GUI/images/Login-Khanat-settings-button.png" type="Texture" id=10]
[ext_resource path="res://assets/GUI/images/Login-Khanat-quit-button.png" type="Texture" id=11]
[ext_resource path="res://gui_scene/GUI/Settings/Settings.tscn" type="PackedScene" id=6]
[ext_resource path="res://assets/GUI/images/Login-Khanat-background-buttons.png" type="Texture" id=7]
[ext_resource path="res://assets/GUI/images/Login-Khanat-sound-button.png" type="Texture" id=8]
[ext_resource path="res://assets/GUI/images/Login-Khanat-sound-muted-button.png" type="Texture" id=9]
[ext_resource path="res://assets/GUI/images/Login-Khanat-help-button.png" type="Texture" id=10]
[ext_resource path="res://assets/GUI/images/Login-Khanat-settings-button.png" type="Texture" id=11]
[ext_resource path="res://assets/GUI/images/Login-Khanat-quit-button.png" type="Texture" id=12]
[node name="login_scene" type="Node"]
script = ExtResource( 1 )
@ -28,12 +29,15 @@ visible = false
[node name="license_menu" parent="." instance=ExtResource( 5 )]
visible = false
[node name="settings_menu" parent="." instance=ExtResource( 6 )]
visible = false
[node name="buttons_background" type="TextureRect" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -307.0
margin_bottom = 65.0
texture = ExtResource( 6 )
texture = ExtResource( 7 )
[node name="buttons" type="HBoxContainer" parent="."]
anchor_right = 1.0
@ -46,33 +50,36 @@ margin_left = 1052.0
margin_right = 1106.0
margin_bottom = 61.0
toggle_mode = true
texture_normal = ExtResource( 7 )
texture_pressed = ExtResource( 8 )
texture_normal = ExtResource( 8 )
texture_pressed = ExtResource( 9 )
[node name="help_button" type="TextureButton" parent="buttons"]
margin_left = 1110.0
margin_right = 1164.0
margin_bottom = 61.0
texture_normal = ExtResource( 9 )
texture_normal = ExtResource( 10 )
[node name="settings_button" type="TextureButton" parent="buttons"]
margin_left = 1168.0
margin_right = 1222.0
margin_bottom = 61.0
texture_normal = ExtResource( 10 )
texture_normal = ExtResource( 11 )
[node name="quit_button" type="TextureButton" parent="buttons"]
margin_left = 1226.0
margin_right = 1280.0
margin_bottom = 61.0
texture_normal = ExtResource( 11 )
texture_normal = ExtResource( 12 )
[connection signal="character_selected" from="character_selection_menu" to="." method="_on_character_selection_menu_character_selected"]
[connection signal="return_button_pressed" from="character_selection_menu" to="." method="_on_character_selection_menu_return_button_pressed"]
[connection signal="login_button_pressed" from="login_menu" to="." method="_on_login_menu_login_button_pressed"]
[connection signal="register_button_pressed" from="login_menu" to="." method="_on_login_menu_register_button_pressed"]
[connection signal="cancel_button_pressed" from="register_menu" to="." method="_on_register_menu_cancel_button_pressed"]
[connection signal="license_button_pressed" from="register_menu" to="." method="_on_register_menu_license_button_pressed"]
[connection signal="register_account_created" from="register_menu" to="." method="_on_register_menu_register_account_created"]
[connection signal="sound_button_toggled" from="register_menu" to="." method="_on_sound_button_toggled"]
[connection signal="return_button_pressed" from="license_menu" to="." method="_on_license_menu_return_button_pressed"]
[connection signal="return_pressed" from="settings_menu" to="." method="_on_Settings_menu_return_pressed"]
[connection signal="toggled" from="buttons/sound_button" to="." method="_on_sound_button_toggled"]
[connection signal="pressed" from="buttons/settings_button" to="." method="_on_settings_button_pressed"]
[connection signal="pressed" from="buttons/quit_button" to="." method="_on_quit_button_pressed"]

7
networkconnexion.gdns Normal file
View file

@ -0,0 +1,7 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "NetworkConnection"
library = ExtResource( 1 )

View file

@ -24,6 +24,12 @@ config/icon="res://icon.png"
global="*res://global.tscn"
character="*res://game_scene/Game/Character/Character.tscn"
net_low_level="*res://assets/Scripts/Network/net_low_level.gd"
msg="*res://assets/Scripts/Definition/msg.gd"
[debug]
settings/stdout/verbose_stdout=true
[display]

View file

@ -7,7 +7,7 @@ func _ready():
var config_file = ConfigFile.new()
var err = config_file.load( HUD_config_file )
if err:
print("Error code when loading config file: ", err)
print("[res://scenes/GUI/HUD/HUD.gd:_ready] Error code when loading config file: ", err)
else:
for child in get_node("Windows" ).get_children():
child.load_from_file( config_file )
@ -15,13 +15,13 @@ func _ready():
func _input( event ):
if event.is_action_pressed( "ui_music_controls" ):
$Windows/Music.visible = not $Windows/Music.visible
func _on_SaveHUD_pressed():
var config_file = ConfigFile.new()
var err = config_file.load( HUD_config_file )
if err:
print("Error code when loading config file: ", err)
print("[res://scenes/GUI/HUD/HUD.gd:_on_SaveHUD_pressed] Error code when loading config file: ", err)
for child in get_node("Windows" ).get_children():

Some files were not shown because too many files have changed in this diff Show more