Fix tip loading issue with pre-converted textures
This was SVN commit r8780.
This commit is contained in:
parent
6662195f66
commit
83f297182e
@ -12,32 +12,15 @@ function init(data)
|
||||
setCursor("cursor-wait");
|
||||
|
||||
// Get tip image and corresponding tip text
|
||||
var sprite = "";
|
||||
var tipText = "";
|
||||
var tipImageLoadingArray = buildDirEntList("art/textures/ui/loading/tips/", "*.png", false);
|
||||
var tipTextLoadingArray = buildDirEntList("gui/text/tips/", "*.txt", false);
|
||||
var tipTextFilePath = tipTextLoadingArray[getRandom (0, tipTextLoadingArray.length-1)];
|
||||
var fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png");
|
||||
var tipImageFilePath = "art/textures/ui/loading/tips/" + fileName;
|
||||
|
||||
if (tipImageLoadingArray.length == 0)
|
||||
error("Failed to find any matching tip textures for the loading screen.");
|
||||
else if (tipTextLoadingArray.length == 0)
|
||||
error("Failed to find any matching tip text files for the loading screen.");
|
||||
else if (tipImageLoadingArray.length != tipTextLoadingArray.length)
|
||||
error("The there are different amounts of tip images and tip text files.");
|
||||
else
|
||||
if (tipTextLoadingArray.length > 0)
|
||||
{
|
||||
var randomIndex = getRandom (0, tipImageLoadingArray.length-1);
|
||||
|
||||
sprite = "stretched:" + tipImageLoadingArray[randomIndex];
|
||||
sprite = sprite.replace("art/textures/ui/", "");
|
||||
sprite = sprite.replace(".cached.dds", ""); // cope with pre-cached textures
|
||||
|
||||
tipText = readFile(tipTextLoadingArray[randomIndex]);
|
||||
}
|
||||
|
||||
// Set tip image
|
||||
getGUIObjectByName("tipImage").sprite = sprite;
|
||||
|
||||
// Set tip text
|
||||
var tipText = readFile(tipTextFilePath);
|
||||
if (tipText)
|
||||
{
|
||||
var index = tipText.indexOf("\n");
|
||||
@ -47,6 +30,17 @@ function init(data)
|
||||
getGUIObjectByName("tipText").caption = tipTextMessage? tipTextMessage : "";
|
||||
}
|
||||
|
||||
// Set tip image
|
||||
var sprite = "stretched:" + tipImageFilePath;
|
||||
sprite = sprite.replace("art/textures/ui/", "");
|
||||
sprite = sprite.replace(".cached.dds", ""); // cope with pre-cached textures
|
||||
getGUIObjectByName("tipImage").sprite = sprite? sprite : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
error("Failed to find any matching tip textures for the loading screen.")
|
||||
}
|
||||
|
||||
// janwas: main loop now sets progress / description, but that won't
|
||||
// happen until the first timeslice completes, so set initial values.
|
||||
var loadingMapName = getGUIObjectByName ("loadingMapName");
|
||||
|
Loading…
Reference in New Issue
Block a user