diary/system/users/users_singleton.gd
mono 7d285bd607 - reworked Chat Panel system
- added user switching
- added Topic Panel functionality (features are missing)
- some basic refactoring
2022-05-14 20:51:48 +02:00

57 lines
971 B
GDScript

extends Node
signal switched
var _primary_user: User
var _helper_user: User # Since helper has more rights, this is required.
var _current_user: User
func _ready():
_set_up_users()
func switch():
if _current_user == _primary_user:
_current_user = _helper_user
elif _current_user == _helper_user:
_current_user = _primary_user
else:
_current_user = null
emit_signal("switched")
func switch_to(user: User):
if user != _current_user:
_current_user = user
emit_signal("switched")
func get_primary():
return _primary_user
func get_helper():
return _helper_user
func get_current():
return _current_user
func get_inactive():
if _primary_user.is_current():
return _helper_user
elif _helper_user.is_current():
return _primary_user
else:
return null
func _set_up_users():
_primary_user = preload("res://configuration/primary_user.tres")
_helper_user = preload("res://configuration/helper_user.tres")
_current_user = _primary_user