allow the loading screen to update during world load by delaying for a frame after heavy loads.

This commit is contained in:
Holly Stubbs 2025-03-06 13:29:48 +00:00
parent df41dc7686
commit 4f7b20a5ca
2 changed files with 180 additions and 165 deletions

View file

@ -28,6 +28,7 @@ func loadThread():
loadingScreen.LoadProgress(10)
loadingScreen.LoadProgress(20)
OS.delay_msec(827)
loadingScreen.LoadProgress(25)
@ -52,12 +53,14 @@ func loadThread():
#Include "MapSystem.bb"
loadingScreen.LoadProgress(80)
OS.delay_msec(320)
#Include "NPCs.bb"
#Include "UpdateEvents.bb"
loadingScreen.LoadProgress(90)
OS.delay_msec(981)
#Include "menu.bb"
#MainMenuOpen = True

View file

@ -7,188 +7,200 @@ func _ready():
loadingScreen = $LoadingScreen
map = get_parent()
map.loadingScreen = loadingScreen
nextFrame.call_deferred()
#nextFrame.call_deferred()
var thread: Thread
func nextFrame():
#thread = Thread.new()
#thread.start(loadThread)
loadThread()
#var thread: Thread
#func nextFrame():
##thread = Thread.new()
##thread.start(loadThread)
#loadThread()
func loadThread():
LoadAllSounds.Go(map)
#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)
var loadStage = 0
var frameDelay = 1
#var busyWork: int
#while not map.mapMade:
#busyWork += 1
#InitWayPoints()
func _process(delta: float) -> void:
if loadStage == 0 and frameDelay == 0:
LoadAllSounds.Go(map)
loadingScreen.LoadProgress(79)
map.LoadRoomTemplates("Data/rooms.ini")
#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.call_deferred(d.obj, null)
if d.obj2 != null:
map.EntityParent.call_deferred(d.obj2, null)
if d.frameobj != null:
map.EntityParent.call_deferred(d.frameobj, null)
if d.buttons[0] != null:
map.EntityParent.call_deferred(d.buttons[0], null)
if d.buttons[1] != null:
map.EntityParent.call_deferred(d.buttons[1], null)
loadingScreen.LoadProgress(45)
loadStage = 1
frameDelay = 1
elif loadStage == 1 and frameDelay == 0:
#map.HideDistance = 15.0
if d.obj2 != null and d.dir == 0:
map.MoveEntity.call_deferred(d.obj, 0, 0, 8.0 * Constants.RoomScale)
map.MoveEntity.call_deferred(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.call_deferred(r.Lights[i], null)
#map.HeartBeatRate = 70
#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))
#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)
loadStage = 2
frameDelay = 1
elif loadStage == 2 and frameDelay == 0:
#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)
loadStage = 3
frameDelay = 1
elif loadStage == 3 and frameDelay == 0:
#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 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))
#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
#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 == "":
map.eventSystem.InitEvents()
for e: Event in map.eventSystem.events:
if e.EventName == "room2nuke":
e.EventState = 1.0
print("room2nuke")
if e.EventName == "room106":
e.EventState2 = 1.0
print("room106")
if e.EventName == "room2sl":
e.EventState3 = 1.0
print("room2sl")
#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 == "":
map.eventSystem.InitEvents()
for e: Event in map.eventSystem.events:
if e.EventName == "room2nuke":
e.EventState = 1.0
print("room2nuke")
if e.EventName == "room106":
e.EventState2 = 1.0
print("room106")
if e.EventName == "room2sl":
e.EventState3 = 1.0
print("room2sl")
#MoveMouse viewport_center_x,viewport_center_y;320, 240
#
#AASetFont Font1
#HidePointer()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
Global.player = load("res://scenes/world/Player.tscn").instantiate()
map.add_child.call_deferred(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()
#MoveMouse viewport_center_x,viewport_center_y;320, 240
#
#AASetFont Font1
if (int(float(i) * 0.27) != int(float(i - 1) * 0.27)):
loadingScreen.LoadProgress(80 + int(float(i) * 0.27))
#HidePointer()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
Global.PlayTempSound(map.StepSFX[0][0][0])
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
loadStage = 4
frameDelay = 1
elif loadStage == 4 and frameDelay == 0:
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)
#FreeTextureCache
loadingScreen.LoadProgress(100)
#FlushKeys
#FlushMouse
Global.player.DropSpeed = 0
#FlushKeys
#FlushMouse
Global.player.DropSpeed = 0
frameDelay = -1
#PrevTime = MilliSecs()
var nomore = false
func _process(delta: float) -> void:
if frameDelay > 0:
frameDelay -= 1
if not nomore and loadingScreen.loaded and Input.is_action_just_pressed("ui_accept"):
nomore = true
queue_free.call_deferred()
queue_free()
map.OtherOpen = null
#
var nomore = false
#func _exit_tree() -> void:
#thread.wait_to_finish()