WIP: texture changement button

This commit is contained in:
2-1-1-2 2023-02-25 14:02:57 +01:00
parent a0eb8b9225
commit 225c912f2b
26 changed files with 334 additions and 15 deletions

BIN
Assets/skin_assets/VCR_OSD_MONO_1.001.ttf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/skin_assets/button_focus.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_focus.png-e1981e994155ca422d4d953f4af77164.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/skin_assets/button_focus.png"
dest_files=[ "res://.import/button_focus.png-e1981e994155ca422d4d953f4af77164.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
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
Assets/skin_assets/button_normal.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_normal.png-7ceacf3d6625a4e76f581d0ae1258671.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/skin_assets/button_normal.png"
dest_files=[ "res://.import/button_normal.png-7ceacf3d6625a4e76f581d0ae1258671.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
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
Assets/skin_assets/button_pressed.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/button_pressed.png-501e49eae0845aa00c0264094791a5b9.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/skin_assets/button_pressed.png"
dest_files=[ "res://.import/button_pressed.png-501e49eae0845aa00c0264094791a5b9.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
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

0
Assets/tmp.png.import Executable file → Normal file
View file

0
Assets/tmp1.png.import Executable file → Normal file
View file

0
Assets/tmp2.png.import Executable file → Normal file
View file

0
Assets/tmp3.png.import Executable file → Normal file
View file

View file

@ -0,0 +1,11 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://Assets/skin_assets/button_focus.png" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 16, 16 )
margin_left = 10.0
margin_right = 10.0
margin_top = 2.0
margin_bottom = 5.0

View file

@ -0,0 +1,11 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://Assets/skin_assets/button_normal.png" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 16, 16 )
margin_left = 10.0
margin_right = 10.0
margin_top = 2.0
margin_bottom = 5.0

View file

@ -0,0 +1,11 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://Assets/skin_assets/button_pressed.png" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 16, 16 )
margin_left = 10.0
margin_right = 10.0
margin_top = 2.0
margin_bottom = 5.0

BIN
Assets/windows.png (Stored with Git LFS) Normal file

Binary file not shown.

35
Assets/windows.png.import Normal file
View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/windows.png-57bc7ca67ed2fd90bf67137af0c36b14.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/windows.png"
dest_files=[ "res://.import/windows.png-57bc7ca67ed2fd90bf67137af0c36b14.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
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

0
Characters/Player.tscn Executable file → Normal file
View file

8
Characters/Villain.gd Executable file → Normal file
View file

@ -3,11 +3,16 @@ extends Node2D
onready var me = $AnimatedSprite onready var me = $AnimatedSprite
onready var timer onready var timer
var limit_random
var rng = RandomNumberGenerator.new()
onready var button = $"../Button/"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
timer = 0 timer = 0
rng.randomize()
limit_random = rng.randi_range(2, 10)
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
@ -16,8 +21,9 @@ func _process(delta):
match me.get_frame(): match me.get_frame():
0: 0:
# Vert # Vert
if timer >= 5: if timer >= limit_random:
timer = 0 timer = 0
limit_random = rng.randi_range(2, 10)
me.set_frame(1) me.set_frame(1)
1: 1:
# Orange # Orange

0
Characters/Villain.tscn Executable file → Normal file
View file

28
Scenes/Button_Node2D.gd Executable file → Normal file
View file

@ -1,21 +1,37 @@
extends Button extends Button
onready var villain = $"../Villain/AnimatedSprite" onready var villain = $"../Villain/AnimatedSprite"
var etat
var _texture1 = load("res://Assets//skin_assets/button_normal.png")
var _texture2 = load("res://Assets//skin_assets/button_pressed.png")
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
etat = false
pass # Replace with function body. pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): func _process(_delta):
match villain.get_frame():
2:
if(etat) : print("non")
else: print("caché")
_:
if(etat) : print("oui")
else: print("caché")
# pass # pass
func _on_Button_pressed(): func _on_Button_pressed():
match villain.get_frame(): etat = !etat
2: """
print("non") if(etat) :
_: self.StyleBoxTexture.set_texture(_texture1) # reste appuyé
print("oui") else :
self.StyleBoxTexture.set_texture(_texture2) # pas appuyé
"""
""" """

27
Scenes/Node2D.tscn Executable file → Normal file
View file

@ -1,27 +1,42 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://Characters/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://Characters/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Characters/Villain.tscn" type="PackedScene" id=2] [ext_resource path="res://Characters/Villain.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scenes/Button_Node2D.gd" type="Script" id=3] [ext_resource path="res://Scenes/Button_Node2D.gd" type="Script" id=3]
[ext_resource path="res://Assets/windows.png" type="Texture" id=4]
[ext_resource path="res://Assets/tres_button/hover.tres" type="StyleBox" id=5]
[ext_resource path="res://Assets/tres_button/normal.tres" type="StyleBox" id=6]
[ext_resource path="res://Assets/tres_button/pressed.tres" type="StyleBox" id=7]
[sub_resource type="Theme" id=1] [sub_resource type="Theme" id=1]
[node name="Node2D" type="Node2D"] [node name="Node2D" type="Node2D"]
[node name="Player" parent="." instance=ExtResource( 1 )] [node name="Player" parent="." instance=ExtResource( 1 )]
visible = false
position = Vector2( 719, 386 ) position = Vector2( 719, 386 )
script = null script = null
[node name="Button" type="Button" parent="."] [node name="Button" type="Button" parent="."]
margin_left = 654.0 margin_left = 462.0
margin_top = 288.0 margin_top = 361.0
margin_right = 784.0 margin_right = 592.0
margin_bottom = 322.0 margin_bottom = 395.0
theme = SubResource( 1 ) theme = SubResource( 1 )
custom_colors/font_color = Color( 0.27451, 0.207843, 0.207843, 1 )
custom_styles/hover = ExtResource( 5 )
custom_styles/pressed = ExtResource( 7 )
custom_styles/normal = ExtResource( 6 )
text = "CLIQUE MOI" text = "CLIQUE MOI"
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="Villain" parent="." instance=ExtResource( 2 )] [node name="Villain" parent="." instance=ExtResource( 2 )]
position = Vector2( 276, 189 ) position = Vector2( 943, 639 )
[node name="Windows" type="Sprite" parent="."]
visible = false
position = Vector2( 512, 358 )
z_index = -3
texture = ExtResource( 4 )
[connection signal="pressed" from="Button" to="Button" method="_on_Button_pressed"] [connection signal="pressed" from="Button" to="Button" method="_on_Button_pressed"]

23
Scenes/Screen_Menu.gd Normal file
View file

@ -0,0 +1,23 @@
extends Control
# 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 _on_PlayButton_pressed():
print("ici")
get_tree().change_scene("res://Scenes/Node2D.tscn")
func _on_Help_Button_pressed():
print("help")
func _on_Quit_Button_pressed():
get_tree().quit()
# Replace with function body.

71
Scenes/menu.tscn Normal file
View file

@ -0,0 +1,71 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://Assets/windows.png" type="Texture" id=1]
[ext_resource path="res://Assets/skin_assets/VCR_OSD_MONO_1.001.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://Assets/tres_button/hover.tres" type="StyleBox" id=3]
[ext_resource path="res://Assets/tres_button/normal.tres" type="StyleBox" id=4]
[ext_resource path="res://Assets/tres_button/pressed.tres" type="StyleBox" id=5]
[ext_resource path="res://Scenes/Screen_Menu.gd" type="Script" id=6]
[sub_resource type="DynamicFont" id=1]
size = 34
outline_color = Color( 0.298039, 0.0745098, 0.0745098, 1 )
font_data = ExtResource( 2 )
[node name="Node2D" type="Node2D"]
[node name="Windows" type="Sprite" parent="."]
position = Vector2( 512, 360 )
z_index = -2
texture = ExtResource( 1 )
[node name="MenuButton" type="MenuButton" parent="."]
margin_left = 480.0
margin_top = 232.0
margin_right = 584.0
margin_bottom = 392.0
script = ExtResource( 6 )
[node name="VBoxContainer" type="VBoxContainer" parent="MenuButton"]
margin_left = -24.0
margin_top = 40.0
margin_right = 76.0
margin_bottom = 203.0
custom_constants/separation = 26
alignment = 1
[node name="PlayButton" type="Button" parent="MenuButton/VBoxContainer"]
margin_right = 100.0
margin_bottom = 37.0
custom_colors/font_color = Color( 0.34902, 0.313726, 0.313726, 1 )
custom_fonts/font = SubResource( 1 )
custom_styles/hover = ExtResource( 3 )
custom_styles/pressed = ExtResource( 5 )
custom_styles/normal = ExtResource( 4 )
text = "PLAY"
[node name="Help_Button" type="Button" parent="MenuButton/VBoxContainer"]
margin_top = 63.0
margin_right = 100.0
margin_bottom = 100.0
custom_colors/font_color = Color( 0.34902, 0.313726, 0.313726, 1 )
custom_fonts/font = SubResource( 1 )
custom_styles/hover = ExtResource( 3 )
custom_styles/pressed = ExtResource( 5 )
custom_styles/normal = ExtResource( 4 )
text = "HELP"
[node name="Quit_Button" type="Button" parent="MenuButton/VBoxContainer"]
margin_top = 126.0
margin_right = 100.0
margin_bottom = 163.0
custom_colors/font_color = Color( 0.34902, 0.313726, 0.313726, 1 )
custom_fonts/font = SubResource( 1 )
custom_styles/hover = ExtResource( 3 )
custom_styles/pressed = ExtResource( 5 )
custom_styles/normal = ExtResource( 4 )
text = "QUIT"
[connection signal="pressed" from="MenuButton/VBoxContainer/PlayButton" to="MenuButton" method="_on_PlayButton_pressed"]
[connection signal="pressed" from="MenuButton/VBoxContainer/Help_Button" to="MenuButton" method="_on_Help_Button_pressed"]
[connection signal="pressed" from="MenuButton/VBoxContainer/Quit_Button" to="MenuButton" method="_on_Quit_Button_pressed"]

0
default_env.tres Executable file → Normal file
View file

0
icon.png.import Executable file → Normal file
View file

4
project.godot Executable file → Normal file
View file

@ -11,13 +11,13 @@ config_version=4
[application] [application]
config/name="Gja" config/name="Gja"
run/main_scene="res://Scenes/Node2D.tscn" run/main_scene="res://Scenes/menu.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[display] [display]
window/size/height=720
window/size/resizable=false window/size/resizable=false
window/size/fullscreen=true
[gui] [gui]