-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui_manager.gd
61 lines (50 loc) · 3.19 KB
/
ui_manager.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
extends CanvasLayer
@export var mode_textures: Array[Texture2D] = []
@export var world: World
@export var clouds: Clouds
@export var options: Control
@export var mode_texture: TextureRect
var ui_open = true
func _ready():
setup_options()
mode_texture.texture = mode_textures[World.Mode.Move]
func setup_options():
# Set in-game options to match editor options
options.find_child("Hexagon Count").find_child("Value").value = world.hexagon_count
options.find_child("River Count").find_child("Min").value = world.min_rivers
options.find_child("River Count").find_child("Max").value = world.max_rivers
options.find_child("Lake Count").find_child("Min").value = world.min_lakes
options.find_child("Lake Count").find_child("Max").value = world.max_lakes
options.find_child("Village Count").find_child("Min").value = world.min_villages
options.find_child("Village Count").find_child("Max").value = world.max_villages
options.find_child("Generate Fields").find_child("Value").button_pressed = world.generate_fields
options.find_child("Generate Docks").find_child("Value").button_pressed = world.generate_docks
options.find_child("Biome Scale").find_child("Value").value = world.noise_scale
options.find_child("Generate Clouds").find_child("Value").button_pressed = clouds.generate_clouds
options.find_child("Cloud Speed").find_child("Value").value = clouds.cloud_speed
options.find_child("Cloud Wait Time").find_child("Min").value = clouds.min_spawn_wait * 10
options.find_child("Cloud Wait Time").find_child("Max").value = clouds.max_spawn_wait * 10
func regenerate():
# Set editor options to match in-game options
world.hexagon_count = options.find_child("Hexagon Count").find_child("Value").value
world.min_rivers = options.find_child("River Count").find_child("Min").value
world.max_rivers = options.find_child("River Count").find_child("Max").value
world.min_lakes = options.find_child("Lake Count").find_child("Min").value
world.max_lakes = options.find_child("Lake Count").find_child("Max").value
world.min_villages = options.find_child("Village Count").find_child("Min").value
world.max_villages = options.find_child("Village Count").find_child("Max").value
world.generate_fields = options.find_child("Generate Fields").find_child("Value").button_pressed
world.generate_docks = options.find_child("Generate Docks").find_child("Value").button_pressed
world.noise_scale = options.find_child("Biome Scale").find_child("Value").value
clouds.generate_clouds = options.find_child("Generate Clouds").find_child("Value").button_pressed
clouds.cloud_speed = options.find_child("Cloud Speed").find_child("Value").value
clouds.min_spawn_wait = options.find_child("Cloud Wait Time").find_child("Min").value / 10
clouds.max_spawn_wait = options.find_child("Cloud Wait Time").find_child("Max").value / 10
# Regenerate world
world.generate_map()
func toggle_cloud_settings_editability(clouds_enabled: bool):
options.find_child("Cloud Speed").find_child("Value").editable = clouds_enabled
options.find_child("Cloud Wait Time").find_child("Min").editable = clouds_enabled
options.find_child("Cloud Wait Time").find_child("Max").editable = clouds_enabled
func change_mode(mode: World.Mode):
mode_texture.texture = mode_textures[mode]