update the music player widget when the music changes

This commit is contained in:
Matthias Mailänder
2014-12-22 21:32:07 +01:00
parent c3e3a47746
commit 895f02d7cb
3 changed files with 15 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
using System; using System;
using System.Linq; using System.Linq;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -96,6 +97,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic
installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks; installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
} }
var songWatcher = widget.GetOrNull<LogicTickerWidget>("SONG_WATCHER");
if (songWatcher != null)
{
songWatcher.OnTick = () =>
{
if (Sound.CurrentMusic == null || currentSong == Sound.CurrentMusic)
return;
currentSong = Sound.CurrentMusic;
};
}
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); }; panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); };
} }

View File

@@ -5,6 +5,7 @@ Container@MUSIC_PANEL:
Width: 360 Width: 360
Height: 435 Height: 435
Children: Children:
LogicTicker@SONG_WATCHER:
Label@TITLE: Label@TITLE:
Width: 360 Width: 360
Y: 0-25 Y: 0-25

View File

@@ -5,6 +5,7 @@ Background@MUSIC_PANEL:
Width: 360 Width: 360
Height: 450 Height: 450
Children: Children:
LogicTicker@SONG_WATCHER:
ScrollPanel@MUSIC_LIST: ScrollPanel@MUSIC_LIST:
X: 15 X: 15
Y: 45 Y: 45