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

Base Tab Menu #157

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 2 additions & 29 deletions COGITO/EasyMenus/Scripts/OptionsTabMenu.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
extends TabContainer
class_name OptionsTabMenu
extends CogitoTabMenu
signal options_updated

const HSliderWLabel = preload("res://COGITO/EasyMenus/Scripts/slider_w_labels.gd")
var config = ConfigFile.new()

@export var nodes_to_focus: Array[Control]

# GAMEPLAY
@onready var invert_y_check_button: CheckButton = %InvertYAxisCheckButton
@onready var headbob_option_button: OptionButton = %HeadbobOptionButton
Expand Down Expand Up @@ -82,32 +80,6 @@ func on_open():
pass


func _input(event):
if !visible:
return

#Tab navigation
if (event.is_action_pressed("ui_next_tab")):
if current_tab + 1 == get_tab_count():
current_tab = 0
else:
current_tab += 1

if nodes_to_focus[current_tab]:
#print("Grabbing focus of : ", tab_container.current_tab, " - ", nodes_to_focus[tab_container.current_tab])
nodes_to_focus[current_tab].grab_focus.call_deferred()

if (event.is_action_pressed("ui_prev_tab")):
if current_tab == 0:
current_tab = get_tab_count()-1
else:
current_tab -= 1

if nodes_to_focus[current_tab]:
#print("Grabbing focus of : ", tab_container.current_tab, " - ", nodes_to_focus[tab_container.current_tab])
nodes_to_focus[current_tab].grab_focus.call_deferred()


# Adding headbob options to the button
func add_headbob_items() -> void:
for headbob_option in HEADBOB_DICTIONARY:
Expand Down Expand Up @@ -150,6 +122,7 @@ func refresh_render():
get_window().content_scale_size = render_resolution
get_window().scaling_3d_scale = render_scale_val


# Function to change resolution. Hooked up to the resolution_option_button.
func on_resolution_selected(index:int) -> void:
render_resolution = RESOLUTION_DICTIONARY.values()[index]
Expand Down
32 changes: 32 additions & 0 deletions COGITO/EasyMenus/Scripts/tab_menu.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class_name CogitoTabMenu
extends TabContainer
## This class can be extended to create a tab menu with controller support.

## Helper for controller input. Sets the node to focus on for each tab.
## The array index corresponds to the tabs.
@export var nodes_to_focus: Array[Control]

func _input(event):
if !visible:
return

#Tab navigation
if (event.is_action_pressed("ui_next_tab")):
if current_tab + 1 == get_tab_count():
current_tab = 0
else:
current_tab += 1

if nodes_to_focus[current_tab]:
#print("Grabbing focus of : ", tab_container.current_tab, " - ", nodes_to_focus[tab_container.current_tab])
nodes_to_focus[current_tab].grab_focus.call_deferred()

if (event.is_action_pressed("ui_prev_tab")):
if current_tab == 0:
current_tab = get_tab_count()-1
else:
current_tab -= 1

if nodes_to_focus[current_tab]:
#print("Grabbing focus of : ", tab_container.current_tab, " - ", nodes_to_focus[tab_container.current_tab])
nodes_to_focus[current_tab].grab_focus.call_deferred()
Loading