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