implement infolayer drawing, support for other types too
This commit is contained in:
parent
7486750ca2
commit
01d896c7dc
5 changed files with 40 additions and 23 deletions
|
@ -119,6 +119,10 @@ layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
|
[node name="button_infolayer_parcels" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
|
offset_right = 8.0
|
||||||
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="DebugContainer" type="GridContainer" parent="EventBus/UILayer/Control"]
|
[node name="DebugContainer" type="GridContainer" parent="EventBus/UILayer/Control"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 1
|
anchors_preset = 1
|
||||||
|
@ -159,6 +163,7 @@ texture_repeat = 1
|
||||||
centered = false
|
centered = false
|
||||||
|
|
||||||
[connection signal="chunk_stats" from="EventBus/Game/ChunkHandler" to="EventBus/UILayer/Control" method="_on_chunk_handler_chunk_stats"]
|
[connection signal="chunk_stats" from="EventBus/Game/ChunkHandler" to="EventBus/UILayer/Control" method="_on_chunk_handler_chunk_stats"]
|
||||||
|
[connection signal="infolayer_button_pressed" from="EventBus/UILayer/Control" to="EventBus" method="_on_control_infolayer_button_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_residental" to="EventBus/UILayer/Control" method="_on_button_residental_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_residental" to="EventBus/UILayer/Control" method="_on_button_residental_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_commercial" to="EventBus/UILayer/Control" method="_on_button_commercial_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_commercial" to="EventBus/UILayer/Control" method="_on_button_commercial_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_industrial" to="EventBus/UILayer/Control" method="_on_button_industrial_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_industrial" to="EventBus/UILayer/Control" method="_on_button_industrial_pressed"]
|
||||||
|
@ -166,6 +171,7 @@ centered = false
|
||||||
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_demolish" to="EventBus/UILayer/Control" method="_on_button_demolish_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_demolish" to="EventBus/UILayer/Control" method="_on_button_demolish_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_services" to="EventBus/UILayer/Control" method="_on_button_services_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_services" to="EventBus/UILayer/Control" method="_on_button_services_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_social" to="EventBus/UILayer/Control" method="_on_button_social_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_social" to="EventBus/UILayer/Control" method="_on_button_social_pressed"]
|
||||||
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_infolayer_parcels" to="EventBus/UILayer/Control" method="_on_button_infolayer_parcels_pressed"]
|
||||||
[connection signal="mouse_entered" from="EventBus/UILayer/Control/Minimap" to="EventBus/UILayer/Control/Minimap" method="_on_mouse_entered"]
|
[connection signal="mouse_entered" from="EventBus/UILayer/Control/Minimap" to="EventBus/UILayer/Control/Minimap" method="_on_mouse_entered"]
|
||||||
[connection signal="mouse_exited" from="EventBus/UILayer/Control/Minimap" to="EventBus/UILayer/Control/Minimap" method="_on_mouse_exited"]
|
[connection signal="mouse_exited" from="EventBus/UILayer/Control/Minimap" to="EventBus/UILayer/Control/Minimap" method="_on_mouse_exited"]
|
||||||
[connection signal="set_camera_position" from="EventBus/UILayer/Control/Minimap" to="EventBus" method="set_camera_position"]
|
[connection signal="set_camera_position" from="EventBus/UILayer/Control/Minimap" to="EventBus" method="set_camera_position"]
|
||||||
|
|
|
@ -5,6 +5,7 @@ extends Node
|
||||||
@onready var node_mainmenu:MainMenu
|
@onready var node_mainmenu:MainMenu
|
||||||
@onready var node_game:Game
|
@onready var node_game:Game
|
||||||
@onready var node_camera:Camera
|
@onready var node_camera:Camera
|
||||||
|
@onready var node_infolayer:InfoLayer
|
||||||
@onready var node_uilayer:UILayer
|
@onready var node_uilayer:UILayer
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ func _ready():
|
||||||
node_mainmenu = find_child("MainMenu")
|
node_mainmenu = find_child("MainMenu")
|
||||||
node_game = find_child("Game")
|
node_game = find_child("Game")
|
||||||
node_camera = find_child("Camera")
|
node_camera = find_child("Camera")
|
||||||
|
node_infolayer = find_child("InfoLayer")
|
||||||
node_uilayer = find_child("UILayer")
|
node_uilayer = find_child("UILayer")
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,6 +96,17 @@ func _unhandled_input(event) -> void:
|
||||||
node_camera.clamp_camera_position()
|
node_camera.clamp_camera_position()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_control_infolayer_button_pressed(button_type):
|
||||||
|
var current_layer:int = node_infolayer.get_draw_mode()
|
||||||
|
|
||||||
|
if current_layer == button_type:
|
||||||
|
node_infolayer.set_draw_mode(Globals.INFLAYER_LAYERS_HIDDEN)
|
||||||
|
node_infolayer.set_visible(false)
|
||||||
|
else:
|
||||||
|
node_infolayer.set_draw_mode(button_type)
|
||||||
|
node_infolayer.set_visible(true)
|
||||||
|
|
||||||
|
|
||||||
func _on_mainmenu_button_pressed(button:int):
|
func _on_mainmenu_button_pressed(button:int):
|
||||||
match button:
|
match button:
|
||||||
Globals.MAINMENU_NEW_GAME:
|
Globals.MAINMENU_NEW_GAME:
|
||||||
|
@ -153,11 +166,6 @@ func start_new_game():
|
||||||
node_game.set_visible(true)
|
node_game.set_visible(true)
|
||||||
node_uilayer.set_visible(true)
|
node_uilayer.set_visible(true)
|
||||||
|
|
||||||
var node_infolayer:InfoLayer
|
|
||||||
node_infolayer = find_child("InfoLayer")
|
|
||||||
node_infolayer.set_draw_mode(0)
|
|
||||||
node_infolayer.set_visible(true)
|
|
||||||
|
|
||||||
# set camera to center of the map
|
# set camera to center of the map
|
||||||
node_camera.camera_reset_rotation()
|
node_camera.camera_reset_rotation()
|
||||||
node_camera.set_camera_position(
|
node_camera.set_camera_position(
|
||||||
|
@ -165,8 +173,5 @@ func start_new_game():
|
||||||
Globals.map_size / 2.0 * Globals.TILE_SIZE_Y)
|
Globals.map_size / 2.0 * Globals.TILE_SIZE_Y)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ enum {
|
||||||
INFOLAYER_DISTRICTS,
|
INFOLAYER_DISTRICTS,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const INFLAYER_LAYERS_HIDDEN:int = -1
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# UI ELEMENT SETTINGS #
|
# UI ELEMENT SETTINGS #
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
class_name InfoLayer
|
class_name InfoLayer
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
var draw_mode:int = -1
|
var draw_mode:int
|
||||||
|
|
||||||
# displays various info layers of the game
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
#no layer disible by default
|
||||||
|
draw_mode = Globals.INFLAYER_LAYERS_HIDDEN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _draw():
|
func _draw():
|
||||||
|
@ -31,6 +27,8 @@ func _draw():
|
||||||
Globals.INFOLAYER_WATER:pass
|
Globals.INFOLAYER_WATER:pass
|
||||||
Globals.INFOLAYER_SNOW:pass
|
Globals.INFOLAYER_SNOW:pass
|
||||||
Globals.INFOLAYER_DISTRICTS:pass
|
Globals.INFOLAYER_DISTRICTS:pass
|
||||||
|
_: #default
|
||||||
|
push_error("InfoLayer: invalid draw mode '%s' specified!" % draw_mode)
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
@ -67,6 +65,7 @@ func get_draw_mode() -> int:
|
||||||
|
|
||||||
|
|
||||||
func set_draw_mode(mode:int) -> void:
|
func set_draw_mode(mode:int) -> void:
|
||||||
|
# change draw mode and redraw if it is not used
|
||||||
self.draw_mode = mode
|
self.draw_mode = mode
|
||||||
if self.draw_mode >= 0:
|
if self.draw_mode >= 0:
|
||||||
queue_redraw()
|
queue_redraw()
|
||||||
|
|
|
@ -2,7 +2,8 @@ extends Control
|
||||||
|
|
||||||
# var view = get_node("../View")
|
# var view = get_node("../View")
|
||||||
|
|
||||||
signal button_pressed(button_name)
|
signal construction_button_pressed(button_name, button_type)
|
||||||
|
signal infolayer_button_pressed(button_type)
|
||||||
@onready var debug_info = get_node("DebugContainer/" + Globals.DEBUGINFO_NODE)
|
@onready var debug_info = get_node("DebugContainer/" + Globals.DEBUGINFO_NODE)
|
||||||
@onready var minimap:Minimap
|
@onready var minimap:Minimap
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ var buttons = {
|
||||||
"button_demolish": [Vector2(50,50), "Dm"],
|
"button_demolish": [Vector2(50,50), "Dm"],
|
||||||
"button_services": [Vector2(100,50), "Sv"],
|
"button_services": [Vector2(100,50), "Sv"],
|
||||||
"button_social": [Vector2(150,50), "So"],
|
"button_social": [Vector2(150,50), "So"],
|
||||||
|
"button_infolayer_parcels": [Vector2(200,50), "Prc"],
|
||||||
}
|
}
|
||||||
|
|
||||||
func _on_chunk_handler_chunk_stats(chunks, removal_queue):
|
func _on_chunk_handler_chunk_stats(chunks, removal_queue):
|
||||||
|
@ -40,31 +42,35 @@ func _process(_delta):
|
||||||
|
|
||||||
# sends signals which View catches and places selected type of buildings
|
# sends signals which View catches and places selected type of buildings
|
||||||
func _on_button_residental_pressed():
|
func _on_button_residental_pressed():
|
||||||
emit_signal("button_pressed", Globals.TYPE_RESIDENTIAL)
|
emit_signal("construction_button_pressed", Globals.TYPE_RESIDENTIAL, 0)
|
||||||
|
|
||||||
|
|
||||||
func _on_button_commercial_pressed():
|
func _on_button_commercial_pressed():
|
||||||
emit_signal("button_pressed", Globals.TYPE_COMMERCIAL)
|
emit_signal("construction_button_pressed", Globals.TYPE_COMMERCIAL, 0)
|
||||||
|
|
||||||
|
|
||||||
func _on_button_industrial_pressed():
|
func _on_button_industrial_pressed():
|
||||||
emit_signal("button_pressed", Globals.TYPE_INDUSTRIAL)
|
emit_signal("construction_button_pressed", Globals.TYPE_INDUSTRIAL, 0)
|
||||||
|
|
||||||
|
|
||||||
func _on_button_roads_pressed():
|
func _on_button_roads_pressed():
|
||||||
emit_signal("button_pressed", Globals.TYPE_ROADS)
|
emit_signal("construction_button_pressed", Globals.TYPE_ROADS, 0)
|
||||||
|
|
||||||
|
|
||||||
func _on_button_demolish_pressed():
|
func _on_button_demolish_pressed():
|
||||||
emit_signal("button_pressed", Globals.TYPE_DEMOLISH)
|
emit_signal("construction_button_pressed", Globals.TYPE_DEMOLISH, 0)
|
||||||
|
|
||||||
|
|
||||||
func _on_button_services_pressed():
|
func _on_button_services_pressed():
|
||||||
emit_signal("button_pressed", Globals.TYPE_SERVICES)
|
emit_signal("construction_button_pressed", Globals.TYPE_SERVICES, 0)
|
||||||
|
|
||||||
|
|
||||||
func _on_button_social_pressed():
|
func _on_button_social_pressed():
|
||||||
emit_signal("button_pressed", Globals.TYPE_SOCIAL)
|
emit_signal("construction_button_pressed", Globals.TYPE_SOCIAL, 0)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_button_infolayer_parcels_pressed():
|
||||||
|
emit_signal("infolayer_button_pressed", Globals.INFOLAYER_PARCELS)
|
||||||
|
|
||||||
|
|
||||||
func _on_main_worldgen_ready():
|
func _on_main_worldgen_ready():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue