Skip to content

Commit

Permalink
Adds setting to performance setting to allow you to only see the enab…
Browse files Browse the repository at this point in the history
…led boxes
  • Loading branch information
Lukasdotcom committed Feb 24, 2022
1 parent 669ecd9 commit b162b72
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 17 deletions.
14 changes: 10 additions & 4 deletions src/Data.gd
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ func start() -> void: # Loads starting loader
if _data["version"] == "v0.6.0":
_data["performance"] = {"Simulate" : 75, "Show" : 100, "Ball" : 9.5}
_data["version"] = "v0.6.1"
if _data["version"] == "v0.6.1": # Loads the save
if _data["version"] == "v0.6.1":
_data["performance"]["CheckButton"] = false
_data["version"] = "v0.6.2"
if _data["version"] == "v0.6.2": # Loads the save
goldenLength = _data["goldenLength"]
goldenMagnitude = _data["goldenMagnitude"]
goldenChance = _data["goldenChance"]
Expand All @@ -88,7 +91,10 @@ func start() -> void: # Loads starting loader
get_node("/root/Main/Game Field").call_deferred("add_child", _instance)
# Loads performance settings
for x in _data["performance"]:
get_node("/root/Main/TabContainer/Performance/" + x).value = _data["performance"][x]
if x == "CheckButton":
get_node("/root/Main/TabContainer/Performance/" + x).pressed = _data["performance"][x]
else:
get_node("/root/Main/TabContainer/Performance/" + x).value = _data["performance"][x]
else: # Runs info for when no save is found
goldenLength = 1
goldenMagnitude = 1
Expand Down Expand Up @@ -143,8 +149,8 @@ func save() -> void: # Used to save the game
"goldenChance" : goldenChance,
"goldenLength" : goldenLength,
"goldenMagnitude" : goldenMagnitude,
"performance" : {"Simulate" : get_node("/root/Main/TabContainer/Performance/Simulate").value, "Show" : get_node("/root/Main/TabContainer/Performance/Show").value, "Ball" : get_node("/root/Main/TabContainer/Performance/Ball").value},
"version" : "v0.6.1"
"performance" : {"Simulate" : get_node("/root/Main/TabContainer/Performance/Simulate").value, "Show" : get_node("/root/Main/TabContainer/Performance/Show").value, "Ball" : get_node("/root/Main/TabContainer/Performance/Ball").value, "CheckButton" : get_node("/root/Main/TabContainer/Performance/CheckButton").pressed},
"version" : "v0.6.2"
})
file.store_string(_save_data)
file.close()
Expand Down
5 changes: 4 additions & 1 deletion src/Game Field.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ var visibly = 0.0
var enabled = 0.0
var total = 0.0 setget changed
var disabledTotal = 0.0
var onlySimulate = false
signal update


func changed(value):
total = value
emit_signal("update")

func _on_Timer_timeout() -> void:
func _on_change() -> void:
simulate = get_node("/root/Main/TabContainer/Performance/Simulate").value / 100.0
onlySimulate = get_node("/root/Main/TabContainer/Performance/CheckButton").pressed
get_node("/root/Main/TabContainer/Performance/Show").editable = not onlySimulate
show = get_node("/root/Main/TabContainer/Performance/Show").value / 100.0
emit_signal("update")
2 changes: 1 addition & 1 deletion src/Loading.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func _ready() -> void:
file.open(Data.save_file, File.READ)
if validate_json(file.get_as_text()) == "":
var _data = parse_json(file.get_as_text())
if _data["version"] in ["v0.5.0", "v0.5.1", "v0.5.2", "v0.6.0", "v0.6.1"]:
if _data["version"] in ["v0.5.0", "v0.5.1", "v0.5.2", "v0.6.0", "v0.6.1", "v0.6.2"]:
$Save.visible = true
$Timer.start()
else:
Expand Down
2 changes: 2 additions & 0 deletions src/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ onready var _tab: TabContainer = $TabContainer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Data.start()
_tab.current_tab = 1
update_interface()
Data.connect("update_game_interface", self, "update_interface")
Data.connect("ball_upgrades", self, "ball_upgrades")
Expand Down Expand Up @@ -59,3 +60,4 @@ func _process(delta: float) -> void: # Checks if a button is pressed to change m
func _on_Export_button_up() -> void:
Data.save()
get_tree().change_scene("res://src/Export.tscn")

34 changes: 27 additions & 7 deletions src/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ margin_top = 65.0
margin_right = 468.0
margin_bottom = 600.0
theme = ExtResource( 5 )
drag_to_rearrange_enabled = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Performance" type="Control" parent="TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
Expand Down Expand Up @@ -124,11 +124,29 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="Label5" type="Label" parent="TabContainer/Performance"]
margin_top = 119.0
margin_right = 40.0
margin_bottom = 150.0
text = "Only show simulated boxes"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="CheckButton" type="CheckButton" parent="TabContainer/Performance"]
margin_left = 383.0
margin_top = 118.0
margin_right = 459.0
margin_bottom = 158.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Ball" type="HSlider" parent="TabContainer/Performance"]
margin_left = 259.0
margin_top = 127.0
margin_top = 161.0
margin_right = 459.0
margin_bottom = 147.0
margin_bottom = 181.0
max_value = 17.0
step = 0.5
value = 9.5
Expand All @@ -137,15 +155,16 @@ __meta__ = {
}

[node name="Label4" type="Label" parent="TabContainer/Performance"]
margin_top = 119.0
margin_right = 40.0
margin_bottom = 150.0
margin_top = 153.0
margin_right = 103.0
margin_bottom = 184.0
text = "Ball Limit"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Boxes" type="Control" parent="TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
Expand Down Expand Up @@ -291,10 +310,11 @@ wait_time = 0.25
autostart = true
script = ExtResource( 4 )

[connection signal="button_up" from="TabContainer/Performance/CheckButton" to="Game Field" method="_on_change"]
[connection signal="button_up" from="TabContainer/Boxes/Box Number/Buy" to="TabContainer/Boxes/Box Number" method="_on_Buy_button_up"]
[connection signal="mouse_entered" from="TabContainer/Boxes/Box Number/Buy" to="TabContainer/Boxes/Box Number" method="_on_Buy_mouse_entered"]
[connection signal="mouse_exited" from="TabContainer/Boxes/Box Number/Buy" to="TabContainer/Boxes/Box Number" method="_on_Buy_mouse_exited"]
[connection signal="timeout" from="Game Field/Timer" to="Game Field" method="_on_Timer_timeout"]
[connection signal="timeout" from="Game Field/Timer" to="Game Field" method="_on_change"]
[connection signal="button_up" from="Save Button" to="." method="_on_Save_Button_button_up"]
[connection signal="button_up" from="Export" to="." method="_on_Export_button_up"]
[connection signal="button_up" from="Reset" to="." method="_on_Reset_button_up"]
Expand Down
16 changes: 12 additions & 4 deletions src/box.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func delete() -> void: # Used to delete the box
self.queue_free()

func update() -> void: # Does all the neccessaary hiding and disabling of physics.
if disabled:
if disabled: # Sets physics
if game.enabled / game.total < game.simulate or game.simulate == 1:
game.enabled += 1
game.disabledTotal -= Data.earnings[level]
Expand All @@ -74,13 +74,21 @@ func update() -> void: # Does all the neccessaary hiding and disabling of physic
game.disabledTotal += Data.earnings[level]
disabled = true
$Node2D/Area2D.collision_mask = 0
if invisible:
if invisible: # Sets visibility
if (game.visibly + 1) / game.total < game.show or game.show == 1:
game.visibly += 1
invisible = false
self.show()
else:
if game.visibly / game.total > game.show:
game.visibly -= 1
invisible = true
self.hide()
var _visibilty = true
# Makes sure to set the visibilty according to the right setting
if game.onlySimulate:
_visibilty = not disabled
else:
_visibilty = not invisible
if _visibilty:
self.show()
else:
self.hide()

0 comments on commit b162b72

Please sign in to comment.