amelioration des fenetres.

This commit is contained in:
osquallo 2018-08-19 11:58:35 +02:00
parent 5d8bb54350
commit ba2590c2a5
7 changed files with 285 additions and 89 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -1,12 +1,18 @@
extends MarginContainer
export(bool) var is_movable = true
export(bool) var is_resizable = true
export(bool) var is_borderless = false
export(String) var title = "Window"
export(Color) var background_color = Color( 1.0, 1.0, 1.0, 1.0 )
export( bool ) var is_movable = true
export( bool ) var is_resizable = true
export( bool ) var is_borderless = false
export( bool ) var has_footer = true
export(String) var background_texture = "res://assets/GUI/images/background_test.png"
export( String ) var title = "Window"
export( Color ) var content_color = Color( 1.0, 1.0, 1.0, 1.0 )# test
export( Color ) var background_color = Color( 1.0, 1.0, 1.0, 1.0 )
export( Texture ) var background_texture = null
export( Vector2 ) var min_size= Vector2( 128, 128 )
export( Rect2 ) var content_margin = Rect2( 8, 8, 8, 8 )
signal window_clicked( window )
@ -18,6 +24,7 @@ var current_rect_size = Vector2( 0, 0 )
var current_rect_position = Vector2( -1, -1 )
var is_resizing = false
var is_moving = false
var size_changed = true
func add_child( node):
if self.get_content():
@ -76,11 +83,15 @@ func _enter_tree():
if not self.has_node( "background" ):
background = NinePatchRect.new()
background.name = "background"
var background_image = Image.new()
if not background_image.load( background_texture ) == OK :
print("Erreur lors du chargement de l'image: "+background_texture )
background.texture = ImageTexture.new()
background.texture.create_from_image( background_image )
if not background_texture:
var background_image = Image.new()
if not background_image.load( "res://addons/ui_window/background_default.jpg" ) == OK :
print("Erreur lors du chargement de l'image: "+str("res://addons/ui_window/background_default.jpg") )
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
@ -119,7 +130,7 @@ func _enter_tree():
header_box.size_flags_horizontal = SIZE_EXPAND_FILL
header_box.size_flags_vertical = SIZE_SHRINK_CENTER
header_box.set( "custom_constants/margin_right", 0)
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)
@ -260,10 +271,10 @@ func _enter_tree():
footer_box.name = "footer_box"
footer_box.size_flags_horizontal = SIZE_FILL
footer_box.size_flags_vertical = SIZE_FILL
footer_box.set( "custom_constants/margin_right", 6)
footer_box.set( "custom_constants/margin_top", 2)
footer_box.set( "custom_constants/margin_left", 6)
footer_box.set( "custom_constants/margin_bottom", 6)
footer_box.set( "custom_constants/margin_right", content_margin.position.y)
footer_box.set( "custom_constants/margin_top", content_margin.size.x)
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 )
###
@ -322,6 +333,7 @@ func _enter_tree():
$background.patch_margin_top = 1
$background.patch_margin_right = 1
$background.patch_margin_bottom = 1
header_box.rect_min_size.y = 1
close_button.visible = false
open_button.visible = false
quit_button.visible = false
@ -331,7 +343,10 @@ func _enter_tree():
if not is_resizable:
$v_box_container/Footer/HBoxContainer/Resize.visible = false
if not has_footer:
footer_box.visible = false
else:
footer_box.get_node( "footer/resize" ).visible = false
func _ready():
# On déplace les enfants ajouter via l'editeur sous content.
@ -350,7 +365,10 @@ func _ready():
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")
@ -417,7 +435,8 @@ func _input( event ):
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 )

View file

@ -1,15 +1,16 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=12 format=2]
[ext_resource path="res://scenes/GUI/HUD/HUD.gd" type="Script" id=1]
[ext_resource path="res://scenes/GUI/HUD/Windows.gd" type="Script" id=2]
[ext_resource path="res://addons/ui_window/ui_window.gd" type="Script" id=3]
[ext_resource path="res://addons/ui_window/icon.png" type="Texture" id=4]
[ext_resource path="res://scenes/GUI/HUD/chat_lines.gd" type="Script" id=5]
[ext_resource path="res://scenes/GUI/HUD/rich_text_label.gd" type="Script" id=6]
[ext_resource path="res://scenes/GUI/MusicControls/MusicControls.tscn" type="PackedScene" id=7]
[ext_resource path="res://scenes/GUI/HUD/oubli.gd" type="Script" id=8]
[ext_resource path="res://scenes/GUI/HUD/trauma.gd" type="Script" id=9]
[ext_resource path="res://scenes/GUI/HUD/douleur.gd" type="Script" id=10]
[ext_resource path="res://assets/GUI/images/background_test.png" type="Texture" id=5]
[ext_resource path="res://scenes/GUI/HUD/chat_lines.gd" type="Script" id=6]
[ext_resource path="res://scenes/GUI/HUD/rich_text_label.gd" type="Script" id=7]
[ext_resource path="res://scenes/GUI/MusicControls/MusicControls.tscn" type="PackedScene" id=8]
[ext_resource path="res://scenes/GUI/HUD/oubli.gd" type="Script" id=9]
[ext_resource path="res://scenes/GUI/HUD/trauma.gd" type="Script" id=10]
[ext_resource path="res://scenes/GUI/HUD/douleur.gd" type="Script" id=11]
[node name="HUD" type="MarginContainer" index="0"]
@ -28,7 +29,7 @@ custom_constants/margin_top = 0
custom_constants/margin_left = 0
custom_constants/margin_bottom = 0
script = ExtResource( 1 )
_sections_unfolded = [ "Margin", "Mouse", "Rect", "Size Flags", "Theme", "Visibility", "custom_constants" ]
_sections_unfolded = [ "Margin", "Mouse", "Pause", "Rect", "Size Flags", "Theme", "Visibility", "custom_constants" ]
[node name="overlay_oubli" type="Panel" parent="." index="0"]
@ -79,7 +80,7 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 2 )
_sections_unfolded = [ "Mouse", "Size Flags", "Theme", "Visibility", "custom_styles" ]
_sections_unfolded = [ "Mouse", "Pause", "Size Flags", "Theme", "Visibility", "custom_styles" ]
[node name="ui_window" type="MarginContainer" parent="Windows" index="0"]
@ -105,9 +106,13 @@ __meta__ = {
is_movable = true
is_resizable = true
is_borderless = false
has_footer = true
title = "Test window plugin"
content_color = Color( 1, 1, 1, 1 )
background_color = Color( 0.808594, 0.808594, 0.808594, 1 )
background_texture = "res://assets/GUI/images/bg2.jpg"
background_texture = null
min_size = Vector2( 128, 128 )
content_margin = Rect2( 8, 8, 8, 8 )
[node name="chat" type="MarginContainer" parent="Windows" index="1"]
@ -126,16 +131,21 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
script = ExtResource( 3 )
_sections_unfolded = [ "custom_constants" ]
_sections_unfolded = [ "Pause", "custom_constants" ]
__meta__ = {
"_edit_group_": true,
"_editor_icon": ExtResource( 4 )
}
is_movable = true
is_resizable = true
is_borderless = true
has_footer = true
title = "Test Chat"
background_color = Color( 0.808594, 0.808594, 0.808594, 1 )
background_texture = "res://assets/GUI/images/background_test.png"
content_color = Color( 1, 1, 1, 1 )
background_color = Color( 1, 1, 1, 1 )
background_texture = ExtResource( 5 )
min_size = Vector2( 128, 128 )
content_margin = Rect2( 8, 8, 8, 8 )
[node name="chat_lines" type="VBoxContainer" parent="Windows/chat" index="0"]
@ -153,7 +163,7 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 0
script = ExtResource( 5 )
script = ExtResource( 6 )
_sections_unfolded = [ "Size Flags" ]
[node name="label" type="Label" parent="Windows/chat/chat_lines" index="0"]
@ -205,7 +215,7 @@ scroll_active = false
scroll_following = false
selection_enabled = true
override_selected_font_color = false
script = ExtResource( 6 )
script = ExtResource( 7 )
_sections_unfolded = [ "BBCode", "Mouse", "Size Flags", "custom_constants" ]
[node name="rich_text_label2" type="RichTextLabel" parent="Windows/chat/chat_lines" index="2"]
@ -235,7 +245,7 @@ scroll_active = false
scroll_following = false
selection_enabled = true
override_selected_font_color = false
script = ExtResource( 6 )
script = ExtResource( 7 )
_sections_unfolded = [ "BBCode", "Mouse", "Size Flags" ]
[node name="footer_line_edit" type="LineEdit" parent="Windows/chat" index="1"]
@ -263,7 +273,204 @@ caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Caret", "Placeholder", "Size Flags" ]
[node name="Music" parent="." index="3" instance=ExtResource( 7 )]
[node name="chat2" type="MarginContainer" parent="Windows" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 311.0
margin_top = 431.0
margin_right = 549.0
margin_bottom = 570.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
script = ExtResource( 3 )
_sections_unfolded = [ "Pause", "custom_constants" ]
__meta__ = {
"_edit_group_": true,
"_editor_icon": ExtResource( 4 )
}
is_movable = true
is_resizable = true
is_borderless = false
has_footer = true
title = "Test Chat"
content_color = Color( 1, 1, 1, 1 )
background_color = Color( 1, 1, 1, 1 )
background_texture = null
min_size = Vector2( 128, 128 )
content_margin = Rect2( 8, 8, 8, 8 )
[node name="chat_lines" type="VBoxContainer" parent="Windows/chat2" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 8.0
margin_right = 238.0
margin_bottom = 139.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
script = ExtResource( 6 )
_sections_unfolded = [ "Size Flags" ]
[node name="label" type="Label" parent="Windows/chat2/chat_lines" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 230.0
margin_bottom = 31.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.164063, 0.31427, 1, 1 )
text = "MDJ: Bienvenue sur Khanat, rêvez bien !"
autowrap = true
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "custom_colors" ]
[node name="rich_text_label" type="RichTextLabel" parent="Windows/chat2/chat_lines" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 35.0
margin_right = 230.0
margin_bottom = 35.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = true
focus_mode = 2
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
bbcode_enabled = true
bbcode_text = "Ceci est un test en [color=red]couleur[/color]."
visible_characters = -1
percent_visible = 1.0
meta_underlined = true
tab_size = 4
text = "Ceci est un test en couleur."
scroll_active = false
scroll_following = false
selection_enabled = true
override_selected_font_color = false
script = ExtResource( 7 )
_sections_unfolded = [ "BBCode", "Mouse", "Size Flags", "custom_constants" ]
[node name="rich_text_label2" type="RichTextLabel" parent="Windows/chat2/chat_lines" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 39.0
margin_right = 230.0
margin_bottom = 39.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = true
focus_mode = 2
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
bbcode_enabled = true
bbcode_text = "Ceci est un test en [url=\"test@test.io\"]ligne[/url]."
visible_characters = -1
percent_visible = 1.0
meta_underlined = true
tab_size = 4
text = "Ceci est un test en ligne."
scroll_active = false
scroll_following = false
selection_enabled = true
override_selected_font_color = false
script = ExtResource( 7 )
_sections_unfolded = [ "BBCode", "Mouse", "Size Flags" ]
[node name="footer_line_edit" type="LineEdit" parent="Windows/chat2" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 8.0
margin_top = 115.0
margin_right = 238.0
margin_bottom = 139.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 = 3
size_flags_vertical = 10
focus_mode = 2
context_menu_enabled = true
placeholder_alpha = 0.6
caret_blink = true
caret_blink_speed = 0.65
caret_position = 0
_sections_unfolded = [ "Caret", "Placeholder", "Size Flags" ]
[node name="music" type="MarginContainer" parent="Windows" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 8.0
margin_bottom = 40.0
rect_min_size = Vector2( 256, 64 )
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
script = ExtResource( 3 )
_sections_unfolded = [ "Rect" ]
__meta__ = {
"_editor_icon": ExtResource( 4 )
}
is_movable = true
is_resizable = true
is_borderless = true
has_footer = true
title = "Musique"
content_color = Color( 1, 1, 1, 1 )
background_color = Color( 1, 1, 1, 1 )
background_texture = null
min_size = Vector2( 128, 164 )
content_margin = Rect2( 8, 8, 8, 8 )
[node name="Music" parent="Windows/music" index="0" instance=ExtResource( 8 )]
margin_left = 8.0
margin_bottom = 66.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Music" parent="." index="3" instance=ExtResource( 8 )]
margin_left = 942.0
margin_right = 1024.0
@ -288,7 +495,7 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 6
size_flags_vertical = 10
alignment = 0
_sections_unfolded = [ "Size Flags" ]
_sections_unfolded = [ "Size Flags", "Theme", "custom_constants" ]
[node name="oubli" type="HBoxContainer" parent="Jauges" index="0"]
@ -306,8 +513,8 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 0
size_flags_vertical = 9
alignment = 0
script = ExtResource( 8 )
_sections_unfolded = [ "Size Flags", "Visibility" ]
script = ExtResource( 9 )
_sections_unfolded = [ "Size Flags", "Visibility", "custom_constants" ]
[node name="ProgressBar" type="ProgressBar" parent="Jauges/oubli" index="0"]
@ -332,7 +539,7 @@ value = 0.0
exp_edit = false
rounded = false
percent_visible = false
_sections_unfolded = [ "Material", "Percent", "Rect", "Size Flags" ]
_sections_unfolded = [ "Material", "Percent", "Rect", "Size Flags", "custom_fonts" ]
[node name="Label" type="Label" parent="Jauges/oubli" index="1"]
@ -372,7 +579,7 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 0
size_flags_vertical = 9
alignment = 0
script = ExtResource( 9 )
script = ExtResource( 10 )
_sections_unfolded = [ "Size Flags", "Visibility" ]
[node name="ProgressBar" type="ProgressBar" parent="Jauges/trauma" index="0"]
@ -438,7 +645,7 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 0
size_flags_vertical = 9
alignment = 0
script = ExtResource( 10 )
script = ExtResource( 11 )
_sections_unfolded = [ "Size Flags", "Visibility" ]
[node name="ProgressBar" type="ProgressBar" parent="Jauges/douleur" index="0"]
@ -513,29 +720,10 @@ flat = false
align = 1
_sections_unfolded = [ "Size Flags" ]
[node name="scroll_container" type="ScrollContainer" parent="." index="6"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 1024.0
margin_bottom = 600.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = true
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
scroll_horizontal_enabled = true
scroll_horizontal = 0
scroll_vertical_enabled = true
scroll_vertical = 0
scroll_deadzone = 0
_sections_unfolded = [ "Focus", "Mouse", "Scroll", "Size Flags" ]
[connection signal="gui_input" from="Windows/chat/footer_line_edit" to="Windows/chat/chat_lines" method="_on_footer_line_edit_gui_input"]
[connection signal="gui_input" from="Windows/chat2/footer_line_edit" to="Windows/chat2/chat_lines" method="_on_footer_line_edit_gui_input"]
[connection signal="value_changed" from="Jauges/oubli/ProgressBar" to="Jauges/oubli" method="_on_ProgressBar_value_changed"]
[connection signal="value_changed" from="Jauges/trauma/ProgressBar" to="Jauges/trauma" method="_on_ProgressBar_value_changed"]

View file

@ -5,16 +5,16 @@ func _ready():
for child in self.get_children():
child.connect( "window_clicked", self, "_on_window_clicked" )
var new_label = Label.new()
new_label.set_name( "azerty" )
new_label.set_text( "azertyuiop sdfghjklm wxcvbn" )
new_label.set_autowrap( true )
$ui_window.add_child( new_label )
new_label = Label.new()
new_label.set_name( "azerty2" )
new_label.set_text( "2azertyuiop2 2sdfghjklm2 wxcvbn2" )
new_label.set_autowrap( true )
$ui_window.add_child( new_label )
# var new_label = Label.new()
# new_label.set_name( "azerty" )
# new_label.set_text( "azertyuiop sdfghjklm wxcvbn" )
# new_label.set_autowrap( true )
# $ui_window.add_child( new_label )
# new_label = Label.new()
# new_label.set_name( "azerty2" )
# new_label.set_text( "2azertyuiop2 2sdfghjklm2 wxcvbn2" )
# new_label.set_autowrap( true )
# $ui_window.add_child( new_label )
func _on_window_clicked( window ):

View file

@ -5,10 +5,10 @@ var line_edit_path = "../../../../footer_box/footer/footer_line_edit"
var new_line_added = false
func _process(delta):
if new_line_added:
if self.new_line_added:
var content_scroll = get_node( "../.." )
content_scroll.scroll_vertical = 2*self.rect_size.y
new_line_added = false
self.new_line_added = false
func _on_footer_line_edit_gui_input( event ):
@ -24,4 +24,4 @@ func _on_footer_line_edit_gui_input( event ):
new_line.selection_enabled = true
self.add_child( new_line )
line_edit.text = ""
new_line_added = true
self.new_line_added = true

View file

@ -1,16 +1,4 @@
extends RichTextLabel
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
func _ready():
# Called when the node is added to the scene for the first time.
# Initialization here
pass
func _process(delta):
self.rect_min_size.y = global.font_size + 4
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
self.rect_min_size.y = global.font_size + global.font_size/2

View file

@ -14,5 +14,6 @@ func _ready():
func _on_font_size_bar_value_changed(value):
$font_size_value.text = str( value )
var menus_node = get_node( "../../../../../" )
global.font_size = value
menus_node.get_theme().default_font.size = value
emit_signal( "font_changed" )