Merge pull request #12646 from pchote/asset-error
Simplify asset browser error message display.
This commit is contained in:
@@ -45,12 +45,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Sprite[] currentSprites;
|
Sprite[] currentSprites;
|
||||||
VqaPlayerWidget player = null;
|
VqaPlayerWidget player = null;
|
||||||
bool isVideoLoaded = false;
|
bool isVideoLoaded = false;
|
||||||
|
bool isLoadError = false;
|
||||||
int currentFrame;
|
int currentFrame;
|
||||||
|
|
||||||
LabelWidget errorLabelWidget;
|
|
||||||
SpriteFont errorFont;
|
|
||||||
bool IsErrorLabelVisible { get { return errorLabelWidget != null && errorLabelWidget.Visible; } }
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary<string, MiniYaml> logicArgs)
|
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary<string, MiniYaml> logicArgs)
|
||||||
{
|
{
|
||||||
@@ -88,16 +85,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
spriteWidget.GetSprite = () => currentSprites != null ? currentSprites[currentFrame] : null;
|
spriteWidget.GetSprite = () => currentSprites != null ? currentSprites[currentFrame] : null;
|
||||||
currentPalette = spriteWidget.Palette;
|
currentPalette = spriteWidget.Palette;
|
||||||
spriteWidget.GetPalette = () => currentPalette;
|
spriteWidget.GetPalette = () => currentPalette;
|
||||||
spriteWidget.IsVisible = () => !isVideoLoaded && !IsErrorLabelVisible;
|
spriteWidget.IsVisible = () => !isVideoLoaded && !isLoadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
var playerWidget = panel.GetOrNull<VqaPlayerWidget>("PLAYER");
|
var playerWidget = panel.GetOrNull<VqaPlayerWidget>("PLAYER");
|
||||||
if (playerWidget != null)
|
if (playerWidget != null)
|
||||||
playerWidget.IsVisible = () => isVideoLoaded && !IsErrorLabelVisible;
|
playerWidget.IsVisible = () => isVideoLoaded && !isLoadError;
|
||||||
|
|
||||||
errorLabelWidget = panel.GetOrNull<LabelWidget>("ERROR");
|
var errorLabelWidget = panel.GetOrNull("ERROR");
|
||||||
if (errorLabelWidget != null)
|
if (errorLabelWidget != null)
|
||||||
errorFont = Game.Renderer.Fonts[errorLabelWidget.Font];
|
errorLabelWidget.IsVisible = () => isLoadError;
|
||||||
|
|
||||||
var paletteDropDown = panel.GetOrNull<DropDownButtonWidget>("PALETTE_SELECTOR");
|
var paletteDropDown = panel.GetOrNull<DropDownButtonWidget>("PALETTE_SELECTOR");
|
||||||
if (paletteDropDown != null)
|
if (paletteDropDown != null)
|
||||||
@@ -292,6 +289,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => currentFilename == filename,
|
() => currentFilename == filename,
|
||||||
() => { LoadAsset(filename); });
|
() => { LoadAsset(filename); });
|
||||||
|
|
||||||
item.Get<LabelWidget>("TITLE").GetText = () => filepath;
|
item.Get<LabelWidget>("TITLE").GetText = () => filepath;
|
||||||
item.IsVisible = () =>
|
item.IsVisible = () =>
|
||||||
{
|
{
|
||||||
@@ -322,7 +320,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (!modData.DefaultFileSystem.Exists(filename))
|
if (!modData.DefaultFileSystem.Exists(filename))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
errorLabelWidget.Visible = false;
|
isLoadError = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -346,15 +344,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (errorLabelWidget != null)
|
isLoadError = true;
|
||||||
{
|
|
||||||
errorLabelWidget.Text = WidgetUtils.TruncateText(errorLabelWidget.Text.Replace("{filename}", filename),
|
|
||||||
errorLabelWidget.Bounds.Width, errorFont);
|
|
||||||
|
|
||||||
currentSprites = new Sprite[0];
|
|
||||||
errorLabelWidget.Visible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.AddChannel("assetbrowser", "assetbrowser.log");
|
Log.AddChannel("assetbrowser", "assetbrowser.log");
|
||||||
Log.Write("assetbrowser", "Error reading {0}:{3} {1}{3}{2}", filename, ex.Message, ex.StackTrace, Environment.NewLine);
|
Log.Write("assetbrowser", "Error reading {0}:{3} {1}{3}{2}", filename, ex.Message, ex.StackTrace, Environment.NewLine);
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ Container@ASSETBROWSER_PANEL:
|
|||||||
Height: 325
|
Height: 325
|
||||||
Align: Center
|
Align: Center
|
||||||
Visible: false
|
Visible: false
|
||||||
Text: Error displaying {filename} check assetbrowser.log
|
Text: Error displaying file. See assetbrowser.log for details.
|
||||||
Container@FRAME_SELECTOR:
|
Container@FRAME_SELECTOR:
|
||||||
X: 190
|
X: 190
|
||||||
Y: 395
|
Y: 395
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ Background@ASSETBROWSER_PANEL:
|
|||||||
Height: 330
|
Height: 330
|
||||||
Align: Center
|
Align: Center
|
||||||
Visible: false
|
Visible: false
|
||||||
Text: Error displaying {filename} check assetbrowser.log
|
Text: Error displaying file. See assetbrowser.log for details.
|
||||||
Container@FRAME_SELECTOR:
|
Container@FRAME_SELECTOR:
|
||||||
X: 190
|
X: 190
|
||||||
Y: 425
|
Y: 425
|
||||||
|
|||||||
Reference in New Issue
Block a user