nettoyage
This commit is contained in:
parent
3252a52530
commit
0c5d43e985
4 changed files with 61 additions and 128 deletions
117
global.gd
117
global.gd
|
@ -2,8 +2,6 @@ extends Node
|
||||||
|
|
||||||
const WINDOW_TITLE_INPUT = "GUI/Settings/Menus/TabContainer/Test/ScrollContainer/VBoxContainer/TitleBox/Title"
|
const WINDOW_TITLE_INPUT = "GUI/Settings/Menus/TabContainer/Test/ScrollContainer/VBoxContainer/TitleBox/Title"
|
||||||
|
|
||||||
var current_scene = null
|
|
||||||
|
|
||||||
var character_name = null
|
var character_name = null
|
||||||
var character_color = null
|
var character_color = null
|
||||||
var character_sex = null
|
var character_sex = null
|
||||||
|
@ -12,43 +10,55 @@ var character_slot = null
|
||||||
# BG loader
|
# BG loader
|
||||||
var loader
|
var loader
|
||||||
var wait_frames
|
var wait_frames
|
||||||
var time_max = 100 # msec
|
var time_max = 10 # msec
|
||||||
#var current_scene
|
var current_scene = null
|
||||||
var main_scene = null
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var root = get_tree().get_root()
|
var root = get_tree().get_root()
|
||||||
current_scene = root.get_child(root.get_child_count() -1)
|
current_scene = root.get_child(root.get_child_count() -1)
|
||||||
|
|
||||||
# current_scene = root.get_node( "Main/login_scene" )
|
|
||||||
# main_scene = root.get_node( "Main" )
|
|
||||||
|
|
||||||
|
|
||||||
change_title()
|
change_title()
|
||||||
get_tree().get_root().connect("size_changed", self, "on_window_size_changed")
|
get_tree().get_root().connect("size_changed", self, "on_window_size_changed")
|
||||||
|
|
||||||
# global.goto_scene_loading( "res://login_scene/login_scene.tscn" )
|
########
|
||||||
# if global.character_creation_camera:
|
#### change title ####
|
||||||
# global.character_creation_camera.make_current()
|
func on_window_size_changed():
|
||||||
|
change_title()
|
||||||
global.goto_scene_loading( "res://login_scene/login_scene.tscn" )
|
|
||||||
# get_tree().change_scene( "res://login_scene/login_scene.tscn" )
|
|
||||||
|
|
||||||
|
func change_title():
|
||||||
|
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 )
|
||||||
|
########
|
||||||
|
|
||||||
|
|
||||||
|
########
|
||||||
|
#### scene loading
|
||||||
func goto_scene_loading( path ):
|
func goto_scene_loading( path ):
|
||||||
|
print( "goto: "+str(path) )
|
||||||
|
|
||||||
get_node("background_loader").show()
|
get_node("background_loader").show()
|
||||||
loader = ResourceLoader.load_interactive( path )
|
loader = ResourceLoader.load_interactive( path )
|
||||||
if loader == null: # check for errors
|
if loader == null: # check for errors
|
||||||
# show_error()
|
show_error()
|
||||||
return
|
return
|
||||||
|
|
||||||
set_process(true)
|
set_process(true)
|
||||||
|
|
||||||
if current_scene:
|
if current_scene:
|
||||||
|
print( "queue_free: "+str(current_scene.name) )
|
||||||
current_scene.queue_free() # get rid of the old scene
|
current_scene.queue_free() # get rid of the old scene
|
||||||
|
|
||||||
wait_frames = 1
|
wait_frames = 1
|
||||||
|
|
||||||
func _process( time ):
|
func _process( time ):
|
||||||
|
print( "process" )
|
||||||
if loader == null:
|
if loader == null:
|
||||||
# no need to process anymore
|
# no need to process anymore
|
||||||
set_process(false)
|
set_process(false)
|
||||||
|
@ -60,19 +70,21 @@ func _process(time):
|
||||||
|
|
||||||
var t = OS.get_ticks_msec()
|
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
|
||||||
|
|
||||||
|
print( "poll: "+str((float(loader.get_stage()) / loader.get_stage_count())*100)+"%" )
|
||||||
|
|
||||||
# poll your loader
|
# poll your loader
|
||||||
var err = loader.poll()
|
var err = loader.poll()
|
||||||
update_progress()
|
# update_progress()
|
||||||
|
|
||||||
if err == ERR_FILE_EOF: # load finished
|
if err == ERR_FILE_EOF: # load finished
|
||||||
# update_progress()
|
# update_progress()
|
||||||
|
|
||||||
var resource = loader.get_resource()
|
var resource = loader.get_resource()
|
||||||
loader = null
|
loader = null
|
||||||
set_new_scene( resource )
|
set_new_scene( resource )
|
||||||
break
|
break
|
||||||
elif err == OK:
|
elif err == OK:
|
||||||
# update_progress()
|
update_progress()
|
||||||
pass
|
pass
|
||||||
else: # error during loading
|
else: # error during loading
|
||||||
show_error()
|
show_error()
|
||||||
|
@ -92,16 +104,36 @@ func set_new_scene( scene_resource ):
|
||||||
|
|
||||||
progress_texture.value = 0
|
progress_texture.value = 0
|
||||||
|
|
||||||
get_node("background_loader").hide()
|
|
||||||
|
|
||||||
current_scene = scene_resource.instance()
|
current_scene = scene_resource.instance()
|
||||||
get_tree().get_root().add_child(current_scene)
|
get_tree().get_root().add_child(current_scene)
|
||||||
# get_tree().set_current_scene( current_scene )
|
# get_tree().set_current_scene( current_scene )
|
||||||
|
|
||||||
|
get_node("background_loader").hide()
|
||||||
|
|
||||||
|
|
||||||
########################################
|
func _on_login_scene_character_creation_finished():
|
||||||
#### deffered goto without loading #####
|
var config_file = ConfigFile.new()
|
||||||
|
var err = config_file.load( "user://player.cfg" )
|
||||||
|
if err:
|
||||||
|
print("Error code when loading config file: ", err)
|
||||||
|
|
||||||
|
config_file.set_value(str(global.character_slot), "name", global.character_name)
|
||||||
|
config_file.set_value(str(global.character_slot), "color", global.character_color)
|
||||||
|
|
||||||
|
config_file.save( "user://player.cfg" )
|
||||||
|
print("test")
|
||||||
|
# global.goto_scene_loading( "res://login_scene/login_scene.tscn" )
|
||||||
|
global.goto_scene_loading( "res://game_scene/game_scene.tscn" )
|
||||||
|
# get_tree().change_scene( "res://game_scene/game_scene.tscn" )
|
||||||
|
|
||||||
|
func _on_logout_button_pressed():
|
||||||
|
global.goto_scene_loading( "res://login_scene/login_scene.tscn" )
|
||||||
|
# get_tree().change_scene( "res://login_scene/login_scene.tscn" )
|
||||||
|
########
|
||||||
|
|
||||||
|
########
|
||||||
|
#### defered goto without loading
|
||||||
func goto_scene( path ):
|
func goto_scene( path ):
|
||||||
# This function will usually be called from a signal callback,
|
# This function will usually be called from a signal callback,
|
||||||
# or some other function from the running scene.
|
# or some other function from the running scene.
|
||||||
|
@ -128,46 +160,9 @@ func _deferred_goto_scene( path ):
|
||||||
current_scene = s.instance()
|
current_scene = s.instance()
|
||||||
|
|
||||||
# Add it to the active scene, as child of root.
|
# Add it to the active scene, as child of root.
|
||||||
main_scene.add_child( current_scene )
|
get_tree().get_root().add_child( current_scene )
|
||||||
|
|
||||||
# Optional, to make it compatible with the SceneTree.change_scene() API.
|
# Optional, to make it compatible with the SceneTree.change_scene() API.
|
||||||
get_tree().set_current_scene( current_scene )
|
get_tree().set_current_scene( current_scene )
|
||||||
|
########
|
||||||
|
|
||||||
########################################
|
|
||||||
########################################
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
########################################
|
|
||||||
############### Main ###################
|
|
||||||
func on_window_size_changed():
|
|
||||||
change_title()
|
|
||||||
|
|
||||||
func change_title():
|
|
||||||
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 )
|
|
||||||
|
|
||||||
func _on_login_scene_character_creation_finished():
|
|
||||||
var config_file = ConfigFile.new()
|
|
||||||
var err = config_file.load( "user://player.cfg" )
|
|
||||||
if err:
|
|
||||||
print("Error code when loading config file: ", err)
|
|
||||||
|
|
||||||
config_file.set_value(str(global.character_slot), "name", global.character_name)
|
|
||||||
config_file.set_value(str(global.character_slot), "color", global.character_color)
|
|
||||||
|
|
||||||
config_file.save( "user://player.cfg" )
|
|
||||||
print("test")
|
|
||||||
global.goto_scene_loading( "res://game_scene/game_scene.tscn" )
|
|
||||||
# get_tree().change_scene( "res://game_scene/game_scene.tscn" )
|
|
||||||
|
|
||||||
func _on_logout_button_pressed():
|
|
||||||
global.goto_scene_loading( "res://login_scene/login_scene.tscn" )
|
|
||||||
# get_tree().change_scene( "res://login_scene/login_scene.tscn" )
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ config_version=3
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Khanat"
|
config/name="Khanat"
|
||||||
run/main_scene="res://scenes/Main.tscn"
|
run/main_scene="res://login_scene/login_scene.tscn"
|
||||||
boot_splash/image="res://assets/GUI/images/new_launcher_bg_0-1.png"
|
boot_splash/image="res://assets/GUI/images/new_launcher_bg_0-1.png"
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
extends Node
|
|
||||||
|
|
||||||
#const WINDOW_TITLE_INPUT = "GUI/Settings/Menus/TabContainer/Test/ScrollContainer/VBoxContainer/TitleBox/Title"
|
|
||||||
#
|
|
||||||
#func _ready():
|
|
||||||
# change_title()
|
|
||||||
# get_tree().get_root().connect("size_changed", self, "on_window_size_changed")
|
|
||||||
#
|
|
||||||
## global.goto_scene_loading( "res://login_scene/login_scene.tscn" )
|
|
||||||
## if global.character_creation_camera:
|
|
||||||
## global.character_creation_camera.make_current()
|
|
||||||
#
|
|
||||||
# get_tree().change_scene( "res://login_scene/login_scene.tscn" )
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
#func _process(delta):
|
|
||||||
# pass
|
|
||||||
#
|
|
||||||
#func on_window_size_changed():
|
|
||||||
# change_title()
|
|
||||||
#
|
|
||||||
#func change_title():
|
|
||||||
# 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 )
|
|
||||||
#
|
|
||||||
#func _on_login_scene_character_creation_finished():
|
|
||||||
# var config_file = ConfigFile.new()
|
|
||||||
# var err = config_file.load( "user://player.cfg" )
|
|
||||||
# if err:
|
|
||||||
# print("Error code when loading config file: ", err)
|
|
||||||
#
|
|
||||||
# config_file.set_value(str(global.character_slot), "name", global.character_name)
|
|
||||||
# config_file.set_value(str(global.character_slot), "color", global.character_color)
|
|
||||||
#
|
|
||||||
# config_file.save( "user://player.cfg" )
|
|
||||||
# print("test")
|
|
||||||
## global.goto_scene_loading( "res://game_scene/game_scene.tscn" )
|
|
||||||
# get_tree().change_scene( "res://game_scene/game_scene.tscn" )
|
|
||||||
#
|
|
||||||
#func _on_logout_button_pressed():
|
|
||||||
## global.goto_scene_loading( "res://login_scene/login_scene.tscn" )
|
|
||||||
# get_tree().change_scene( "res://login_scene/login_scene.tscn" )
|
|
||||||
## pass
|
|
|
@ -1,10 +0,0 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://scenes/Main.gd" type="Script" id=1]
|
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
|
||||||
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
_sections_unfolded = [ "Pause" ]
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue