Skip to content

Commit

Permalink
Merge pull request #157 from ac-arcana/main
Browse files Browse the repository at this point in the history
Base Tab Menu
  • Loading branch information
Phazorknight authored Apr 7, 2024
2 parents 5faee29 + d5f7dd6 commit dd193e8
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 119 deletions.
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

0 comments on commit dd193e8

Please sign in to comment.