Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node
- const SCENE : String = "res://Levels/IntroStoryScene.tscn"
- const CONFIG_FILE_OPTIONS : String = "user://options.cfg"
- var started : bool = false
- var finishedAnimation : bool = false
- var playedLoop : bool = false
- var deltaIntro : float = 0
- var fullScreen : bool = false
- var vSync : bool = true
- var screenSizeMultiplier : int = 3
- var vibration : bool = true
- func _ready():
- if !SavedData.checkedForSteam:
- if Steam.isSteamRunning():
- Steam.steamInit()
- #Steam.resetAllStats(true) #ONLY RUN AS A TEST
- SavedData.loadAchievementsLocal()
- SavedData.checkedForSteam = true
- loadWindowSizeConfig()
- SavedData.choseDestroyMachine = false
- SavedData.choseSacrificeSelf = false
- checkpoint_saver.startFinalSequence = false
- func loadWindowSizeConfig():
- var displayCfg = ConfigFile.new()
- var err = displayCfg.load(CONFIG_FILE_OPTIONS)
- var currentScreenSizeMax = int(floor(OS.get_screen_size().y / 270))
- if currentScreenSizeMax < 1:
- currentScreenSizeMax = 1
- if currentScreenSizeMax > 3:
- currentScreenSizeMax = 3
- screenSizeMultiplier = currentScreenSizeMax
- if err:
- displayCfg.set_value("options", "screenSizeMultiplier", currentScreenSizeMax)
- displayCfg.set_value("options", "vSync", true)
- displayCfg.set_value("options", "fullScreen", false)
- displayCfg.set_value("options", "vibration", true)
- displayCfg.save(CONFIG_FILE_OPTIONS)
- print("Error loading options, likely doesn't yet exist. Created new options.cfg: ", err)
- else:
- screenSizeMultiplier = displayCfg.get_value("options", "screenSizeMultiplier", currentScreenSizeMax)
- vSync = displayCfg.get_value("options", "vSync", true)
- fullScreen = displayCfg.get_value("options", "fullScreen", false)
- vibration = displayCfg.get_value("options", "vibration", true)
- displayCfg.save(CONFIG_FILE_OPTIONS)
- SavedData.vibrationEnabled = vibration
- _applyWindowSettings()
- func _setFullScreen():
- OS.set_window_fullscreen(true)
- OS.set_use_vsync(vSync)
- OS.set_borderless_window(false)
- Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
- func _setWindowed(size : int):
- OS.set_window_fullscreen(false)
- OS.set_window_size(Vector2(360 * size, 270 * size))
- OS.set_use_vsync(vSync)
- OS.set_borderless_window(false)
- Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
- func _applyWindowSettings():
- if fullScreen:
- _setFullScreen()
- else:
- _setWindowed(screenSizeMultiplier)
- func _process(delta):
- if Steam.isSteamRunning():
- Steam.run_callbacks()
- deltaIntro += delta
- if started && !$charge_intro.playing && !playedLoop:
- $charge_loop.play(0)
- playedLoop = true
- if finishedAnimation:
- get_tree().change_scene(SCENE)
- func _on_AnimatedSprite_animation_finished():
- finishedAnimation = true
- func _on_Timer_timeout():
- started = true
- $AnimatedSprite.playing = true
- $charge_intro.play(0)
- func _input(event):
- if deltaIntro > 1:
- if event.is_action_released("ui_pause") || event.is_action_released("ui_shoot") || event.is_action_released("ui_jump"):
- get_tree().change_scene(SCENE)
Advertisement
Add Comment
Please, Sign In to add comment