Guest User

Untitled

a guest
Mar 28th, 2025
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.02 KB | Source Code | 0 0
  1. extends Node
  2.  
  3. const SCENE : String = "res://Levels/IntroStoryScene.tscn"
  4. const CONFIG_FILE_OPTIONS : String = "user://options.cfg"
  5.  
  6. var started : bool = false
  7. var finishedAnimation : bool = false
  8. var playedLoop : bool = false
  9. var deltaIntro : float = 0
  10.  
  11. var fullScreen : bool = false
  12. var vSync : bool = true
  13. var screenSizeMultiplier : int = 3
  14. var vibration : bool = true
  15.  
  16. func _ready():
  17.     if !SavedData.checkedForSteam:
  18.         if Steam.isSteamRunning():
  19.             Steam.steamInit()
  20.             #Steam.resetAllStats(true) #ONLY RUN AS A TEST
  21.             SavedData.loadAchievementsLocal()
  22.         SavedData.checkedForSteam = true
  23.     loadWindowSizeConfig()
  24.     SavedData.choseDestroyMachine = false
  25.     SavedData.choseSacrificeSelf = false
  26.     checkpoint_saver.startFinalSequence = false
  27.    
  28. func loadWindowSizeConfig():
  29.     var displayCfg = ConfigFile.new()
  30.     var err = displayCfg.load(CONFIG_FILE_OPTIONS)
  31.    
  32.     var currentScreenSizeMax = int(floor(OS.get_screen_size().y / 270))
  33.     if currentScreenSizeMax < 1:
  34.         currentScreenSizeMax = 1
  35.     if currentScreenSizeMax > 3:
  36.         currentScreenSizeMax = 3
  37.        
  38.     screenSizeMultiplier = currentScreenSizeMax
  39.    
  40.     if err:
  41.         displayCfg.set_value("options", "screenSizeMultiplier", currentScreenSizeMax)
  42.         displayCfg.set_value("options", "vSync", true)
  43.         displayCfg.set_value("options", "fullScreen", false)
  44.         displayCfg.set_value("options", "vibration", true)
  45.         displayCfg.save(CONFIG_FILE_OPTIONS)
  46.         print("Error loading options, likely doesn't yet exist.  Created new options.cfg: ", err)
  47.     else:
  48.         screenSizeMultiplier = displayCfg.get_value("options", "screenSizeMultiplier", currentScreenSizeMax)
  49.         vSync = displayCfg.get_value("options", "vSync", true)
  50.         fullScreen = displayCfg.get_value("options", "fullScreen", false)
  51.         vibration = displayCfg.get_value("options", "vibration", true)
  52.         displayCfg.save(CONFIG_FILE_OPTIONS)
  53.        
  54.     SavedData.vibrationEnabled = vibration
  55.     _applyWindowSettings()
  56.  
  57. func _setFullScreen():
  58.     OS.set_window_fullscreen(true)
  59.     OS.set_use_vsync(vSync)
  60.     OS.set_borderless_window(false)
  61.     Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
  62.  
  63. func _setWindowed(size : int):
  64.     OS.set_window_fullscreen(false)
  65.     OS.set_window_size(Vector2(360 * size, 270 * size))
  66.     OS.set_use_vsync(vSync)
  67.     OS.set_borderless_window(false)
  68.     Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
  69.  
  70. func _applyWindowSettings():
  71.     if fullScreen:
  72.         _setFullScreen()
  73.     else:
  74.         _setWindowed(screenSizeMultiplier)
  75.  
  76. func _process(delta):
  77.    
  78.     if Steam.isSteamRunning():
  79.         Steam.run_callbacks()
  80.    
  81.     deltaIntro += delta
  82.    
  83.     if started && !$charge_intro.playing && !playedLoop:
  84.         $charge_loop.play(0)
  85.         playedLoop = true
  86.    
  87.     if finishedAnimation:
  88.         get_tree().change_scene(SCENE)
  89.  
  90. func _on_AnimatedSprite_animation_finished():
  91.     finishedAnimation = true
  92.  
  93. func _on_Timer_timeout():
  94.     started = true
  95.     $AnimatedSprite.playing = true
  96.     $charge_intro.play(0)
  97.  
  98. func _input(event):
  99.     if deltaIntro > 1:
  100.         if event.is_action_released("ui_pause") || event.is_action_released("ui_shoot") || event.is_action_released("ui_jump"):
  101.             get_tree().change_scene(SCENE)
  102.  
Advertisement
Add Comment
Please, Sign In to add comment