@@ -9,12 +9,17 @@ signal show_game_msg(msg:String)
99# SCENES
1010@onready var grid_container :GridContainer = $ GridContainer
1111@onready var hbox_container :HBoxContainer = $ HBoxContainer
12- # VARS
12+ @onready var inactivity_timer :Timer = $ InactivityTimer
13+ @onready var cont_debug_label :Label = $ "../../ContDebug/VBoxContainer/ContDebugLabel"
14+ @onready var cont_debug_value :Label = $ "../../ContDebug/VBoxContainer/ContDebugValue"
15+ # PRELOAD
1316var CmnFunc = preload ("res://game_boards/all_common/common.gd" ).new ()
1417var CmnDbg = preload ("res://game_boards/all_common/common_debug.gd" ).new ()
18+ # CONST
1519const GEM_COLOR_NAMES = [Enums .GemColor .RED , Enums .GemColor .ORG , Enums .GemColor .YLW , Enums .GemColor .GRN , Enums .GemColor .BLU , Enums .GemColor .PRP ]
1620const GEM_POINTS :int = 25
1721const GEM_DICT :Enums .GemDict = Enums .GemDict .SPACE
22+ # VARS
1823var selected_cell_1 :CommonGemCell = null
1924var selected_cell_2 :CommonGemCell = null
2025var undo_cell_1 :CommonGemCell = null
@@ -27,14 +32,15 @@ var board_props_score:int = 0
2732func _ready ():
2833 # godot setup
2934 randomize ()
35+ inactivity_timer .wait_time = Enums .HINT_DELAY # sync UI to logic
3036 # A: populate board
3137 const brd_sq0 = "res://game_boards/board_space/assets/board_square_0.tscn"
3238 const brd_sq1 = "res://game_boards/board_space/assets/board_square_1.tscn"
3339 CmnFunc .fill_grid (hbox_container , grid_container , brd_sq0 , brd_sq1 )
34- # 20240520: WIP: moved below to "init_game"
35- # CmnFunc.fill_hbox(hbox_container, GEM_DICT, self._on_cell_click)
36- # B: check board after init
37- # process_game_round( )
40+
41+ func _process ( delta ):
42+ cont_debug_label . text = "TIMER left secs..."
43+ cont_debug_value . text = str ( round ( inactivity_timer . time_left ) )
3844
3945# NOTE: iOS [Xcode] has no cells if "CmnFunc.fill_hbox()" is in the _ready() func above
4046# So, instead of having [game_space.gd] flip `visible` flag on this scene, let's do both of these here to alleviate the issue
@@ -81,6 +87,10 @@ func _on_cell_click(gem_cell:CommonGemCell):
8187 Enums .debug_print ("[_on_cell_click] gem_cell.......: " + JSON .stringify (CmnFunc .find_gem_indices (gem_cell )), Enums .DEBUG_LEVEL .INFO )
8288 Enums .debug_print ("[_on_cell_click] ---------------------------------------------" , Enums .DEBUG_LEVEL .INFO )
8389
90+ # A: Reset the inactivity_timer timer on any user input
91+ inactivity_timer .stop ()
92+ inactivity_timer .start ()
93+
8494 # Clear first, we'll set later
8595 if selected_cell_1 :
8696 selected_cell_1 .play_selected_anim (false )
@@ -214,8 +224,6 @@ func process_game_round():
214224 # B: TODO: check for "NO MORE MOVES"
215225 var brent = CmnFunc .check_for_possible_moves (hbox_container )
216226 print ("CHECK FOR MOVES = " , str (brent ))
217- # C: TODO: highlight available moves after short delay
218- CmnFunc .highlight_first_swap (hbox_container )
219227 # C: Reset undo cells or perform other cleanup here.
220228 if undo_cell_1 and undo_cell_2 :
221229 swap_gem_cells (undo_cell_2 , undo_cell_1 )
@@ -329,3 +337,13 @@ func debug_make_gem_grid():
329337
330338func debug_clear_debug_labels ():
331339 CmnDbg .debug_clear_debug_labels (hbox_container )
340+
341+ func _on_inactivity_timer_timeout ():
342+ # A: Deselect all (e.g.: maybe one gem was clicked on and is just pulsating on screen)
343+ # TODO: ^^^
344+ # B: Call the highlight function on timeout
345+ # WIP: highlight available moves after short delay
346+ # cont_debug_label.text += "- highlight_first_swap! \n"
347+ CmnFunc .highlight_first_swap (hbox_container )
348+ # C: Restart timer
349+ inactivity_timer .start ()
0 commit comments