Truncate SoundDevice label at the UI level.
This commit is contained in:
@@ -37,10 +37,6 @@ namespace OpenRA
|
|||||||
Engine = engine;
|
Engine = engine;
|
||||||
Device = device;
|
Device = device;
|
||||||
Label = label;
|
Label = label;
|
||||||
|
|
||||||
// Limit label to 32 characters
|
|
||||||
if (Label.Length > 32)
|
|
||||||
Label = "..." + Label.Substring(Label.Length - 32);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -335,7 +335,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var audioDeviceDropdown = panel.Get<DropDownButtonWidget>("AUDIO_DEVICE");
|
var audioDeviceDropdown = panel.Get<DropDownButtonWidget>("AUDIO_DEVICE");
|
||||||
audioDeviceDropdown.OnMouseDown = _ => ShowAudioDeviceDropdown(audioDeviceDropdown, devices);
|
audioDeviceDropdown.OnMouseDown = _ => ShowAudioDeviceDropdown(audioDeviceDropdown, devices);
|
||||||
audioDeviceDropdown.GetText = () => soundDevice.Label;
|
|
||||||
|
var deviceFont = Game.Renderer.Fonts[audioDeviceDropdown.Font];
|
||||||
|
var deviceLabel = new CachedTransform<SoundDevice, string>(
|
||||||
|
s => WidgetUtils.TruncateText(s.Label, audioDeviceDropdown.UsableWidth, deviceFont));
|
||||||
|
audioDeviceDropdown.GetText = () => deviceLabel.Update(soundDevice);
|
||||||
|
|
||||||
return () =>
|
return () =>
|
||||||
{
|
{
|
||||||
@@ -644,7 +648,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => soundDevice == options[o],
|
() => soundDevice == options[o],
|
||||||
() => soundDevice = options[o]);
|
() => soundDevice = options[o]);
|
||||||
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => options[o].Label;
|
var deviceLabel = item.Get<LabelWidget>("LABEL");
|
||||||
|
var font = Game.Renderer.Fonts[deviceLabel.Font];
|
||||||
|
var label = WidgetUtils.TruncateText(options[o].Label, deviceLabel.Bounds.Width, font);
|
||||||
|
deviceLabel.GetText = () => label;
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user