Add window panning
This commit is contained in:
parent
355e699601
commit
aa07378fc6
13 changed files with 132 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
# Godot 4+ specific ignores
|
# Godot 4+ specific ignores
|
||||||
.godot/
|
.godot/
|
||||||
/android/
|
/android/
|
||||||
|
builds/
|
|
@ -9,7 +9,7 @@
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4cq27"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4cq27"]
|
||||||
size = Vector2(4, 4)
|
size = Vector2(4, 4)
|
||||||
|
|
||||||
[node name="Cursor" type="CanvasLayer"]
|
[node name="Cursor" type="CanvasLayer" groups=["Cursor"]]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
script = ExtResource("1_nmkwm")
|
script = ExtResource("1_nmkwm")
|
||||||
|
|
||||||
|
|
64
export_presets.cfg
Normal file
64
export_presets.cfg
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
[preset.0]
|
||||||
|
|
||||||
|
name="Windows Desktop"
|
||||||
|
platform="Windows Desktop"
|
||||||
|
runnable=true
|
||||||
|
advanced_options=false
|
||||||
|
dedicated_server=false
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter="*.txt"
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="builds/window-creatures.exe"
|
||||||
|
encryption_include_filters=""
|
||||||
|
encryption_exclude_filters=""
|
||||||
|
encrypt_pck=false
|
||||||
|
encrypt_directory=false
|
||||||
|
script_export_mode=2
|
||||||
|
|
||||||
|
[preset.0.options]
|
||||||
|
|
||||||
|
custom_template/debug=""
|
||||||
|
custom_template/release=""
|
||||||
|
debug/export_console_wrapper=1
|
||||||
|
binary_format/embed_pck=true
|
||||||
|
texture_format/s3tc_bptc=true
|
||||||
|
texture_format/etc2_astc=false
|
||||||
|
binary_format/architecture="x86_64"
|
||||||
|
codesign/enable=false
|
||||||
|
codesign/timestamp=true
|
||||||
|
codesign/timestamp_server_url=""
|
||||||
|
codesign/digest_algorithm=1
|
||||||
|
codesign/description=""
|
||||||
|
codesign/custom_options=PackedStringArray()
|
||||||
|
application/modify_resources=true
|
||||||
|
application/icon=""
|
||||||
|
application/console_wrapper_icon=""
|
||||||
|
application/icon_interpolation=4
|
||||||
|
application/file_version=""
|
||||||
|
application/product_version=""
|
||||||
|
application/company_name=""
|
||||||
|
application/product_name=""
|
||||||
|
application/file_description=""
|
||||||
|
application/copyright=""
|
||||||
|
application/trademarks=""
|
||||||
|
application/export_angle=0
|
||||||
|
application/export_d3d12=0
|
||||||
|
application/d3d12_agility_sdk_multiarch=true
|
||||||
|
ssh_remote_deploy/enabled=false
|
||||||
|
ssh_remote_deploy/host="user@host_ip"
|
||||||
|
ssh_remote_deploy/port="22"
|
||||||
|
ssh_remote_deploy/extra_args_ssh=""
|
||||||
|
ssh_remote_deploy/extra_args_scp=""
|
||||||
|
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
|
||||||
|
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
|
||||||
|
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
|
||||||
|
$settings = New-ScheduledTaskSettingsSet
|
||||||
|
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
|
||||||
|
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
|
||||||
|
Start-ScheduledTask -TaskName godot_remote_debug
|
||||||
|
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
|
||||||
|
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
|
||||||
|
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
|
||||||
|
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
|
||||||
|
Remove-Item -Recurse -Force '{temp_dir}'"
|
2
main.gd
2
main.gd
|
@ -29,6 +29,8 @@ func _ready() -> void:
|
||||||
get_viewport().transparent_bg = true
|
get_viewport().transparent_bg = true
|
||||||
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_MOUSE_PASSTHROUGH, true)
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_MOUSE_PASSTHROUGH, true)
|
||||||
|
|
||||||
|
upgrade_pool.shuffle()
|
||||||
|
zone_pool.shuffle()
|
||||||
var new_buttons = UI_BUTTONS.instantiate()
|
var new_buttons = UI_BUTTONS.instantiate()
|
||||||
var new_cursor = CURSOR.instantiate()
|
var new_cursor = CURSOR.instantiate()
|
||||||
new_buttons.add_child(new_cursor)
|
new_buttons.add_child(new_cursor)
|
||||||
|
|
|
@ -3,4 +3,4 @@ description: 10% higher chance for a creature to drop coins ev
|
||||||
property: creature_resource_spawn_rate
|
property: creature_resource_spawn_rate
|
||||||
type: percent
|
type: percent
|
||||||
amount: 10
|
amount: 10
|
||||||
cost: 5
|
cost: 3
|
||||||
|
|
|
@ -2,4 +2,4 @@ name: Creature Bait
|
||||||
description: 2 More creatures will wander onto your property every day
|
description: 2 More creatures will wander onto your property every day
|
||||||
property: creature_amount
|
property: creature_amount
|
||||||
amount: 2
|
amount: 2
|
||||||
cost: 7
|
cost: 3
|
||||||
|
|
|
@ -201,6 +201,7 @@ volume_db = -10.0
|
||||||
stream = ExtResource("9_fxutd")
|
stream = ExtResource("9_fxutd")
|
||||||
volume_db = 5.0
|
volume_db = 5.0
|
||||||
|
|
||||||
|
[connection signal="close_requested" from="." to="Control" method="_on_build_window_close_requested"]
|
||||||
[connection signal="clicked" from="Control/Upgrade/MouseHandler" to="Control" method="_on_mouse_handler_clicked"]
|
[connection signal="clicked" from="Control/Upgrade/MouseHandler" to="Control" method="_on_mouse_handler_clicked"]
|
||||||
[connection signal="hovered" from="Control/Upgrade/MouseHandler" to="Control" method="_on_mouse_handler_hovered"]
|
[connection signal="hovered" from="Control/Upgrade/MouseHandler" to="Control" method="_on_mouse_handler_hovered"]
|
||||||
[connection signal="unhovered" from="Control/Upgrade/MouseHandler" to="Control" method="_on_mouse_handler_unhovered"]
|
[connection signal="unhovered" from="Control/Upgrade/MouseHandler" to="Control" method="_on_mouse_handler_unhovered"]
|
||||||
|
|
|
@ -31,29 +31,5 @@ wait_time = 6.0
|
||||||
one_shot = true
|
one_shot = true
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
[node name="Timer3" type="Timer" parent="."]
|
|
||||||
wait_time = 12.0
|
|
||||||
one_shot = true
|
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[node name="Timer4" type="Timer" parent="."]
|
|
||||||
wait_time = 20.0
|
|
||||||
one_shot = true
|
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[node name="Timer5" type="Timer" parent="."]
|
|
||||||
wait_time = 30.0
|
|
||||||
one_shot = true
|
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[node name="Timer6" type="Timer" parent="."]
|
|
||||||
wait_time = 50.0
|
|
||||||
one_shot = true
|
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="Node2D" method="_on_timer_timeout"]
|
[connection signal="timeout" from="Timer" to="Node2D" method="_on_timer_timeout"]
|
||||||
[connection signal="timeout" from="Timer2" to="Node2D" method="_on_timer_timeout"]
|
[connection signal="timeout" from="Timer2" to="Node2D" method="_on_timer_timeout"]
|
||||||
[connection signal="timeout" from="Timer3" to="Node2D" method="_on_timer_timeout"]
|
|
||||||
[connection signal="timeout" from="Timer4" to="Node2D" method="_on_timer_timeout"]
|
|
||||||
[connection signal="timeout" from="Timer5" to="Node2D" method="_on_timer_timeout"]
|
|
||||||
[connection signal="timeout" from="Timer6" to="Node2D" method="_on_timer_timeout"]
|
|
||||||
|
|
|
@ -56,14 +56,15 @@ var buying = [
|
||||||
]
|
]
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
main.upgrade_pool.shuffle()
|
|
||||||
main.zone_pool.shuffle()
|
|
||||||
|
|
||||||
var screen_size = DisplayServer.screen_get_size(0)
|
var screen_size = DisplayServer.screen_get_size(0)
|
||||||
|
|
||||||
get_window().position = DisplayServer.screen_get_position(0) + screen_size / 2 - Vector2i(450, 250)
|
get_window().position = DisplayServer.screen_get_position(0) + screen_size / 2 - Vector2i(450, 250)
|
||||||
_refresh_cards()
|
_refresh_cards()
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if get_window().mode == Window.MODE_MINIMIZED:
|
||||||
|
get_window().mode = Window.MODE_WINDOWED
|
||||||
|
|
||||||
|
|
||||||
func _refresh_cards():
|
func _refresh_cards():
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
|
@ -89,11 +90,15 @@ func _update_card(index):
|
||||||
main.upgrade_pool.shuffle()
|
main.upgrade_pool.shuffle()
|
||||||
choice = main.upgrade_pool.pop_back()
|
choice = main.upgrade_pool.pop_back()
|
||||||
card_data = Data.data.upgrades[choice]
|
card_data = Data.data.upgrades[choice]
|
||||||
cost = card_data.cost + (round(card_data.cost / 2) * Persister.get_value(choice, PersisterEnums.Scope.UNKNOWN, 0))
|
|
||||||
|
cost = card_data.cost
|
||||||
|
for i in range(0, Persister.get_value(choice, PersisterEnums.Scope.UNKNOWN, 0)):
|
||||||
|
cost += round(cost / 2)
|
||||||
|
|
||||||
cards[index].title.text = "[center]%s" % [card_data.name]
|
cards[index].title.text = "[center]%s" % [card_data.name]
|
||||||
cards[index].cost.text = "[center]%d G" % [cost]
|
cards[index].cost.text = "[center]%d G" % [cost]
|
||||||
card_data.key = choice
|
card_data.key = choice
|
||||||
|
card_data.actual_cost = cost
|
||||||
chosen_cards[index] = card_data
|
chosen_cards[index] = card_data
|
||||||
|
|
||||||
if (index == 1 and chosen_cards[0].key == choice) or (index == 0 and chosen_cards[1] and chosen_cards[1].key == choice):
|
if (index == 1 and chosen_cards[0].key == choice) or (index == 0 and chosen_cards[1] and chosen_cards[1].key == choice):
|
||||||
|
@ -133,8 +138,8 @@ func _buy_upgrade(index):
|
||||||
return
|
return
|
||||||
|
|
||||||
var card_data = chosen_cards[index]
|
var card_data = chosen_cards[index]
|
||||||
if Persister.get_value("gold", PersisterEnums.Scope.UNKNOWN, 0) >= (card_data.cost if card_data.has("cost") else 10 + (5 * Persister.get_value("zones_bought", PersisterEnums.Scope.UNKNOWN, 0))):
|
if Persister.get_value("gold", PersisterEnums.Scope.UNKNOWN, 0) >= (card_data.actual_cost if card_data.has("actual_cost") else 10 + (5 * Persister.get_value("zones_bought", PersisterEnums.Scope.UNKNOWN, 0))):
|
||||||
Persister.change_value("gold", -(card_data.cost if card_data.has("cost") else 10 + (5 * Persister.get_value("zones_bought", PersisterEnums.Scope.UNKNOWN, 0))))
|
Persister.change_value("gold", -(card_data.actual_cost if card_data.has("actual_cost") else 10 + (5 * Persister.get_value("zones_bought", PersisterEnums.Scope.UNKNOWN, 0))))
|
||||||
|
|
||||||
buying[index] = true
|
buying[index] = true
|
||||||
|
|
||||||
|
@ -195,3 +200,8 @@ func _on_mouse_handler_unhovered() -> void:
|
||||||
tweens[index].set_parallel()
|
tweens[index].set_parallel()
|
||||||
tweens[index].tween_property(cards[index].title, "modulate", Color.WHITE, 0.25)
|
tweens[index].tween_property(cards[index].title, "modulate", Color.WHITE, 0.25)
|
||||||
tweens[index].tween_property(cards[index].object, "position:y", 42.5, 0.25)
|
tweens[index].tween_property(cards[index].object, "position:y", 42.5, 0.25)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_build_window_close_requested() -> void:
|
||||||
|
get_window().queue_free()
|
||||||
|
Triggerer.trigger("window_close_icon")
|
||||||
|
|
|
@ -9,7 +9,7 @@ const CREATURE = preload("res://src/Creature.tscn")
|
||||||
var mouse_in_window = false
|
var mouse_in_window = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Persister.change_value("creature_amount", 4)
|
Persister.change_value("creature_amount", 8)
|
||||||
Triggerer.listen("minutes", _on_minutes)
|
Triggerer.listen("minutes", _on_minutes)
|
||||||
Triggerer.listen("day", _on_day)
|
Triggerer.listen("day", _on_day)
|
||||||
_generate_spawn_times()
|
_generate_spawn_times()
|
||||||
|
@ -18,7 +18,9 @@ func _ready() -> void:
|
||||||
|
|
||||||
get_window().position = Vector2i(50, screen_size.y - 300 - 50) + DisplayServer.screen_get_position(0)
|
get_window().position = Vector2i(50, screen_size.y - 300 - 50) + DisplayServer.screen_get_position(0)
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if get_window().mode == Window.MODE_MINIMIZED:
|
||||||
|
get_window().mode = Window.MODE_WINDOWED
|
||||||
|
|
||||||
func _on_minutes(_data):
|
func _on_minutes(_data):
|
||||||
minutes_left -= 1
|
minutes_left -= 1
|
||||||
|
@ -50,7 +52,7 @@ func _on_day(_data):
|
||||||
func _generate_spawn_times():
|
func _generate_spawn_times():
|
||||||
spawn_times = []
|
spawn_times = []
|
||||||
|
|
||||||
for i in range(0, 4):
|
for i in range(0, Persister.get_value("creature_amount")):
|
||||||
spawn_times.push_back(randi_range(2, 6 * 24 - 2))
|
spawn_times.push_back(randi_range(2, 6 * 24 - 2))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,17 @@ var mouse_in_window
|
||||||
#print("EXITED")
|
#print("EXITED")
|
||||||
#mouse_in_window = false
|
#mouse_in_window = false
|
||||||
|
|
||||||
|
var last_mouse = Vector2.ZERO
|
||||||
|
var cursor
|
||||||
|
var diff = Vector2.ZERO
|
||||||
|
var following = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Triggerer.listen("released", _on_released)
|
Triggerer.listen("released", _on_released)
|
||||||
|
var children = get_parent().get_children()
|
||||||
|
for child in children:
|
||||||
|
if child.is_in_group("Cursor"):
|
||||||
|
cursor = child
|
||||||
|
|
||||||
|
|
||||||
func _on_released(_data):
|
func _on_released(_data):
|
||||||
|
@ -22,6 +30,27 @@ func _on_released(_data):
|
||||||
get_window().grab_focus()
|
get_window().grab_focus()
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if Input.is_action_just_pressed("right_click") and mouse_in_window:
|
||||||
|
following = true
|
||||||
|
|
||||||
|
if Input.is_action_just_released("right_click"):
|
||||||
|
following = false
|
||||||
|
|
||||||
|
var mouse = get_tree().root.get_mouse_position()
|
||||||
|
if following:
|
||||||
|
diff += (mouse - last_mouse) * 4
|
||||||
|
|
||||||
|
var x = floor(diff.x)
|
||||||
|
var y = floor(diff.y)
|
||||||
|
|
||||||
|
get_parent().position += Vector2i(x, y)
|
||||||
|
|
||||||
|
diff -= Vector2(x, y)
|
||||||
|
|
||||||
|
last_mouse = mouse
|
||||||
|
|
||||||
|
|
||||||
func _notification(blah):
|
func _notification(blah):
|
||||||
match blah:
|
match blah:
|
||||||
NOTIFICATION_WM_MOUSE_EXIT:
|
NOTIFICATION_WM_MOUSE_EXIT:
|
||||||
|
|
|
@ -13,6 +13,13 @@ var size_tween
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
sprite_2d.texture = image
|
sprite_2d.texture = image
|
||||||
|
|
||||||
|
Triggerer.listen("window_close_icon", _on_window_close_icon)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_window_close_icon(_data):
|
||||||
|
if key == "upgrade_menu":
|
||||||
|
sprite_2d.texture = image
|
||||||
|
|
||||||
func _on_mouse_handler_clicked() -> void:
|
func _on_mouse_handler_clicked() -> void:
|
||||||
if value == "toggle":
|
if value == "toggle":
|
||||||
|
|
|
@ -12,6 +12,10 @@ const CREATURE = preload("res://src/Creature.tscn")
|
||||||
var tiles = []
|
var tiles = []
|
||||||
var newt = []
|
var newt = []
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if mode == Window.MODE_MINIMIZED:
|
||||||
|
mode = Window.MODE_WINDOWED
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var window_size = get_tree().root.get_window().size
|
var window_size = get_tree().root.get_window().size
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue