Some tweaks
This commit is contained in:
+10
-16
@@ -2,12 +2,9 @@ extends Node
|
||||
|
||||
signal show_main_menu
|
||||
|
||||
|
||||
var _pause_menu: PauseMenu
|
||||
var _current_passage: Passage
|
||||
|
||||
var _show_pause_menu: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_current_passage = load("res://game/passage.tscn").instantiate()
|
||||
@@ -15,33 +12,30 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("pause") and not _current_passage.is_paused():
|
||||
if event.is_action_pressed("pause") and not get_tree().paused:
|
||||
_pause_game()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if _show_pause_menu:
|
||||
_pause_menu = load("res://menu/pause_menu.tscn").instantiate()
|
||||
add_child(_pause_menu)
|
||||
_pause_menu.continue_game.connect(_unpause_game)
|
||||
_pause_menu.show_main_menu.connect(_show_main_menu)
|
||||
_show_pause_menu = false
|
||||
func _create_pause_menu() -> void:
|
||||
_pause_menu = load("res://menu/pause_menu.tscn").instantiate()
|
||||
add_child(_pause_menu)
|
||||
_pause_menu.continue_game.connect(_unpause_game)
|
||||
_pause_menu.show_main_menu.connect(_show_main_menu)
|
||||
|
||||
|
||||
func _pause_game() -> void:
|
||||
_current_passage.set_paused(true)
|
||||
get_tree().paused = true
|
||||
_current_passage.visible = false
|
||||
|
||||
_show_pause_menu = true
|
||||
|
||||
_create_pause_menu.call_deferred()
|
||||
|
||||
|
||||
func _unpause_game() -> void:
|
||||
_current_passage.set_paused(false)
|
||||
get_tree().paused = false
|
||||
_current_passage.visible = true
|
||||
|
||||
_pause_menu.queue_free()
|
||||
|
||||
|
||||
func _show_main_menu() -> void:
|
||||
get_tree().paused = false
|
||||
show_main_menu.emit()
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
class_name Passage
|
||||
|
||||
extends Node2D
|
||||
|
||||
var _paused : bool = false
|
||||
|
||||
|
||||
func set_paused(paused: bool) -> void:
|
||||
_paused = paused
|
||||
|
||||
|
||||
func is_paused() -> bool:
|
||||
return _paused
|
||||
|
||||
@@ -9,8 +9,24 @@ const SETTING_WINDOW_FACTOR = "window_factor"
|
||||
|
||||
var _config: ConfigFile
|
||||
|
||||
|
||||
var _fullscreen := false
|
||||
var fullscreen : bool:
|
||||
get:
|
||||
return _fullscreen
|
||||
set(value):
|
||||
_fullscreen = value
|
||||
_apply_video_settings()
|
||||
_save_settings()
|
||||
|
||||
var _window_factor := 0
|
||||
var window_factor : int:
|
||||
get:
|
||||
return _window_factor
|
||||
set(value):
|
||||
_window_factor = value
|
||||
_apply_video_settings()
|
||||
_save_settings()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -86,23 +102,3 @@ func _ensure_window_on_screen() -> void:
|
||||
|
||||
if new_x != window_position.x or new_y != window_position.y:
|
||||
DisplayServer.window_set_position(Vector2i(new_x, new_y))
|
||||
|
||||
|
||||
func set_fullscreen(value: bool) -> void:
|
||||
_fullscreen = value
|
||||
_apply_video_settings()
|
||||
_save_settings()
|
||||
|
||||
|
||||
func fullscreen() -> bool:
|
||||
return _fullscreen
|
||||
|
||||
|
||||
func set_window_factor(value: int) -> void:
|
||||
_window_factor = value
|
||||
_apply_window_scale()
|
||||
_save_settings()
|
||||
|
||||
|
||||
func window_factor() -> int:
|
||||
return _window_factor
|
||||
|
||||
+6
-6
@@ -20,23 +20,23 @@ func _setup_neighbors() -> void:
|
||||
|
||||
|
||||
func _load_current_settings() -> void:
|
||||
$%FullscreenCheckButton.button_pressed = SettingsManager.fullscreen()
|
||||
$%WindowFactorOptionButton.selected = SettingsManager.window_factor()
|
||||
$%FullscreenCheckButton.button_pressed = SettingsManager.fullscreen
|
||||
$%WindowFactorOptionButton.selected = SettingsManager.window_factor
|
||||
_update_window_factor_disabled()
|
||||
|
||||
|
||||
func _update_window_factor_disabled() -> void:
|
||||
$%WindowFactorOptionButton.disabled = SettingsManager.fullscreen()
|
||||
$%WindowFactorOptionButton.disabled = SettingsManager.fullscreen
|
||||
|
||||
|
||||
func _on_fullscreen_check_button_toggled(toggled: bool) -> void:
|
||||
SettingsManager.set_fullscreen(toggled)
|
||||
SettingsManager.fullscreen = toggled
|
||||
_update_window_factor_disabled()
|
||||
|
||||
|
||||
func _on_window_factor_option_button_item_selected(index: int) -> void:
|
||||
if !SettingsManager.fullscreen():
|
||||
SettingsManager.set_window_factor(index)
|
||||
if not SettingsManager.fullscreen:
|
||||
SettingsManager.window_factor = index
|
||||
|
||||
|
||||
func _on_credits_button_pressed() -> void:
|
||||
|
||||
@@ -12,6 +12,7 @@ action = &"pause"
|
||||
events = [SubResource("InputEventAction_inj1j"), SubResource("InputEventAction_vy7sn")]
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
process_mode = 2
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_inj1j")
|
||||
|
||||
Reference in New Issue
Block a user