mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-14 01:01:05 +02:00
Implemented loading screen code from prey
This commit is contained in:
+107
-12
@@ -30,6 +30,9 @@ If you have questions concerning this license or the applicable additional terms
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Session_local.h"
|
||||
#ifdef PREY
|
||||
#include "../renderer/tr_local.h"
|
||||
#endif
|
||||
|
||||
idCVar idSessionLocal::com_showAngles( "com_showAngles", "0", CVAR_SYSTEM | CVAR_BOOL, "" );
|
||||
idCVar idSessionLocal::com_minTics( "com_minTics", "1", CVAR_SYSTEM, "" );
|
||||
@@ -1435,25 +1438,117 @@ void idSessionLocal::UnloadMap() {
|
||||
idSessionLocal::LoadLoadingGui
|
||||
===============
|
||||
*/
|
||||
void idSessionLocal::LoadLoadingGui( const char *mapName ) {
|
||||
void idSessionLocal::LoadLoadingGui(const char* mapName) {
|
||||
// load / program a gui to stay up on the screen while loading
|
||||
idStr stripped = mapName;
|
||||
stripped.StripFileExtension();
|
||||
stripped.StripPath();
|
||||
|
||||
char guiMap[ MAX_STRING_CHARS ];
|
||||
strncpy( guiMap, va( "guis/map/%s.gui", stripped.c_str() ), MAX_STRING_CHARS );
|
||||
// give the gamecode a chance to override
|
||||
#ifndef PREY
|
||||
game->GetMapLoadingGUI( guiMap );
|
||||
#endif
|
||||
#ifdef PREY
|
||||
guiLoading = uiManager->FindGui("guis/map/loading.gui", true, false, true);
|
||||
|
||||
if ( uiManager->CheckGui( guiMap ) ) {
|
||||
guiLoading = uiManager->FindGui( guiMap, true, false, true );
|
||||
} else {
|
||||
guiLoading = uiManager->FindGui( "guis/map/loading.gui", true, false, true );
|
||||
if (guiLoading == NULL) {
|
||||
return;
|
||||
}
|
||||
guiLoading->SetStateFloat( "map_loading", 0.0f );
|
||||
|
||||
guiLoading->SetStateFloat("map_loading", 0.0f);
|
||||
|
||||
// Hex dump sets "demo" to localized #str_02087.
|
||||
guiLoading->SetStateString("demo", common->GetLanguageDict()->GetString("#str_02087"));
|
||||
|
||||
idStr imageName;
|
||||
|
||||
if (stripped.Length() > 0) {
|
||||
imageName = va("%s.tga", stripped.c_str());
|
||||
|
||||
if (fileSystem->ReadFile(imageName.c_str(), NULL, NULL) < 0) {
|
||||
imageName.Clear();
|
||||
}
|
||||
else {
|
||||
idImage* image = globalImages->ImageFromFile(imageName.c_str(), TF_DEFAULT, false, TR_REPEAT, TD_DEFAULT, CF_2D);
|
||||
if (image != NULL) {
|
||||
image->PurgeImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imageName.Length() <= 0) {
|
||||
char screenshot[MAX_STRING_CHARS];
|
||||
screenshot[0] = '\0';
|
||||
|
||||
#if defined( PREY_HAS_FIND_MAP_SCREENSHOT )
|
||||
fileSystem->FindMapScreenshot(stripped.c_str(), screenshot, sizeof(screenshot), false);
|
||||
|
||||
if (screenshot[0] != '\0') {
|
||||
imageName = screenshot;
|
||||
}
|
||||
#else
|
||||
// Safe fallback if the Prey filesystem helper is not exposed.
|
||||
imageName = va("guis/assets/loading/%s.tga", stripped.c_str());
|
||||
|
||||
if (fileSystem->ReadFile(imageName.c_str(), NULL, NULL) < 0) {
|
||||
imageName = va("guis/map/%s.tga", stripped.c_str());
|
||||
|
||||
if (fileSystem->ReadFile(imageName.c_str(), NULL, NULL) < 0) {
|
||||
imageName.Clear();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (imageName.Length() > 0) {
|
||||
declManager->FindMaterial(imageName.c_str(), true);
|
||||
guiLoading->SetStateString("image", imageName.c_str());
|
||||
}
|
||||
else {
|
||||
guiLoading->SetStateString("image", "");
|
||||
}
|
||||
|
||||
const idDecl* mapDecl = declManager->FindType(DECL_MAPDEF, mapName, false);
|
||||
|
||||
if (mapDecl != NULL) {
|
||||
const idDeclEntityDef* mapDef = static_cast<const idDeclEntityDef*>(mapDecl);
|
||||
const idDict& dict = mapDef->dict;
|
||||
|
||||
const char* friendlyName = dict.GetString("name");
|
||||
const char* recPlayers = dict.GetString("recplayers");
|
||||
|
||||
guiLoading->SetStateString(
|
||||
"friendlyname",
|
||||
common->GetLanguageDict()->GetString(friendlyName)
|
||||
);
|
||||
|
||||
guiLoading->SetStateString(
|
||||
"recplayers",
|
||||
common->GetLanguageDict()->GetString(recPlayers)
|
||||
);
|
||||
}
|
||||
else {
|
||||
guiLoading->SetStateString("friendlyname", "");
|
||||
guiLoading->SetStateString("recplayers", "");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
char guiMap[MAX_STRING_CHARS];
|
||||
strncpy(guiMap, va("guis/map/%s.gui", stripped.c_str()), MAX_STRING_CHARS);
|
||||
guiMap[MAX_STRING_CHARS - 1] = '\0';
|
||||
|
||||
// give the gamecode a chance to override
|
||||
game->GetMapLoadingGUI(guiMap);
|
||||
|
||||
if (uiManager->CheckGui(guiMap)) {
|
||||
guiLoading = uiManager->FindGui(guiMap, true, false, true);
|
||||
}
|
||||
else {
|
||||
guiLoading = uiManager->FindGui("guis/map/loading.gui", true, false, true);
|
||||
}
|
||||
|
||||
if (guiLoading != NULL) {
|
||||
guiLoading->SetStateFloat("map_loading", 0.0f);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user