Merge pull request #146 from Excello-Recherche-Education/open-dev-options-from-main-menu
Developer Settings now access by clicking on version number
This commit is contained in:
@@ -23,6 +23,7 @@ var dev_last_click_time: float = 0.0
|
||||
@onready var teacher_timer: Timer = %TeacherTimer
|
||||
@onready var teacher_help_label: Label = %TeacherHelpLabel
|
||||
@onready var kalulu_button: CanvasItem = %KaluluButton
|
||||
@onready var version_label: Label = %BuildVersionValue
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -40,6 +41,9 @@ func _ready() -> void:
|
||||
device_number_label.show()
|
||||
device_number_label.text = tr("DEVICE_NUMBER").format({"number": UserDataManager.get_device_settings().device_id})
|
||||
|
||||
version_label.text = ProjectSettings.get_setting("application/config/version")
|
||||
version_label.gui_input.connect(_on_version_label_gui_input)
|
||||
|
||||
await OpeningCurtain.open()
|
||||
|
||||
kalulu_button.hide()
|
||||
@@ -77,17 +81,6 @@ func _on_teacher_button_button_down() -> void:
|
||||
if keyboard.get_password_as_string() != TEACHER_PASSWORD:
|
||||
return
|
||||
teacher_timer.start()
|
||||
var now: float = Time.get_ticks_msec() / 1000.0
|
||||
if now - dev_last_click_time <= DEV_CLICK_MAX_DELAY:
|
||||
dev_click_count += 1
|
||||
else:
|
||||
dev_click_count = 1 # Too slow, reset
|
||||
dev_last_click_time = now
|
||||
if dev_click_count >= DEV_CLICK_THRESHOLD:
|
||||
dev_click_count = 0
|
||||
teacher_timer.stop()
|
||||
await OpeningCurtain.close()
|
||||
get_tree().change_scene_to_file(DEVELOPER_SCENE_PATH)
|
||||
|
||||
|
||||
func _on_teacher_button_button_up() -> void:
|
||||
@@ -99,3 +92,20 @@ func _on_teacher_timer_timeout() -> void:
|
||||
teacher_help_label.hide()
|
||||
await OpeningCurtain.close()
|
||||
get_tree().change_scene_to_file(TEACHER_SCENE_PATH)
|
||||
|
||||
|
||||
func _on_version_label_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
var mb: InputEventMouseButton = event
|
||||
if mb.pressed and mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
var now: float = Time.get_ticks_msec() / 1000.0
|
||||
if now - dev_last_click_time <= DEV_CLICK_MAX_DELAY:
|
||||
dev_click_count += 1
|
||||
else:
|
||||
dev_click_count = 1
|
||||
dev_last_click_time = now
|
||||
if dev_click_count >= DEV_CLICK_THRESHOLD:
|
||||
dev_click_count = 0
|
||||
await OpeningCurtain.close()
|
||||
DeveloperSettings.return_path = get_tree().current_scene.scene_file_path
|
||||
get_tree().change_scene_to_file(DEVELOPER_SCENE_PATH)
|
||||
|
||||
@@ -81,6 +81,21 @@ texture_pressed = ExtResource("8_nxlxw")
|
||||
texture_disabled = ExtResource("9_k74e3")
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="Padding" type="Control" parent="InterfaceLeft/Container"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.1
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="BuildVersionValue" type="Label" parent="InterfaceLeft/Container"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
mouse_filter = 0
|
||||
theme_override_font_sizes/font_size = 30
|
||||
text = "?"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="InterfaceRight" type="MarginContainer" parent="."]
|
||||
custom_minimum_size = Vector2(450, 0)
|
||||
layout_mode = 1
|
||||
|
||||
@@ -3,6 +3,13 @@ extends Control
|
||||
const KALULU: GDScript = preload("res://sources/menus/main/kalulu.gd")
|
||||
const ADULT_CHECK_SCENE_PATH: PackedScene = preload("res://sources/menus/adult_check/adult_check.tscn")
|
||||
const LANGUAGE_CHECK_SCENE_PATH: PackedScene = preload("res://sources/menus/language_selection/language_check.tscn")
|
||||
const DEVELOPER_SCENE_PATH: String = "res://sources/menus/settings/developer_settings.tscn"
|
||||
const DEVELOPER_SETTINGS: GDScript = preload("res://sources/menus/settings/developer_settings.gd")
|
||||
const DEV_CLICK_THRESHOLD: int = 10 # Number of clicks needed to open Developer Settings
|
||||
const DEV_CLICK_MAX_DELAY: float = 0.6 # Delay between each clicks (in seconds)
|
||||
|
||||
var dev_click_count: int = 0
|
||||
var dev_last_click_time: float = 0.0
|
||||
|
||||
@onready var version_label: Label = $Informations/BuildVersionValue
|
||||
@onready var teacher_label: Label = $Informations/TeacherValue
|
||||
@@ -19,6 +26,7 @@ func _ready() -> void:
|
||||
version_label.text = ProjectSettings.get_setting("application/config/version")
|
||||
teacher_label.text = UserDataManager.get_device_settings().teacher
|
||||
device_id_label.text = str(UserDataManager.get_device_settings().device_id)
|
||||
version_label.gui_input.connect(_on_version_label_gui_input)
|
||||
OpeningCurtain.open()
|
||||
|
||||
|
||||
@@ -60,3 +68,20 @@ func _on_login_in() -> void:
|
||||
var error: Error = get_tree().change_scene_to_packed(LANGUAGE_CHECK_SCENE_PATH)
|
||||
if error != OK:
|
||||
Log.error(error_string(error))
|
||||
|
||||
|
||||
func _on_version_label_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
var mb: InputEventMouseButton = event
|
||||
if mb.pressed and mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
var now: float = Time.get_ticks_msec() / 1000.0
|
||||
if now - dev_last_click_time <= DEV_CLICK_MAX_DELAY:
|
||||
dev_click_count += 1
|
||||
else:
|
||||
dev_click_count = 1
|
||||
dev_last_click_time = now
|
||||
if dev_click_count >= DEV_CLICK_THRESHOLD:
|
||||
dev_click_count = 0
|
||||
await OpeningCurtain.close()
|
||||
DeveloperSettings.return_path = get_tree().current_scene.scene_file_path
|
||||
get_tree().change_scene_to_file(DEVELOPER_SCENE_PATH)
|
||||
|
||||
@@ -383,6 +383,7 @@ layout_mode = 1
|
||||
offset_left = 410.0
|
||||
offset_right = 560.0
|
||||
offset_bottom = 56.0
|
||||
mouse_filter = 0
|
||||
theme_override_font_sizes/font_size = 30
|
||||
text = "?"
|
||||
vertical_alignment = 1
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
class_name DeveloperSettings
|
||||
extends Control
|
||||
|
||||
const LOGIN_MENU_PATH: String = "res://sources/menus/login/login.tscn"
|
||||
const LOG_LEVEL_ELEMENT: PackedScene = preload("res://sources/menus/settings/log_level_element.tscn")
|
||||
|
||||
static var return_path: String = "res://sources/menus/main/main_menu.tscn"
|
||||
|
||||
var filters: Dictionary[int, bool] = {}
|
||||
var line_steps: PackedInt32Array = [10, 50, 100, 200, 500, 1000, -1] # -1 = all
|
||||
var loglevel_regex: RegEx
|
||||
@@ -106,7 +107,7 @@ func _on_filters_changed(checked: bool, index: int) -> void:
|
||||
|
||||
func _on_back_button_pressed() -> void:
|
||||
await OpeningCurtain.close()
|
||||
get_tree().change_scene_to_file(LOGIN_MENU_PATH)
|
||||
get_tree().change_scene_to_file(return_path)
|
||||
|
||||
|
||||
func _on_slider_changed(_value: float) -> void:
|
||||
|
||||
Reference in New Issue
Block a user