extends Node2D onready var menuButtons = $"MenuButtons"; onready var background = $"Background"; onready var saveButtons = $"SlotMenu/LoadGameSlots" onready var arrowCursor = preload("res://resources/cursors/arrow2.webp"); var EnableDebug = true; const labelVersion:String = "v1.5"; var windowSize; var slotName; var tempScene; var haveSavedGame var isMenuZooming; func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) Input.set_custom_mouse_cursor(arrowCursor) CheckHaveStates(); haveSavedGame = SettingsSingleton.GetHaveSave(); windowSize = SettingsSingleton.GetCurrectScreenResolutionVector2() SetClouds(); SetBackground(); SetCamera(); if SettingsSingleton.MainOpenCount == 0: isMenuZooming = true; yield ($Camera2D / Tween, "tween_all_completed"); isMenuZooming = false; SettingsSingleton.MainOpenCount = 1; if SettingsSingleton.MainOpenCount == 1: $Background / Rain.material.set_shader_param("isON", true) SetButtons(); InitSlots(); InitBirds(); get_tree().root.get_node("Loading").LoadCommonScenes(); if not SceneLoader.is_connected("on_scene_loaded", self, "OpenAnotherScene"): var _temp = SceneLoader.connect("on_scene_loaded", self, "OpenAnotherScene") func SetButtons(): var uiLocalization = LanguageLocalization.GetMainMenuButtons(); for i in menuButtons.get_child_count(): var temp = (menuButtons.get_child(i) as Button); temp.text = uiLocalization[i]; changeFontSize(temp); temp.connect("mouse_entered", self, "onButtonHoverOn", [temp]); temp.connect("mouse_exited", self, "onButtonHoverOff", [temp]); if i == 0: if haveSavedGame: temp.rect_size = temp.get_font("res://resources/fonts/OneEleven.ttf").get_string_size(temp.text); temp.rect_position = PositionButton(temp.rect_size, null); temp.visible = true; else : temp.visible = false; else : temp.rect_size = temp.get_font("res://resources/fonts/OneEleven.ttf").get_string_size(temp.text); temp.rect_position = PositionButton(temp.rect_size, menuButtons.get_child(i - 1)); var debugButton = $Debug / Debug changeFontSize(debugButton) debugButton.rect_size = debugButton.get_font("font").get_string_size(debugButton.text); debugButton.rect_position = Vector2(windowSize.x - debugButton.rect_size.x, windowSize.y - debugButton.rect_size.y) $Debug.visible = EnableDebug; $MenuButtons.visible = true; $Logo.visible = true; $Logo / VersionLabel.text = labelVersion; CheckDLC(); func onButtonHoverOn(button): (button as Button).get("custom_fonts/font").outline_color = Color(213, 55, 29, 255) func onButtonHoverOff(button): (button as Button).get("custom_fonts/font").outline_color = Color(0, 0, 0, 255) var positionButtonIndex = 0; func PositionButton(buttonSize, prevSize): var topMargin = 0; if prevSize != null: topMargin = prevSize.rect_size.y; var position = Vector2( windowSize.x * 0.85 - buttonSize.x / 2, windowSize.y * 0.13 + topMargin * positionButtonIndex * 1.55); positionButtonIndex += 1; return position; func _on_Continue_pressed(): menuButtons.visible = false; RemoveHover(); $SlotMenu / Blur.material.set_shader_param("blur_amount", 2.0); $SlotMenu.visible = true; $SlotMenu / LoadGameSlots.visible = true; $SlotMenu / BackToMenuFromSlotContainer / BackToMenuFromSlots.visible = true; $SlotMenu / BackToMenuFromSlotContainer / DifficultyLabel.visible = false $SlotMenu / NewGameSlots.visible = false; $SlotMenu / Overwrite.visible = false; func _on_NewGame_pressed(): menuButtons.visible = false; RemoveHover(); $SlotMenu / Blur.material.set_shader_param("blur_amount", 2.0); $SlotMenu.visible = true; $SlotMenu / NewGameSlots.visible = true; $SlotMenu / BackToMenuFromSlotContainer / BackToMenuFromSlots.visible = true; $SlotMenu / BackToMenuFromSlotContainer / DifficultyLabel.visible = true $SlotMenu / LoadGameSlots.visible = false; $SlotMenu / Overwrite.visible = false; var loadingPath = ""; func LoadScene(path): SceneLoader.load_scene(path); loadingPath = path; for i in menuButtons.get_children(): onButtonHoverOff(i); func _on_Options_pressed(): LoadScene("res://scenes/SettingsScene.tscn") func _on_Debug_pressed(): LoadScene("res://scenes/DebugScene.tscn"); func _on_Credits_pressed(): LoadScene("res://scenes/Credits.tscn"); func _on_Gallery_pressed(): var temp = load("res://scenes/Gallery.tscn").instance(); get_tree().root.add_child(temp); for i in menuButtons.get_children(): onButtonHoverOff(i); CloseMenu(); func OpenAnotherScene(obj): if obj.path == loadingPath: get_tree().root.add_child(obj.instance); CloseMenu(); func CloseMenu(): for i in get_tree().root.get_children(): if i.name == "MainMenu": get_tree().root.remove_child(i); break; SceneLoader.disconnect("on_scene_loaded", self, "OpenAnotherScene"); func _on_Exit_pressed(): get_tree().root.get_node("Loading").PrepareExit(); get_tree().notification(MainLoop.NOTIFICATION_WM_QUIT_REQUEST) get_tree().call_deferred("quit"); func SetBackground(): var backgroundsSize = Vector2(3840, 2160); var scaleX = 1 / float(backgroundsSize.x / windowSize.x); var scaleY = 1 / float(backgroundsSize.y / windowSize.y); for i in background.get_child_count(): var temp = (background.get_child(i) as Node2D); temp.scale = Vector2(scaleX, scaleY); $RainDropEffect.set_polygon(PoolVector2Array([ Vector2(0, 0), Vector2(0, windowSize.y), Vector2(windowSize.x, windowSize.y), Vector2(windowSize.x, 0) ])) func changeFontSize(button:Button): var font = button.get_font("font"); var fontSize = round(0.0708 * windowSize.y - 6.3); font.size = fontSize; font.outline_size = int(0.00555556 * windowSize.y - 3); button.add_font_override("font", font); onready var noDlcLabel:Label = $Logo / NoDlcLabel; onready var dlcCheck:CheckBox = $DLCContainer / DLCCheck; func CheckDLC(): dlcCheck.text = tr("ui_use_dlc"); dlcCheck.visible = SettingsSingleton.GetDLC(); dlcCheck.pressed = SettingsSingleton.GetUseDlc(); noDlcLabel.text = tr("ui_give_feedback"); noDlcLabel.visible = not SettingsSingleton.GetDLC(); func _on_DLCCheck_toggled(button_pressed:bool): SettingsSingleton.SetUseDlc(button_pressed); SettingsSingleton.SaveSettings(); func _on_DLCCheck_mouse_entered(): if dlcCheck.pressed: dlcCheck.get("custom_fonts/font").outline_color = Color8(128, 128, 128, 255) else : dlcCheck.get("custom_fonts/font").outline_color = Color8(213, 213, 213, 255) func _on_DLCCheck_mouse_exited(): dlcCheck.get("custom_fonts/font").outline_color = Color8(0, 0, 0, 255) func InitSlots(): var newNormal = $SlotMenu / NewGameSlots / VBoxContainer / Normal newNormal.Init("Normal"); newNormal.connect("pressed", self, "onNewSlotPressed", ["AutosaveCasual"]); var newHard = $SlotMenu / NewGameSlots / VBoxContainer / Hard; newHard.Init("Hard"); newHard.connect("pressed", self, "onNewSlotPressed", ["AutosaveNormal"]); var uiLocalization = LanguageLocalization.GetSlotMenuButtons(); var loadAutosaveNormal = $SlotMenu / LoadGameSlots / HBoxContainer / VBoxContainer / AutosaveNormal; loadAutosaveNormal.connect("SlotNameClicked", self, "onLoadSlotPressed", ["AutosaveNormal"]); loadAutosaveNormal.Init("AutosaveNormal", tr(uiLocalization[0])); loadAutosaveNormal.CheckIfDisabled(); var loadAutosaveCasual = $SlotMenu / LoadGameSlots / HBoxContainer / VBoxContainer / AutosaveCasual; loadAutosaveCasual.connect("SlotNameClicked", self, "onLoadSlotPressed", ["AutosaveCasual"]); loadAutosaveCasual.Init("AutosaveCasual", tr(uiLocalization[1])); loadAutosaveCasual.CheckIfDisabled(); CreateSlots(0); var paginationContainer = $SlotMenu / LoadGameSlots / HBoxContainer / Control / Pagination; for i in paginationContainer.get_child_count(): var btn:Button = paginationContainer.get_child(i); btn.connect("pressed", self, "_on_slot_Page_pressed", [i]); $SlotMenu / Blur.set_polygon(PoolVector2Array([ Vector2(0, 0), Vector2(0, windowSize.y), Vector2(windowSize.x, windowSize.y), Vector2(windowSize.x, 0) ])) var backbutton = $SlotMenu / BackToMenuFromSlotContainer / BackToMenuFromSlots var difficultyLabel = $SlotMenu / BackToMenuFromSlotContainer / DifficultyLabel backbutton.text = tr("ui_back_to_menu"); difficultyLabel.text = tr("ui_difficulty_text"); var buttonHeight = backbutton.get_font("font").get_string_size(backbutton.text).y; backbutton.rect_global_position = Vector2(30, 1080 - 20 - buttonHeight); backbutton.connect("mouse_entered", self, "onButtonHoverOn", [backbutton]); backbutton.connect("mouse_exited", self, "onButtonHoverOff", [backbutton]); var slotScene = preload("res://resources/customControls/SaveSlot.tscn"); func CreateSlots(pageNumber:int): var slotIndex = pageNumber * 4; var slotsContainer = $SlotMenu / LoadGameSlots / HBoxContainer / Control / VBoxContainer; var slotLocalization = tr("ui_slot") for i in 2: var hContainer = HBoxContainer.new(); hContainer.set("custom_constants/separation", 605); for j in 2: slotIndex += 1; var slot = slotScene.instance(); var slotname = str("slot", slotIndex); slot.connect("SlotNameClicked", self, "onLoadSlotPressed", [slotname]); slot.Init(str(slotIndex), str(slotLocalization, " ", slotIndex)); slot.CheckIfDisabled(); hContainer.add_child(slot); slotsContainer.add_child(hContainer); var paginationContainer = $SlotMenu / LoadGameSlots / HBoxContainer / Control / Pagination for i in paginationContainer.get_child_count(): var button = paginationContainer.get_child(i); if i == pageNumber: button.disabled = true; button._on_Button_mouse_entered(); else : button.disabled = false; button._on_Button_mouse_exited(); func _on_slot_Page_pressed(number): var slotsContainer = $SlotMenu / LoadGameSlots / HBoxContainer / Control / VBoxContainer; for i in slotsContainer.get_children(): slotsContainer.remove_child(i); CreateSlots(number); func onLoadSlotPressed(slotNameVar): slotName = slotNameVar; loadGame(); func loadGame(): Dialogic.load(slotName) if slotName == "AutosaveNormal": Dialogic.set_variable("EasyMode", 0) else : Dialogic.set_variable("EasyMode", 1) Dialogic.set_variable("SaveSlotName", "AutosaveCasual") Dialogic.set_variable("NeedCharacter", 1) get_tree().root.get_node("Loading").ShowLoader(); SceneLoader.free_scene_cache("Game"); LoadScene("res://scenes/Game.tscn"); func onNewSlotPressed(slotNameVar:String): slotName = slotNameVar; get_tree().root.get_node("Loading").LoadBeginningScenes(); newGame() func newGame(): Dialogic.erase_slot(slotName) Dialogic.reset_saves(slotName) Dialogic.set_variable("SaveSlotName", slotName) Dialogic.set_variable("NeedCharacter", 1) if slotName == "AutosaveNormal": Dialogic.set_variable("EasyMode", 0) else : Dialogic.set_variable("EasyMode", 1) $SlotMenu.visible = false; LoadScene("res://scenes/ChapterSelector.tscn") BackgroundFade(); func BackgroundFade(): $Darkening.visible = true; $Darkening.Fade(true); func CheckHaveStates(): var directory = Directory.new(); var defaultFolder = OS.get_user_data_dir() + "/dialogic"; if not directory.dir_exists(defaultFolder): directory.make_dir(defaultFolder) var slotNames = Dialogic.get_slot_names() if (slotNames.size() > 0): for i in slotNames: Dialogic.load(i) if (Dialogic.get_variable("TimelineSave") != "Timeline_0" and i != "debug"): SettingsSingleton.SetHaveSave(true) else :SettingsSingleton.SetHaveSave(false) var birdLoading:bool = false; func InitBirds(): var _temp = SceneLoader.connect("on_scene_loaded", self, "BirdsLoaded"); SceneLoader.load_scene("res://resources/customControls/Birds/BirdsWrapper.tscn"); birdLoading = true; func BirdsLoaded(obj): if obj.path != "res://resources/customControls/Birds/BirdsWrapper.tscn": return ; SceneLoader.disconnect("on_scene_loaded", self, "BirdsLoaded"); birdLoading = false; var scene = obj.instance; scene.name = "Birds"; $Background.add_child(scene); scene.Init(); func _exit_tree(): if birdLoading: SceneLoader.disconnect("on_scene_loaded", self, "BirdsLoaded"); func _input(ev): if ev is InputEventKey and ev.scancode == KEY_ESCAPE: if ($SlotMenu.visible == true): _on_BackToMenu_pressed(); if isMenuZooming: $Camera2D / Tween.remove_all(); SetCameraToFinalPos(); $Camera2D / Tween.emit_signal("tween_all_completed"); if ev is InputEventKey and ev.scancode == KEY_SPACE: if isMenuZooming: $Camera2D / Tween.remove_all(); SetCameraToFinalPos(); $Camera2D / Tween.emit_signal("tween_all_completed"); if ev is InputEventMouseButton and ev.button_index == BUTTON_LEFT and not ev.pressed: if isMenuZooming: $Camera2D / Tween.remove_all(); SetCameraToFinalPos(); $Camera2D / Tween.emit_signal("tween_all_completed"); func SetClouds(): var cloudH = 2160; var scaleY = windowSize.y * 0.53 / cloudH; var scaleClouds = Vector2(scaleY, scaleY); for i in $Clouds.get_children(): i.scale = scaleClouds; $Clouds / Cloud2.position = Vector2(0, - windowSize.y * 0.05); $Clouds / Cloud1.position = Vector2( - 1000, 0); func RemoveHover(): var buttonsToRemoveHover = []; buttonsToRemoveHover.append_array(menuButtons.get_children()) buttonsToRemoveHover.append_array([$SlotMenu / Overwrite / ButtonYES, $SlotMenu / Overwrite / ButtonNO]) buttonsToRemoveHover.append_array([$SlotMenu / BackToMenuFromSlotContainer / BackToMenuFromSlots]) for i in buttonsToRemoveHover: onButtonHoverOff(i); func SetCamera(): $Camera2D.position = Vector2(960, 540); $Camera2D.zoom = Vector2(1, 1); if SettingsSingleton.MainOpenCount == 1: return ; var finalPos = Vector2(960, 540); var finalZoom = Vector2(1, 1); var startPos = Vector2(680, 200); var startZoom = Vector2(0.35, 0.35); $Camera2D.position = startPos; $Camera2D.zoom = startZoom; $Camera2D / Tween.interpolate_method(self, "ChangePosition", startPos, finalPos, 10, Tween.TRANS_LINEAR, 0); $Camera2D / Tween.interpolate_method(self, "ChangeZoom", startZoom, finalZoom, 10, Tween.TRANS_LINEAR, 0); $Camera2D / Tween.start(); func SetCameraToFinalPos(): var finalPos = Vector2(960, 540); var finalZoom = Vector2(1, 1); $Camera2D.position = finalPos; $Camera2D.zoom = finalZoom; $Background / Rain.zoom = finalZoom func ChangePosition(newPosition): $Camera2D.position = newPosition func ChangeZoom(newZoom): $Camera2D.zoom = newZoom $Background / Rain.zoom = newZoom func _on_ButtonYES_pressed(): newGame() func _on_ButtonNO_pressed(): RemoveHover() saveButtons.visible = true $SlotMenu / LoadGame.visible = false $SlotMenu / Overwrite.visible = false func _on_BackToMenu_pressed(): $SlotMenu.visible = false; $SlotMenu / Blur.material.set_shader_param("blur_amount", 0); RemoveHover(); menuButtons.visible = true; func _on_DiscordButton_pressed(): var _e = OS.shell_open("https://discord.gg/J8rcQFAA"); func _on_EmailButton_pressed(): var email = "awedrtyh1@gmail.com"; OS.set_clipboard(email); var _e = OS.shell_open(str("mailto:", email))