Proper swap, generic mouse confinment and win
This commit is contained in:
parent
cba43ee477
commit
5df5633c27
16 changed files with 136 additions and 96 deletions
|
|
@ -6,24 +6,13 @@ func _ready() -> void:
|
|||
func on_round_state_changed(state: int) -> void:
|
||||
if state != Session.ROUND_STATES.BUY:
|
||||
visible = false
|
||||
if visible:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
if Session.session_started_flag:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
MouseConfiner.stop_borrow()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("plr_buy"):
|
||||
if Session.round_state == Session.ROUND_STATES.BUY:
|
||||
visible = not visible
|
||||
else:
|
||||
MouseConfiner.borrow()
|
||||
elif visible:
|
||||
visible = false
|
||||
if visible:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
if Session.session_started_flag:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
MouseConfiner.stop_borrow()
|
||||
|
|
|
|||
|
|
@ -14,12 +14,9 @@ func _input(event: InputEvent) -> void:
|
|||
if event.is_action_pressed("menu_settings"):
|
||||
visible = not visible
|
||||
if visible:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
MouseConfiner.borrow()
|
||||
else:
|
||||
if Session.session_started_flag:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
MouseConfiner.stop_borrow()
|
||||
|
||||
|
||||
func _on_gameplay_main_slider_value_changed(value: float) -> void:
|
||||
|
|
|
|||
20
gui/mouse_confiner.gd
Normal file
20
gui/mouse_confiner.gd
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
extends Node
|
||||
|
||||
var global_mode: Input.MouseMode = Input.MouseMode.MOUSE_MODE_VISIBLE
|
||||
var borrowed_visibiles: int = 0
|
||||
|
||||
func set_global_mode(to: Input.MouseMode) -> void:
|
||||
global_mode = to
|
||||
Input.mouse_mode = to
|
||||
borrowed_visibiles = 0
|
||||
|
||||
func borrow() -> void:
|
||||
borrowed_visibiles += 1
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
func stop_borrow() -> void:
|
||||
if borrowed_visibiles == 0:
|
||||
return
|
||||
borrowed_visibiles -= 1
|
||||
if borrowed_visibiles == 0:
|
||||
Input.mouse_mode = global_mode
|
||||
1
gui/mouse_confiner.gd.uid
Normal file
1
gui/mouse_confiner.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://t5safg1xv074
|
||||
|
|
@ -4,34 +4,28 @@ func _on_spectator_button_pressed() -> void:
|
|||
if Lobby.get_team() != Session.TEAMS.SPECTATE:
|
||||
Lobby.switch_team(Session.TEAMS.SPECTATE)
|
||||
visible = false
|
||||
update_mouse()
|
||||
MouseConfiner.stop_borrow()
|
||||
|
||||
func _on_attack_button_pressed() -> void:
|
||||
if Lobby.get_team() != Session.TEAMS.ATTACK:
|
||||
Lobby.switch_team(Session.TEAMS.ATTACK)
|
||||
visible = false
|
||||
update_mouse()
|
||||
MouseConfiner.stop_borrow()
|
||||
|
||||
func _on_defence_button_pressed() -> void:
|
||||
if Lobby.get_team() != Session.TEAMS.DEFENCE:
|
||||
Lobby.switch_team(Session.TEAMS.DEFENCE)
|
||||
visible = false
|
||||
update_mouse()
|
||||
MouseConfiner.stop_borrow()
|
||||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
visible = false
|
||||
update_mouse()
|
||||
MouseConfiner.stop_borrow()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("menu_team_choice"):
|
||||
visible = not visible
|
||||
update_mouse()
|
||||
|
||||
func update_mouse() -> void:
|
||||
if visible:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
if Session.session_started_flag:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
if visible:
|
||||
MouseConfiner.borrow()
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
MouseConfiner.stop_borrow()
|
||||
|
|
|
|||
15
gui/team_won_text.gd
Normal file
15
gui/team_won_text.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extends Label
|
||||
|
||||
func _ready() -> void:
|
||||
Session.team_won.connect(on_team_won)
|
||||
|
||||
func on_team_won(team: Session.TEAMS):
|
||||
match team:
|
||||
Session.TEAMS.DEFENCE:
|
||||
text = "ПОБЕДА КОМАНДЫ ЗАЩИТНИКОВ"
|
||||
Session.TEAMS.ATTACK:
|
||||
text = "ПОБЕДА КОМАНДЫ АТАКУЮЩИХ"
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self,"modulate",Color.WHITE,2)
|
||||
tween.tween_interval(3.5)
|
||||
tween.tween_property(self,"modulate",Color.TRANSPARENT,1)
|
||||
1
gui/team_won_text.gd.uid
Normal file
1
gui/team_won_text.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://btbpe8hgf0knl
|
||||
Loading…
Add table
Add a link
Reference in a new issue