extends GridContainer signal grid_completed export var answerGrid = [ 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, ] export var gridSize = { "col": 5, "row": 5, } var lineHeaders func _ready(): lineHeaders = get_tree().get_nodes_in_group("LineHeader") for header in lineHeaders: header.connect("line_completed", self, "_lineHeader_completed") parse_LineHeader_name(header) func _lineHeader_completed(): var result = true for i in range(0, lineHeaders.size()): if !lineHeaders[i].completed: result = false break if result: emit_signal("grid_completed") func parse_LineHeader_name(line_header: LineHeader): var line_type = line_header.name.substr(0, 3) match line_type: "Col": set_LineHeader_col(line_header) "Row": set_LineHeader_row(line_header) _: print("Error, LineHeader is neither Col nor Row !") get_tree().quit(1) # Check state at default (line content at 0) line_header._pix_clicked() func set_LineHeader_col(line_header: LineHeader): var column = int(line_header.name.substr(3)) var answer = answerGrid.slice(column, gridSize.col * gridSize.row, gridSize.col) line_header.set_answer_line(answer, "\n") func set_LineHeader_row(line_header: LineHeader): var row = int(line_header.name.substr(3)) var answer = answerGrid.slice(row * gridSize.col, row * gridSize.col + gridSize.col - 1) line_header.set_answer_line(answer, " ")