création du menu principal

pull/34/head
Valentin Stark 3 years ago
parent 029ea030d5
commit 117bcfe7ee
  1. 18
      menu/LoadWorld.gd
  2. 53
      menu/LoadWorld.tscn
  3. 4
      menu/MainMenu.gd
  4. 21
      menu/MainMenu.tscn
  5. 14
      menu/NewWorld.gd
  6. 64
      menu/NewWorld.tscn
  7. 74
      theme/theme.tres
  8. 3
      utils/Global.gd
  9. 21
      world/game.gd

@ -0,0 +1,18 @@
extends Control
func _ready():
for terrain in Global.terrain.list():
var name = terrain.name
var button = Button.new()
button.text = terrain.name
button.connect("pressed", self, "_button_pressed", [name])
$VBoxContainer/ScrollContainer/WorldList.add_child(button)
func _on_CancelButton_pressed():
get_tree().change_scene("res://menu/MainMenu.tscn")
func _button_pressed(name):
Global.terrain_name = name
get_tree().change_scene("res://world/game.tscn")

@ -0,0 +1,53 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://theme/theme.tres" type="Theme" id=1]
[ext_resource path="res://menu/LoadWorld.gd" type="Script" id=2]
[node name="LoadWorld" type="Control"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -512.0
margin_top = -300.0
margin_right = 512.0
margin_bottom = 300.0
theme = ExtResource( 1 )
script = ExtResource( 2 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -240.0
margin_top = -131.5
margin_right = 240.0
margin_bottom = 131.5
[node name="Title" type="Label" parent="VBoxContainer"]
margin_right = 480.0
margin_bottom = 64.0
text = "Charger un monde"
align = 1
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
margin_top = 68.0
margin_right = 480.0
margin_bottom = 218.0
rect_min_size = Vector2( 0, 150 )
[node name="WorldList" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 222.0
margin_right = 480.0
margin_bottom = 263.0
[node name="CancelButton" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_right = 480.0
margin_bottom = 41.0
size_flags_horizontal = 3
text = "Annuler"
[connection signal="pressed" from="VBoxContainer/HBoxContainer/CancelButton" to="." method="_on_CancelButton_pressed"]

@ -6,11 +6,11 @@ func _ready():
func _on_NewButton_pressed():
get_tree().change_scene("res://world/game.tscn")
get_tree().change_scene("res://menu/NewWorld.tscn")
func _on_LoadButton_pressed():
pass # Replace with function body.
get_tree().change_scene("res://menu/LoadWorld.tscn")
func _on_QuitButton_pressed():

@ -21,26 +21,31 @@ margin_top = -74.5
margin_right = 158.0
margin_bottom = 74.5
[node name="Title" type="Label" parent="VBoxContainer"]
margin_right = 316.0
margin_bottom = 131.0
text = "Societer
"
align = 1
[node name="NewButton" type="Button" parent="VBoxContainer"]
margin_top = 135.0
margin_right = 316.0
margin_bottom = 47.0
margin_bottom = 176.0
theme = SubResource( 1 )
text = "Nouveau monde"
flat = true
[node name="LoadButton" type="Button" parent="VBoxContainer"]
margin_top = 51.0
margin_top = 180.0
margin_right = 316.0
margin_bottom = 98.0
margin_bottom = 221.0
text = "Charger un monde"
flat = true
[node name="QuitButton" type="Button" parent="VBoxContainer"]
margin_top = 102.0
margin_top = 225.0
margin_right = 316.0
margin_bottom = 149.0
margin_bottom = 266.0
text = "Quitter"
flat = true
[connection signal="pressed" from="VBoxContainer/NewButton" to="." method="_on_NewButton_pressed"]
[connection signal="pressed" from="VBoxContainer/LoadButton" to="." method="_on_LoadButton_pressed"]

@ -0,0 +1,14 @@
extends Control
func _ready():
pass
func _on_CancelButton_pressed():
get_tree().change_scene("res://menu/MainMenu.tscn")
func _on_CreateButton_pressed():
Global.terrain_name = $VBoxContainer/LineEdit.text
get_tree().change_scene("res://world/game.tscn")

@ -0,0 +1,64 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://theme/theme.tres" type="Theme" id=1]
[ext_resource path="res://theme/fonts/monogram.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://menu/NewWorld.gd" type="Script" id=3]
[sub_resource type="DynamicFont" id=1]
size = 35
font_data = ExtResource( 2 )
[node name="NewWorld" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( -383, -181 )
theme = ExtResource( 1 )
script = ExtResource( 3 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -195.0
margin_top = -85.0
margin_right = 195.0
margin_bottom = 85.0
[node name="Title" type="Label" parent="VBoxContainer"]
margin_right = 390.0
margin_bottom = 64.0
text = "Nouveau monde"
align = 1
[node name="Label" type="Label" parent="VBoxContainer"]
margin_top = 68.0
margin_right = 390.0
margin_bottom = 97.0
custom_fonts/font = SubResource( 1 )
text = "Nom du monde :"
[node name="LineEdit" type="LineEdit" parent="VBoxContainer"]
margin_top = 101.0
margin_right = 390.0
margin_bottom = 125.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 129.0
margin_right = 390.0
margin_bottom = 170.0
[node name="CreateButton" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_right = 247.0
margin_bottom = 41.0
text = "Nouveau monde"
[node name="CancelButton" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 251.0
margin_right = 390.0
margin_bottom = 41.0
size_flags_horizontal = 3
text = "Annuler"
[connection signal="pressed" from="VBoxContainer/HBoxContainer/CreateButton" to="." method="_on_CreateButton_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/CancelButton" to="." method="_on_CancelButton_pressed"]

@ -1,4 +1,6 @@
[gd_resource type="Theme" load_steps=3 format=2]
[gd_resource type="Theme" load_steps=21 format=2]
[ext_resource path="res://theme/fonts/monogram.ttf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFontData" id=1]
font_path = "res://theme/fonts/monogram.ttf"
@ -7,6 +9,74 @@ font_path = "res://theme/fonts/monogram.ttf"
size = 50
font_data = SubResource( 1 )
[sub_resource type="Gradient" id=12]
interpolation_mode = 1
colors = PoolColorArray( 0.596078, 0.596078, 0.596078, 1, 1, 1, 1, 1 )
[sub_resource type="GradientTexture" id=13]
gradient = SubResource( 12 )
[sub_resource type="GradientTexture" id=14]
[sub_resource type="StyleBoxTexture" id=15]
texture = SubResource( 14 )
normal_map = SubResource( 13 )
region_rect = Rect2( 0, 0, 2048, 1 )
[sub_resource type="Gradient" id=16]
interpolation_mode = 1
colors = PoolColorArray( 0.47451, 0.47451, 0.47451, 1, 1, 1, 1, 1 )
[sub_resource type="GradientTexture" id=17]
gradient = SubResource( 16 )
[sub_resource type="StyleBoxTexture" id=18]
texture = SubResource( 17 )
region_rect = Rect2( 0, 0, 2048, 1 )
[sub_resource type="Gradient" id=19]
interpolation_mode = 1
colors = PoolColorArray( 0.266667, 0.266667, 0.266667, 1, 1, 1, 1, 1 )
[sub_resource type="GradientTexture" id=20]
gradient = SubResource( 19 )
[sub_resource type="StyleBoxTexture" id=21]
texture = SubResource( 20 )
region_rect = Rect2( 0, 0, 2048, 1 )
[sub_resource type="Gradient" id=6]
interpolation_mode = 1
colors = PoolColorArray( 0.47451, 0.47451, 0.47451, 1, 1, 1, 1, 1 )
[sub_resource type="GradientTexture" id=7]
gradient = SubResource( 6 )
[sub_resource type="StyleBoxTexture" id=5]
texture = SubResource( 7 )
region_rect = Rect2( 0, 0, 2048, 1 )
[sub_resource type="Gradient" id=9]
interpolation_mode = 1
colors = PoolColorArray( 0.239216, 0.239216, 0.239216, 1, 1, 1, 1, 1 )
[sub_resource type="GradientTexture" id=10]
gradient = SubResource( 9 )
[sub_resource type="StyleBoxTexture" id=11]
texture = SubResource( 10 )
region_rect = Rect2( 0, 0, 2048, 1 )
[sub_resource type="DynamicFont" id=8]
size = 80
font_data = ExtResource( 1 )
[resource]
Button/colors/font_color_hover = Color( 0.819608, 0.211765, 0.211765, 1 )
Button/colors/font_color_hover = Color( 0.854902, 0.439216, 0.439216, 1 )
Button/fonts/font = SubResource( 2 )
Button/styles/disabled = SubResource( 15 )
Button/styles/focus = SubResource( 18 )
Button/styles/hover = SubResource( 21 )
Button/styles/normal = SubResource( 5 )
Button/styles/pressed = SubResource( 11 )
Label/fonts/font = SubResource( 8 )

@ -1,7 +1,8 @@
extends Node
var debug = true
var terrain
var terrain_name = ""
var terrain = Terrain.new()
# Debuging messages
func print_debug(message):

@ -23,18 +23,23 @@ func _ready():
noise.seed = rng.randi()
noise.octaves = octaves
var terrain_name="bonjour90"
terrain = Terrain.new()
# var Global.terrain_name="bonjour90"
terrain = Global.terrain
print(terrain.list())
if terrain.exists(terrain_name):
terrain.load(terrain_name)
if terrain.exists(Global.terrain_name):
terrain.load(Global.terrain_name)
else:
terrain.create(width,height,spacing,terrain_name)
terrain.create(width,height,spacing,Global.terrain_name)
if terrain.is_created() or terrain.is_loaded():
if terrain.is_created():
init_data()
terrain.save_data()
if terrain.is_created() or terrain.is_loaded():
add_trees()
emit_signal("world_loaded", terrain)
else:
@ -58,9 +63,7 @@ func init_data():
# point.set_data("coast", point_is_coast(point))
# if point.get_data("river"):
# set_river_path(point)
var triangles = 0
for triangle in terrain.get_triangles():
triangles += 1
triangle.set_elevation(find_elevation(triangle.center2d()))
# triangle.set_data("elevation", triangle_find_elevation(triangle))
triangle.set_data("water", triangle_is_water(triangle))
@ -76,7 +79,7 @@ func init_data():
# for edge in terrain.get_edges():
# edge.set_data("coast", edge_is_coast(edge))
# edge.set_data("river", edge_is_river(edge))
print(triangles)
func fill_oceans():
var stack = []
for point in terrain.get_points():

Loading…
Cancel
Save