diff --git a/scenes/screens/LoadInit.tscn b/scenes/screens/LoadInit.tscn new file mode 100644 index 0000000..767c642 --- /dev/null +++ b/scenes/screens/LoadInit.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://bh8bpwgf05eif"] + +[ext_resource type="PackedScene" uid="uid://ctajpl2bdscko" path="res://scenes/screens/LoadingScreen.tscn" id="1_1wbmi"] +[ext_resource type="Script" uid="uid://dwjefg8hhnlmf" path="res://src/LoadInit.gd" id="1_phn4v"] + +[node name="LoadInit" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_phn4v") + +[node name="LoadingScreen" parent="." instance=ExtResource("1_1wbmi")] +layout_mode = 1 + +[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] diff --git a/scenes/screens/LoadWorld.tscn b/scenes/screens/LoadWorld.tscn new file mode 100644 index 0000000..b4ca374 --- /dev/null +++ b/scenes/screens/LoadWorld.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3 uid="uid://7us2ty43184l"] + +[ext_resource type="Script" uid="uid://dbiw5m5l3nbe7" path="res://src/LoadWorld.gd" id="1_05k81"] +[ext_resource type="PackedScene" uid="uid://ctajpl2bdscko" path="res://scenes/screens/LoadingScreen.tscn" id="1_y1jkv"] + +[node name="LoadWorld" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_05k81") + +[node name="LoadingScreen" parent="." instance=ExtResource("1_y1jkv")] +layout_mode = 1 diff --git a/scenes/world/DebugCamera.tscn b/scenes/world/DebugCamera.tscn new file mode 100644 index 0000000..acd687d --- /dev/null +++ b/scenes/world/DebugCamera.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://mmlhpn58sbwy"] + +[ext_resource type="Script" uid="uid://0qi1n888pbj6" path="res://src/TempDebugCamera.gd" id="1_qdkb2"] + +[node name="DebugCamera" type="Node3D"] + +[node name="Camera3D" type="Camera3D" parent="."] +fov = 74.0 +script = ExtResource("1_qdkb2") diff --git a/scenes/world/DynamicMap.tscn b/scenes/world/DynamicMap.tscn index a620fe6..71a0bb9 100644 --- a/scenes/world/DynamicMap.tscn +++ b/scenes/world/DynamicMap.tscn @@ -1,8 +1,6 @@ -[gd_scene load_steps=5 format=3 uid="uid://bc46lc1tdvrio"] +[gd_scene load_steps=3 format=3 uid="uid://bc46lc1tdvrio"] [ext_resource type="Script" uid="uid://b08xfsygxqj6a" path="res://src/DynamicMap.gd" id="1_mytgt"] -[ext_resource type="Script" uid="uid://0qi1n888pbj6" path="res://src/TempDebugCamera.gd" id="2_co6fy"] -[ext_resource type="PackedScene" uid="uid://dm33ofcbh8sht" path="res://scenes/world/Player.tscn" id="3_58gow"] [sub_resource type="Environment" id="Environment_d5g72"] background_mode = 1 @@ -15,25 +13,3 @@ script = ExtResource("1_mytgt") [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_d5g72") - -[node name="CameraPivot" type="Node3D" parent="."] -visible = false - -[node name="Camera3D" type="Camera3D" parent="CameraPivot"] -fov = 74.0 -script = ExtResource("2_co6fy") - -[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) - -[node name="CSGBox3D" type="CSGBox3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.2, 12.2, 0.3) -use_collision = true -size = Vector3(15.4238, 0.866943, 15.2599) - -[node name="Label3D" type="Label3D" parent="."] - -[node name="Player" parent="." instance=ExtResource("3_58gow")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.2, 12.2, 0.3) - -[node name="Sprite3D" type="Sprite3D" parent="."] diff --git a/src/DynamicMap.gd b/src/DynamicMap.gd index 89ee818..fadc97c 100644 --- a/src/DynamicMap.gd +++ b/src/DynamicMap.gd @@ -1,4 +1,7 @@ extends Node3D +class_name DynamicMap + +var loadingScreen: LoadingScreenNode func EntityX(obj: Node3D, global: bool = false): return obj.global_position.x if global else obj.position.x @@ -576,6 +579,8 @@ func CreateEmitter(x: float, y: float, z: float, emittertype: int) -> Emitter: return e func _ready() -> void: + OtherOpen = load("res://scenes/screens/LoadWorld.tscn").instantiate() + add_child(OtherOpen) #add_child(RMesh.LoadRMesh("GFX\\map\\gatea_opt.rmesh", RoomTemplate.new())) #B3D.Load("GFX\\npcs\\106_2.b3d") #add_child(B3D.Load("GFX\\apache.b3d")) @@ -592,9 +597,9 @@ func _ready() -> void: #RMesh.LoadRMesh(self, roomInfo["mesh path"]) #CreateMap() - IntroEnabled = true - LoadRoomTemplates("Data/rooms.ini") - CreateMap() + #IntroEnabled = true + #LoadRoomTemplates("Data/rooms.ini") + #CreateMap() var IntroEnabled: bool var I_Zone: MapZones = MapZones.new() @@ -4549,6 +4554,7 @@ func CalculateRoomExtents(r: Room): print("roomextents: ", r.MinX, ", ", r.MinY, ", ", r.MinZ, ", ", r.MaxX, ", ", r.MaxY, ", ", r.MaxZ) +var loadedRoomMeshes: int = 0 func LoadRoomMesh(rt: RoomTemplate): var path = Utils.GetCaseiFileName(str("res://", rt.objPath.replace("\\", "/"))).replace("res://", "") if rt.objPath.contains(".rmesh"): # file is roommesh @@ -4564,6 +4570,8 @@ func LoadRoomMesh(rt: RoomTemplate): # NOTE: Probably not needed, works different here to b3d. #HideEntity(rt\obj) + #loadingScreen.LoadProgress(int(30.0 + (15.0 / RoomTemplates.size()) * loadedRoomMeshes)) + loadedRoomMeshes += 1 var rooms:Array = [] func CreateRoom(zone, roomshape, x, y, z, name = ""): diff --git a/src/Global.gd b/src/Global.gd index f0a8447..46fa5a6 100644 --- a/src/Global.gd +++ b/src/Global.gd @@ -8,7 +8,6 @@ var textureCache: Dictionary var audioCache: Dictionary var videoToPlay: String var clickSound: AudioStreamPlayer -var music: AudioStreamPlayer var player: Player var FPSfactor: float @@ -53,15 +52,93 @@ func Sin(input: Variant): #func resize(): #resolution = DisplayServer.window_get_size() +var Music: Dictionary[int, String] = { + 0: "The Dread", + 1: "HeavyContainment", + 2: "EntranceZone", + 3: "PD", + 4: "079", + 5: "GateB1", + 6: "GateB2", + 7: "Room3Storage", + 8: "Room049", + 9: "8601", + 10: "106", + 11: "Menu", + 12: "8601Cancer", + 13: "Intro", + 14: "178", + 15: "PDTrench", + 16: "205", + 17: "GateA", + 18: "1499", + 19: "1499Danger", + 20: "049Chase", + 21: "..\\Ending\\MenuBreath", + 22: "914", + 23: "Ending", + 24: "Credits", + 25: "SaveMeFrom", +} + +var MusicCHN: AudioStreamPlayer = AudioStreamPlayer.new() + +var BlurVolume: float +var BlurTimer: float + +var LightBlink: float +var LightFlash: float + +var BumpEnabled: int +var HUDenabled: int + +var Camera: Camera3D +var CameraShake: float +var CurrCameraZoom: float + +var Brightness: int +var CameraFogNear: float +var CameraFogFar: float + +var StoredCameraFogFar# = CameraFogFar + +var MouseSens: float + +var EnableVRam: int + +var NavImages: Array = Utils.Init1DArray(5, null) + +var MusicVolume: float = 1.0 + +# TODO: Set SFX volume! +func PlayTempSound(path: String): + var audioPlayer = AudioStreamPlayer.new() + add_child(audioPlayer) + audioPlayer.connect("finished", func(): + audioPlayer.queue_free() + ) + audioPlayer.stream = LoadAudio(path) + audioPlayer.play() + return audioPlayer + func _ready(): + #BumpEnabled = GetINIInt("options.ini", "options", "bump mapping enabled") + #Brightness = GetINIFloat("options.ini", "options", "brightness") + #HUDenabled = GetINIInt("options.ini", "options", "HUD enabled") + #CameraFogNear = GetINIFloat("options.ini", "options", "camera fog near") + #CameraFogFar = GetINIFloat("options.ini", "options", "camera fog far") + #MouseSens = GetINIFloat("options.ini", "options", "mouse sensitivity") + #EnableVRam = GetINIInt("options.ini", "options", "enable vram") + + MusicCHN.name = "MusicCHN" + add_child(MusicCHN) + clickSound = AudioStreamPlayer.new() + clickSound.name = "ClickSND" clickSound.stream = LoadAudio("SFX/Interact/Button.ogg") clickSound.max_polyphony = 5 add_child(clickSound) - music = AudioStreamPlayer.new() - add_child(music) - #resolution = DisplayServer.window_get_size() #get_viewport().connect("size_changed", resize) diff --git a/src/IntroVideo.gd b/src/IntroVideo.gd index 3cf942f..d59107b 100644 --- a/src/IntroVideo.gd +++ b/src/IntroVideo.gd @@ -14,7 +14,7 @@ func _process(_delta: float) -> void: func _on_video_stream_player_finished() -> void: if Global.videoToPlay == "res://GFX/menu/startup_TSS.avi": #get_tree().change_scene_to_file("res://scenes/screens/MainMenu.tscn") - get_tree().change_scene_to_file("res://scenes/screens/LoadingScreen.tscn") + get_tree().change_scene_to_file("res://scenes/screens/LoadInit.tscn") return Global.videoToPlay = "res://GFX/menu/startup_TSS.avi" diff --git a/src/LoadInit.gd b/src/LoadInit.gd new file mode 100644 index 0000000..27c1eed --- /dev/null +++ b/src/LoadInit.gd @@ -0,0 +1,77 @@ +extends Control + +var loadingScreen: LoadingScreenNode + +func _ready(): + loadingScreen = $LoadingScreen + nextFrame.call_deferred() + +var thread: Thread +func nextFrame(): + thread = Thread.new() + thread.start(loadThread) + +func loadThread(): + loadingScreen.LoadProgress(0) + + #Include "Achievements.bb" + + #Include "Difficulty.bb" + + #Include "dreamfilter.bb" + + Global.MusicVolume = INI.GetFloat(Main.options["audio"], "music volume") + Global.MusicCHN.stream = Global.LoadAudio("SFX/Music/"+ str(Global.Music[2]) + ".ogg") + Global.MusicCHN.stream.loop = true + #Global.MusicCHN.volume_linear = Global.MusicVolume + Global.MusicCHN.play.call_deferred() + + loadingScreen.LoadProgress(10) + + loadingScreen.LoadProgress(20) + + loadingScreen.LoadProgress(25) + + loadingScreen.LoadProgress(30) + + #Global NVGImages = LoadAnimImage("GFX\battery.png",64,64,0,2) + #MaskImage NVGImages,255,0,255 + + for i in range(4): + Global.NavImages[i] = Global.LoadTexture("GFX/navigator/roomborder" + str(i) + ".png") + Global.NavImages[i] = Utils.KeyBackground(Global.NavImages[i], Color(1, 0, 1)) + Global.NavImages[4] = Global.LoadTexture("GFX/navigator/batterymeter.png") + + loadingScreen.LoadProgress(35) + + #Include "Items.bb" + + #Include "Particles.bb" + + loadingScreen.LoadProgress(40) + + #Include "MapSystem.bb" + + loadingScreen.LoadProgress(80) + + #Include "NPCs.bb" + + #Include "UpdateEvents.bb" + + loadingScreen.LoadProgress(90) + + #Include "menu.bb" + #MainMenuOpen = True + + #Global m.MEMORYSTATUS = New MEMORYSTATUS + + loadingScreen.LoadProgress(100) + +var nomore = false +func _process(delta: float) -> void: + if not nomore and loadingScreen.loaded and Input.is_anything_pressed(): + nomore = true + get_tree().change_scene_to_file("res://scenes/screens/MainMenu.tscn") + +func _exit_tree() -> void: + thread.wait_to_finish() diff --git a/src/LoadInit.gd.uid b/src/LoadInit.gd.uid new file mode 100644 index 0000000..a5729f2 --- /dev/null +++ b/src/LoadInit.gd.uid @@ -0,0 +1 @@ +uid://dwjefg8hhnlmf diff --git a/src/LoadWorld.gd b/src/LoadWorld.gd new file mode 100644 index 0000000..8cc5b2c --- /dev/null +++ b/src/LoadWorld.gd @@ -0,0 +1,181 @@ +extends Control + +var loadingScreen: LoadingScreenNode +var map: DynamicMap + +func _ready(): + loadingScreen = $LoadingScreen + map = get_parent() + map.loadingScreen = loadingScreen + nextFrame.call_deferred() + +var thread: Thread +func nextFrame(): + thread = Thread.new() + thread.start(loadThread) + +func loadThread(): + #Local i%, de.Decals, d.Doors, it.Items, r.Rooms, sc.SecurityCams, e.Events + + map.LoadRoomTemplates("Data/rooms.ini") + + loadingScreen.LoadProgress(45) + + #map.HideDistance = 15.0 + + #map.HeartBeatRate = 70 + + #map.AccessCode = 0 + #for i in range(4): + #map.AccessCode = map.AccessCode + randi_range(1, 9) * (10 ^ i) + + #if map.SelectedMap == "": + map.CreateMap() + #else: + #LoadMap("Map Creator\Maps\"+SelectedMap) + + #InitWayPoints() + + loadingScreen.LoadProgress(79) + + #Curr173 = CreateNPC(NPCtype173, 0, -30.0, 0) + #Curr106 = CreateNPC(NPCtypeOldMan, 0, -30.0, 0) + #Curr106.State = 70 * 60 * randi_range(12,17) + + for d: Door in map.doors: + map.EntityParent(d.obj, null) + if d.obj2 != null: + map.EntityParent(d.obj2, null) + if d.frameobj != null: + map.EntityParent(d.frameobj, null) + if d.buttons[0] != null: + map.EntityParent(d.buttons[0], null) + if d.buttons[1] != null: + map.EntityParent(d.buttons[1], null) + + if d.obj2 != null and d.dir == 0: + map.MoveEntity(d.obj, 0, 0, 8.0 * Constants.RoomScale) + map.MoveEntity(d.obj2, 0, 0, 8.0 * Constants.RoomScale) + + #for it: Item in map.items: + #map.EntityType (it.collider, HIT_ITEM) + #map.EntityParent(it.collider, null) + + loadingScreen.LoadProgress(80) + #For sc.SecurityCams= Each SecurityCams + #sc\angle = EntityYaw(sc\obj) + sc\angle + #EntityParent(sc\obj, 0) + #Next + + for r: Room in map.rooms: + for i in range(Constants.MaxRoomLights): + if r.Lights[i] != null: + map.EntityParent(r.Lights[i], null) + + #if (not r.RoomTemplate.DisableDecals): + #if randi_range(0, 4) == 1: + #var de: Decal = CreateDecal(Rand(2, 3), EntityX(r\obj)+Rnd(- 2,2), 0.003, EntityZ(r\obj)+Rnd(-2,2), 90, Rand(360), 0) + #de\Size = Rnd(0.1, 0.4) : ScaleSprite(de\obj, de\Size, de\Size) + #EntityAlpha(de\obj, Rnd(0.85, 0.95)) + #EndIf + # + #If Rand(4) = 1 Then + #de.Decals = CreateDecal(0, EntityX(r\obj)+Rnd(- 2,2), 0.003, EntityZ(r\obj)+Rnd(-2,2), 90, Rand(360), 0) + #de\Size = Rnd(0.5, 0.7) : EntityAlpha(de\obj, 0.7) : de\ID = 1 : ScaleSprite(de\obj, de\Size, de\Size) + #EntityAlpha(de\obj, Rnd(0.7, 0.85)) + #EndIf + #EndIf + + #If (r\RoomTemplate\Name = "start" And IntroEnabled = False) Then + #PositionEntity (Collider, EntityX(r\obj)+3584*RoomScale, 704*RoomScale, EntityZ(r\obj)+1024*RoomScale) + #PlayerRoom = r + #it = CreateItem("Class D Orientation Leaflet", "paper", 1, 1, 1) + #it\Picked = True + #it\Dropped = -1 + #it\itemtemplate\found=True + #Inventory(0) = it + #HideEntity(it\collider) + #EntityType (it\collider, HIT_ITEM) + #EntityParent(it\collider, 0) + #ItemAmount = ItemAmount + 1 + #it = CreateItem("Document SCP-173", "paper", 1, 1, 1) + #it\Picked = True + #it\Dropped = -1 + #it\itemtemplate\found=True + #Inventory(1) = it + #HideEntity(it\collider) + #EntityType (it\collider, HIT_ITEM) + #EntityParent(it\collider, 0) + #ItemAmount = ItemAmount + 1 + #ElseIf (r\RoomTemplate\Name = "173" And IntroEnabled) Then + #PositionEntity (Collider, EntityX(r\obj), 1.0, EntityZ(r\obj)) + #PlayerRoom = r + #EndIf + + #Local rt.RoomTemplates + #for rt: RoomTemplate in map.RoomTemplates: + #FreeEntity(rt.obj) + + #Local tw.TempWayPoints + #For tw.TempWayPoints = Each TempWayPoints + #Delete tw + #Next + + #TurnEntity(Collider, 0, Rand(160, 200), 0) + + #ResetEntity Collider + + #If SelectedMap = "" Then InitEvents() + # + #For e.Events = Each Events + #If e\EventName = "room2nuke" + #e\EventState = 1 + #DebugLog "room2nuke" + #EndIf + #If e\EventName = "room106" + #e\EventState2 = 1 + #DebugLog "room106" + #EndIf + #If e\EventName = "room2sl" + #e\EventState3 = 1 + #DebugLog "room2sl" + #EndIf + #Next + # + #MoveMouse viewport_center_x,viewport_center_y;320, 240 + # + #AASetFont Font1 + + #HidePointer() + + Global.player = load("res://scenes/world/Player.tscn").instantiate() + map.add_child(Global.player) + + Global.player.BlinkTimer = -10 + #Global.player.BlurTimer = 100 + Global.player.Stamina = 100 + + for i in range(70): + Global.FPSfactor = 1.0 + #FlushKeys() + Global.player._process(Global.FPSfactor / 70.0) + Global.player._physics_process(Global.FPSfactor / 70.0) + map.UpdateDoors() + map.UpdateNPCs() + map.UpdateWorld() + + if (int(float(i) * 0.27) != int(float(i - 1) * 0.27)): + loadingScreen.LoadProgress(80 + int(float(i) * 0.27)) + + #FreeTextureCache + loadingScreen.LoadProgress(100) + + #FlushKeys + #FlushMouse + + Global.player.DropSpeed = 0 + + #PrevTime = MilliSecs() + +func _exit_tree() -> void: + thread.wait_to_finish() diff --git a/src/LoadWorld.gd.uid b/src/LoadWorld.gd.uid new file mode 100644 index 0000000..32700f6 --- /dev/null +++ b/src/LoadWorld.gd.uid @@ -0,0 +1 @@ +uid://dbiw5m5l3nbe7 diff --git a/src/LoadingScreen.gd b/src/LoadingScreen.gd index a0b9072..13956d3 100644 --- a/src/LoadingScreen.gd +++ b/src/LoadingScreen.gd @@ -1,4 +1,5 @@ extends Control +class_name LoadingScreenNode func InitLoadingScreen(file: String) -> LoadingScreen: var loadingScreenIni = INI.Load(file) @@ -45,9 +46,9 @@ func generateTextRows(string = "", mw = 0): var strings = [""]; var needToSplit = false; var justSplit = false; - for char in string: + for chr in string: justSplit = false; - if needToSplit and char == " ": + if needToSplit and chr == " ": needToSplit = false justSplit = true strings.push_back("") @@ -57,7 +58,7 @@ func generateTextRows(string = "", mw = 0): needToSplit = true if not justSplit: - strings[arrayIndex] += char + strings[arrayIndex] += chr return strings @@ -72,8 +73,9 @@ var percent: int = 0 func LoadProgress(progress: int): if progress > ((100 / loadingText.size()) * (loadProgressIndex + 1)): loadProgressIndex += 1 + loadProgressIndex = min(loadProgressIndex, loadingText.size() - 1) percent = progress - queue_redraw() + queue_redraw.call_deferred() func _ready() -> void: background = $Background @@ -120,6 +122,9 @@ func _process(delta: float) -> void: loadingImage.position.y = size.y - loadingImage.size.y @onready var binkMeterImg = Global.LoadTexture("GFX/BlinkMeter.jpg") +var firstloop = true +var nomore = false +var loaded = false func _draw(): Global.menuScale = size.y / 1024.0 @@ -143,4 +148,9 @@ func _draw(): if percent == 100: #If firstloop And SelectedLoadingScreen\title <> "CWM" Then PlaySound_Strict LoadTempSound(("SFX\Horror\Horror8.ogg")) + if firstloop: + firstloop = false + loaded = true + Global.PlayTempSound("SFX/Horror/Horror8.ogg") DrawText("PRESS ANY KEY TO CONTINUE", size.x / 2, size.y - 50, COUR_FONT, 19, false, true) + diff --git a/src/file_parsers/INI.gd b/src/file_parsers/INI.gd index 59934a8..2cdc3ba 100644 --- a/src/file_parsers/INI.gd +++ b/src/file_parsers/INI.gd @@ -28,6 +28,11 @@ static func GetInt(dict: Dictionary, name: String) -> int: return dict[name].to_int() return 0 +static func GetFloat(dict: Dictionary, name: String) -> int: + if dict.has(name): + return dict[name].to_float() + return 0 + static func GetBool(dict: Dictionary, name: String) -> bool: if dict.has(name): return dict[name].to_lower() == "true"