Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start page UI #76

Merged
merged 30 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6d244ce
Very basic UI trial
WyattHolliday Feb 2, 2024
c6f80e8
added label, shifted stat_counter to bottom left
MaxwellCole9 Feb 9, 2024
235147f
fixed accidental viewport shifting
MaxwellCole9 Feb 9, 2024
930075b
added label
MaxwellCole9 Feb 9, 2024
4b101be
Merge remote-tracking branch 'origin' into start-page-ui
WyattHolliday Feb 12, 2024
f0531dd
Start button changes display and cells
WyattHolliday Feb 12, 2024
d89e82c
Adjusted stats window styling. Nonfunctional as of now.
MaxwellCole9 Feb 12, 2024
ae3a3f9
Added time stat and reset and menu button functionality
WyattHolliday Feb 13, 2024
b52be73
Added functionality for stats panel. User can now close and move the …
MaxwellCole9 Feb 20, 2024
4d192e5
Pause and quit functionality and rename ui elements
WyattHolliday Feb 20, 2024
52462f7
Added hotkey functionality for statspanel. Obeys menu functionality
MaxwellCole9 Feb 20, 2024
b6f292e
Added in-sim menu functionality
WyattHolliday Feb 23, 2024
03fc095
adjusted click functionality, linked cell signal and applied cell stats.
MaxwellCole9 Feb 23, 2024
fde175b
Merge branch 'start-page-ui' of https://github.com/MylesScholz/A-Life…
MaxwellCole9 Feb 23, 2024
e6e8af9
Renamed exit to main menu to match functonality
WyattHolliday Feb 23, 2024
4877fbd
Merge remote-tracking branch 'origin' into start-page-ui - Needs fixes
WyattHolliday Mar 1, 2024
bf3f3b6
Fixed how cells display
WyattHolliday Mar 1, 2024
77cabaa
Merge remote-tracking branch 'origin' into start-page-ui
WyattHolliday Mar 1, 2024
979bec1
Restructured nodes, fixed pause and exit
WyattHolliday Mar 11, 2024
d1c9ca4
Transfered cell.gd functionality to C++, still broken in terms of dis…
MaxwellCole9 Mar 12, 2024
fc48529
Transfered cell.gd functionality to C++, still broken in terms of dis…
MaxwellCole9 Mar 12, 2024
3c060e3
Added Stats Panel Fucntionality in C++
MaxwellCole9 Mar 13, 2024
2d9b727
Imrpoved refresh
MaxwellCole9 Mar 13, 2024
154a6d4
repaired age display for expected value.
MaxwellCole9 Mar 14, 2024
d2f0366
Merge remote-tracking branch 'origin/main' into start-page-ui
WyattHolliday Mar 14, 2024
6c650cc
added stats, cleaned up functionality and UI
MaxwellCole9 Mar 15, 2024
08063f8
Merge branch 'start-page-ui' of https://github.com/MylesScholz/A-Life…
MaxwellCole9 Mar 15, 2024
34f0660
fixed build issue
MaxwellCole9 Mar 15, 2024
acfd28b
Formatting fixes
MylesScholz Mar 15, 2024
c0437f7
cell.hpp formatting fix
MylesScholz Mar 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions EXIT_TO_MENUButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extends TextureButton

func _pressed():
var rootNode = get_tree().get_root()
rootNode.get_node("CellSpawner/UI/FpsCounter").text = "-1" # Toggles FpsCounter off
rootNode.get_node("CellSpawner/UI/TimeCounter").text = "-1" # Toggles TimeCounter off
rootNode.get_node("CellSpawner/UI/MenuPanels/SaveAndQuitMenuPanel").visible = false
rootNode.get_node("CellSpawner/UI/StatsPanel").visible = false
rootNode.get_node("CellSpawner/UI/NavBar").visible = false
rootNode.get_node("CellSpawner/UI/BarPanel").visible = true
var spawner = rootNode.get_node("CellSpawner")
for child in spawner.get_children():
if child is Cell:
spawner.remove_child(child)
child.queue_free()

var pauseButton = rootNode.get_node("CellSpawner/UI/NavBar/PauseButton")
pauseButton.get_child(!get_tree().paused).visible = false # Change pause button visually
pauseButton.get_child(get_tree().paused).visible = true
get_tree().paused = !get_tree().paused # Pause and unpause

# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
5 changes: 5 additions & 0 deletions GlobalSignals.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# GlobalSignals.gd
extends Node

# Signal to be emitted when a cell is clicked.
signal cell_selected(cell_instance)
4 changes: 4 additions & 0 deletions GlobalVariables.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends Node

var delta_multiplier = 1
var used_pause_button = false
19 changes: 19 additions & 0 deletions MenuButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends TextureButton

func _pressed():
var rootNode = get_tree().get_root()
rootNode.get_node("CellSpawner/UI/MenuPanels/SaveAndQuitMenuPanel").visible = true

var pauseButton = rootNode.get_node("CellSpawner/UI/NavBar/PauseButton")
if (!get_tree().paused):
pauseButton.get_child(1).visible = false # Change pause button visually
pauseButton.get_child(0).visible = true
get_tree().paused = true # Pause and unpause

# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
23 changes: 23 additions & 0 deletions MenuExitButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extends TextureButton

# Should not be able to unpause when in menu

func _pressed():
var rootNode = get_tree().get_root()
rootNode.get_node("CellSpawner/UI/MenuPanels/SaveAndQuitMenuPanel").visible = false
rootNode.get_node("CellSpawner/UI/MenuPanels/SimSettingsMenuPanel").visible = false

if (!GlobalVariables.used_pause_button):
var pauseButton = rootNode.get_node("CellSpawner/UI/NavBar/PauseButton")
pauseButton.get_child(!get_tree().paused).visible = false # Change pause button visually
pauseButton.get_child(get_tree().paused).visible = true
get_tree().paused = !get_tree().paused # Pause and unpause

# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
22 changes: 22 additions & 0 deletions PauseButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extends TextureButton

# Needs a way for c++ scripts to still run when paused for
# things like the fps counter, main menu and reset buttons

func _pressed():
var rootNode = get_tree().get_root()
var SaveAndQuit = rootNode.get_node("CellSpawner/UI/MenuPanels/SaveAndQuitMenuPanel").visible
var SimSettings = rootNode.get_node("CellSpawner/UI/MenuPanels/SimSettingsMenuPanel").visible
if (!SaveAndQuit and !SimSettings):
get_child(!get_tree().paused).visible = false # Change pause button visually
get_child(get_tree().paused).visible = true
get_tree().paused = !get_tree().paused # Pause and unpause
GlobalVariables.used_pause_button = !GlobalVariables.used_pause_button

# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
13 changes: 13 additions & 0 deletions QuitButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends Button

func _pressed():
get_tree().quit()

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
15 changes: 15 additions & 0 deletions SaveAndQuitButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends TextureButton

func _pressed():
var root = get_tree().get_root()
root.get_node("CellSpawner/UI/MenuPanels/SaveAndQuitMenuPanel").visible = true
root.get_node("CellSpawner/UI/MenuPanels/SimSettingsMenuPanel").visible = false

# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
15 changes: 15 additions & 0 deletions SimSettingsButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends TextureButton

func _pressed():
var root = get_tree().get_root()
root.get_node("CellSpawner/UI/MenuPanels/SaveAndQuitMenuPanel").visible = false
root.get_node("CellSpawner/UI/MenuPanels/SimSettingsMenuPanel").visible = true

# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
13 changes: 13 additions & 0 deletions SpeedUpButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends TextureButton

func _pressed():
GlobalVariables.delta_multiplier += .25

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
11 changes: 11 additions & 0 deletions StatsExitButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Button


# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
15 changes: 15 additions & 0 deletions StatsOpenButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends Button


# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass


func _pressed():
visible = false
37 changes: 37 additions & 0 deletions StatsPanel.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
extends Panel

var dragging = false
var drag_offset = Vector2()

# Called when the node enters the scene tree for the first time.
func _ready():
mouse_filter = Control.MOUSE_FILTER_STOP
process_mode = Node.PROCESS_MODE_ALWAYS

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var bar_panel = get_parent().get_node("BarPanel")
if Input.is_key_pressed(KEY_S) and not bar_panel.visible:
visible = true

func _on_stats_exit_button_pressed():
visible = false

func _gui_input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
# Start dragging and calculate the offset when the mouse button is pressed.
dragging = true
drag_offset = get_global_mouse_position() - global_position
else:
dragging = false
accept_event()

if event is InputEventMouseMotion and dragging:
# Update the panel's global position smoothly using the drag offset.
global_position = get_global_mouse_position() - drag_offset
accept_event()


func _on_stats_open_button_pressed():
visible = true # Show the stats panel again.
Loading
Loading