project_teddy/scripts/mainmenu.gd

122 lines
3.4 KiB
GDScript3
Raw Normal View History

2023-01-24 13:33:37 -07:00
extends Control
var mainMenuScene = "res://scenes/mainmenu.tscn"
2023-03-11 18:50:43 -07:00
var musicName = "Fall From Grace"
var musicAuthor = "Darren Curtis"
2023-01-26 13:23:13 -07:00
2023-03-17 00:20:54 -06:00
@export var audio_bus_name := "Master"
@onready var _bus := AudioServer.get_bus_index(audio_bus_name)
2023-01-24 13:33:37 -07:00
func _ready():
2023-03-17 00:20:54 -06:00
AudioServer.set_bus_volume_db(_bus, linear_to_db(Global.volumeModifer))
2023-01-26 13:23:13 -07:00
if Global.playingGame == true:
$Button.text = "RESUME"
2023-03-05 20:15:46 -07:00
$Button3.text = "MAIN MENU"
2023-02-24 23:49:49 -07:00
$playButton.visible = false
2023-03-05 20:15:46 -07:00
$OurTimeIsNowSolo.visible = false
$Button.disabled = false
$AudioStreamPlayer.playing = false
2023-03-11 14:48:23 -07:00
if Global.playingGame == false:
2023-06-01 23:32:22 -06:00
Global.reset_variables_hard()
2023-04-15 15:04:16 -06:00
if not Global.tutorialCompleted:
2023-05-27 16:49:09 -06:00
load_tutorial()
2023-04-15 15:04:16 -06:00
Global.mapName = "Tutorial"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
2023-03-11 18:50:43 -07:00
$musicPanel.visible = true
$musicPanel/playingLabel.text = musicName
$musicPanel/authorLabel.text = musicAuthor
await get_tree().create_timer(3).timeout
$musicPanel.visible = false
2023-01-24 13:33:37 -07:00
func _process(delta):
if Global.playingGame == false:
if $AudioStreamPlayer.playing == false:
$AudioStreamPlayer.playing = true
2023-01-24 13:33:37 -07:00
func _on_button_pressed():
2023-01-26 13:23:13 -07:00
if Global.playingGame == false:
2023-05-27 16:49:09 -06:00
load_tutorial()
2023-03-16 22:59:05 -06:00
Global.mapName = "Tutorial"
2023-01-26 13:23:13 -07:00
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
elif Global.playingGame == true:
2023-03-18 22:08:51 -06:00
self.visible = false
2023-03-02 12:52:49 -07:00
Global.miniMenuResume = true
2023-01-26 13:23:13 -07:00
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
2023-01-26 12:17:54 -07:00
func _on_button_2_pressed():
var scene_trs =load("res://scenes/settings.tscn")
2023-01-24 13:33:37 -07:00
var scene=scene_trs.instantiate()
add_child(scene)
2023-01-26 12:17:54 -07:00
func _on_button_3_pressed():
2023-03-05 20:15:46 -07:00
if Global.playingGame == true:
2023-03-11 16:03:03 -07:00
Global.goScene = "res://scenes/mainmenu-background.tscn"
var scene_trs =load("res://scenes/sceneChangerConfirm.tscn")
var scene=scene_trs.instantiate()
add_child(scene)
2023-03-05 20:15:46 -07:00
elif Global.playingGame == false:
get_tree().quit()
func _on_button_4_pressed():
2023-02-24 23:49:49 -07:00
var scene_trs =load("res://scenes/multiplayer.tscn")
var scene=scene_trs.instantiate()
add_child(scene)
func _on_button_5_pressed():
var scene_trs =load("res://scenes/credits.tscn")
var scene=scene_trs.instantiate()
add_child(scene)
2023-02-24 23:49:49 -07:00
func _on_play_button_mouse_entered():
$playButton/PlayUnselected.visible = false
$playButton/PlaySelected.visible = true
func _on_play_button_mouse_exited():
$playButton/PlayUnselected.visible = true
$playButton/PlaySelected.visible = false
func _on_settings_button_mouse_entered():
$settingsButton/SettingsUnselected.visible = false
$settingsButton/SettingsSelected.visible = true
func _on_settings_button_mouse_exited():
$settingsButton/SettingsUnselected.visible = true
$settingsButton/SettingsSelected.visible = false
func _on_credits_button_mouse_entered():
$creditsButton/CreditUnselected.visible = false
$creditsButton/CreditSelected.visible = true
func _on_credits_button_mouse_exited():
$creditsButton/CreditUnselected.visible = true
$creditsButton/CreditSelected.visible = false
2023-03-12 00:43:49 -07:00
func _on_light_button_pressed():
Global.menuLightSwitch = true
2023-03-12 00:58:33 -07:00
var audiostream = AudioStreamPlayer.new()
audiostream.set_stream(load("res://sounds/light-switch.mp3"))
add_child(audiostream)
audiostream.play()
2023-05-12 23:56:15 -06:00
func _on_issues_button_pressed():
OS.shell_open("https://git.techwizz-emu.com/the_adventures_of_teddy/public_issues/issues")
2023-05-23 13:03:06 -06:00
2023-05-27 16:49:09 -06:00
func load_tutorial():
Global.playerPleaseRespawn = true
2023-05-30 12:48:26 -06:00
Networking.create_server(28000, 0)
2023-05-27 16:49:09 -06:00
Networking.load_map("res://scenes/tutorial.tscn")
Networking.add_player_node(1)
Global.connectedPlayers += [Global.playerName]
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)