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

View file

@ -7,188 +7,200 @@ func _ready():
loadingScreen = $LoadingScreen loadingScreen = $LoadingScreen
map = get_parent() map = get_parent()
map.loadingScreen = loadingScreen map.loadingScreen = loadingScreen
nextFrame.call_deferred() #nextFrame.call_deferred()
var thread: Thread #var thread: Thread
func nextFrame(): #func nextFrame():
#thread = Thread.new() ##thread = Thread.new()
#thread.start(loadThread) ##thread.start(loadThread)
loadThread() #loadThread()
func loadThread(): var loadStage = 0
LoadAllSounds.Go(map) var frameDelay = 1
#Local i%, de.Decals, d.Doors, it.Items, r.Rooms, sc.SecurityCams, e.Events func _process(delta: float) -> void:
if loadStage == 0 and frameDelay == 0:
LoadAllSounds.Go(map)
map.LoadRoomTemplates("Data/rooms.ini") map.LoadRoomTemplates("Data/rooms.ini")
loadingScreen.LoadProgress(45) loadingScreen.LoadProgress(45)
loadStage = 1
frameDelay = 1
elif loadStage == 1 and frameDelay == 0:
#map.HideDistance = 15.0
#map.HideDistance = 15.0 #map.HeartBeatRate = 70
#map.HeartBeatRate = 70 #map.AccessCode = 0
#for i in range(4):
#map.AccessCode = map.AccessCode + randi_range(1, 9) * (10 ^ i)
#map.AccessCode = 0 #if map.SelectedMap == "":
#for i in range(4): map.CreateMap()
#map.AccessCode = map.AccessCode + randi_range(1, 9) * (10 ^ i) #else:
#LoadMap("Map Creator\Maps\"+SelectedMap)
#if map.SelectedMap == "": #InitWayPoints()
map.CreateMap() loadingScreen.LoadProgress(79)
#else: loadStage = 2
#LoadMap("Map Creator\Maps\"+SelectedMap) 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)
#var busyWork: int for d: Door in map.doors:
#while not map.mapMade: map.EntityParent(d.obj, null)
#busyWork += 1 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)
#InitWayPoints() 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)
loadingScreen.LoadProgress(79) #for it: Item in map.items:
#map.EntityType (it.collider, HIT_ITEM)
#map.EntityParent(it.collider, null)
#Curr173 = CreateNPC(NPCtype173, 0, -30.0, 0) loadingScreen.LoadProgress(80)
#Curr106 = CreateNPC(NPCtypeOldMan, 0, -30.0, 0) loadStage = 3
#Curr106.State = 70 * 60 * randi_range(12,17) 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 d: Door in map.doors: for r: Room in map.rooms:
map.EntityParent.call_deferred(d.obj, null) for i in range(Constants.MaxRoomLights):
if d.obj2 != null: if r.Lights[i] != null:
map.EntityParent.call_deferred(d.obj2, null) map.EntityParent(r.Lights[i], 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)
if d.obj2 != null and d.dir == 0: #if (not r.RoomTemplate.DisableDecals):
map.MoveEntity.call_deferred(d.obj, 0, 0, 8.0 * Constants.RoomScale) #if randi_range(0, 4) == 1:
map.MoveEntity.call_deferred(d.obj2, 0, 0, 8.0 * Constants.RoomScale) #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)
#for it: Item in map.items: #EntityAlpha(de\obj, Rnd(0.85, 0.95))
#map.EntityType (it.collider, HIT_ITEM) #EndIf
#map.EntityParent(it.collider, null) #
#If Rand(4) = 1 Then
loadingScreen.LoadProgress(80) #de.Decals = CreateDecal(0, EntityX(r\obj)+Rnd(- 2,2), 0.003, EntityZ(r\obj)+Rnd(-2,2), 90, Rand(360), 0)
#For sc.SecurityCams= Each SecurityCams #de\Size = Rnd(0.5, 0.7) : EntityAlpha(de\obj, 0.7) : de\ID = 1 : ScaleSprite(de\obj, de\Size, de\Size)
#sc\angle = EntityYaw(sc\obj) + sc\angle #EntityAlpha(de\obj, Rnd(0.7, 0.85))
#EntityParent(sc\obj, 0) #EndIf
#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)
#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 #EndIf
#
#If Rand(4) = 1 Then #If (r\RoomTemplate\Name = "start" And IntroEnabled = False) Then
#de.Decals = CreateDecal(0, EntityX(r\obj)+Rnd(- 2,2), 0.003, EntityZ(r\obj)+Rnd(-2,2), 90, Rand(360), 0) #PositionEntity (Collider, EntityX(r\obj)+3584*RoomScale, 704*RoomScale, EntityZ(r\obj)+1024*RoomScale)
#de\Size = Rnd(0.5, 0.7) : EntityAlpha(de\obj, 0.7) : de\ID = 1 : ScaleSprite(de\obj, de\Size, de\Size) #PlayerRoom = r
#EntityAlpha(de\obj, Rnd(0.7, 0.85)) #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
#EndIf
#If (r\RoomTemplate\Name = "start" And IntroEnabled = False) Then #Local rt.RoomTemplates
#PositionEntity (Collider, EntityX(r\obj)+3584*RoomScale, 704*RoomScale, EntityZ(r\obj)+1024*RoomScale) #for rt: RoomTemplate in map.RoomTemplates:
#PlayerRoom = r #FreeEntity(rt.obj)
#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 #Local tw.TempWayPoints
#for rt: RoomTemplate in map.RoomTemplates: #For tw.TempWayPoints = Each TempWayPoints
#FreeEntity(rt.obj) #Delete tw
#Next
#Local tw.TempWayPoints #TurnEntity(Collider, 0, Rand(160, 200), 0)
#For tw.TempWayPoints = Each TempWayPoints
#Delete tw
#Next
#TurnEntity(Collider, 0, Rand(160, 200), 0) #ResetEntity Collider
#ResetEntity Collider #if SelectedMap == "":
map.eventSystem.InitEvents()
#if SelectedMap == "": for e: Event in map.eventSystem.events:
map.eventSystem.InitEvents() 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")
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 #MoveMouse viewport_center_x,viewport_center_y;320, 240
# #
#AASetFont Font1 #AASetFont Font1
#HidePointer() #HidePointer()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
Global.player = load("res://scenes/world/Player.tscn").instantiate() Global.PlayTempSound(map.StepSFX[0][0][0])
map.add_child.call_deferred(Global.player)
Global.player.BlinkTimer = -10 Global.player = load("res://scenes/world/Player.tscn").instantiate()
#Global.player.BlurTimer = 100 map.add_child(Global.player)
Global.player.Stamina = 100
for i in range(70): Global.player.BlinkTimer = -10
Global.FPSfactor = 1.0 #Global.player.BlurTimer = 100
#FlushKeys() Global.player.Stamina = 100
#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)): loadStage = 4
loadingScreen.LoadProgress(80 + int(float(i) * 0.27)) 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()
#FreeTextureCache if (int(float(i) * 0.27) != int(float(i - 1) * 0.27)):
loadingScreen.LoadProgress(100) loadingScreen.LoadProgress(80 + int(float(i) * 0.27))
#FlushKeys #FreeTextureCache
#FlushMouse loadingScreen.LoadProgress(100)
Global.player.DropSpeed = 0 #FlushKeys
#FlushMouse
Global.player.DropSpeed = 0
frameDelay = -1
#PrevTime = MilliSecs() #PrevTime = MilliSecs()
if frameDelay > 0:
frameDelay -= 1
var nomore = false
func _process(delta: float) -> void:
if not nomore and loadingScreen.loaded and Input.is_action_just_pressed("ui_accept"): if not nomore and loadingScreen.loaded and Input.is_action_just_pressed("ui_accept"):
nomore = true nomore = true
queue_free.call_deferred() queue_free()
map.OtherOpen = null map.OtherOpen = null
# var nomore = false
#func _exit_tree() -> void: #func _exit_tree() -> void:
#thread.wait_to_finish() #thread.wait_to_finish()