fix trailing whitespace everywhere
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Widget panel;
|
||||
MusicInfo[] music;
|
||||
MusicInfo[] random;
|
||||
|
||||
|
||||
ScrollItemWidget itemTemplate;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
@@ -35,18 +35,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
[ObjectCreator.Param] Action onExit)
|
||||
{
|
||||
panel = widget.GetWidget("MUSIC_PANEL");
|
||||
|
||||
|
||||
var ml = panel.GetWidget<ScrollPanelWidget>("MUSIC_LIST");
|
||||
itemTemplate = ml.GetWidget<ScrollItemWidget>("MUSIC_TEMPLATE");
|
||||
|
||||
|
||||
BuildMusicTable(ml);
|
||||
|
||||
currentSong = Sound.CurrentMusic ?? GetNextSong();
|
||||
installed = Rules.Music.Where(m => m.Value.Exists).Any();
|
||||
Func<bool> noMusic = () => !installed;
|
||||
|
||||
|
||||
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
||||
|
||||
|
||||
Action afterInstall = () =>
|
||||
{
|
||||
// Mount the new mixfile and rebuild the scores list
|
||||
@@ -58,22 +58,22 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Rules.Music.Do(m => m.Value.Reload());
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
|
||||
installed = Rules.Music.Where(m => m.Value.Exists).Any();
|
||||
BuildMusicTable(ml);
|
||||
};
|
||||
|
||||
|
||||
var installButton = panel.GetWidget<ButtonWidget>("INSTALL_BUTTON");
|
||||
installButton.OnClick = () =>
|
||||
Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {{ "afterInstall", afterInstall }});
|
||||
installButton.IsVisible = () => music.Length < 3; // Hack around music being split between transit.mix and scores.mix
|
||||
|
||||
|
||||
panel.GetWidget("NO_MUSIC_LABEL").IsVisible = noMusic;
|
||||
|
||||
var playButton = panel.GetWidget<ButtonWidget>("BUTTON_PLAY");
|
||||
playButton.OnClick = Play;
|
||||
playButton.IsDisabled = noMusic;
|
||||
|
||||
|
||||
var pauseButton = panel.GetWidget<ButtonWidget>("BUTTON_PAUSE");
|
||||
pauseButton.OnClick = Pause;
|
||||
pauseButton.IsDisabled = noMusic;
|
||||
@@ -81,93 +81,93 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
var stopButton = panel.GetWidget<ButtonWidget>("BUTTON_STOP");
|
||||
stopButton.OnClick = Stop;
|
||||
stopButton.IsDisabled = noMusic;
|
||||
|
||||
|
||||
var nextButton = panel.GetWidget<ButtonWidget>("BUTTON_NEXT");
|
||||
nextButton.OnClick = () => { currentSong = GetNextSong(); Play(); };
|
||||
nextButton.IsDisabled = noMusic;
|
||||
|
||||
|
||||
var prevButton = panel.GetWidget<ButtonWidget>("BUTTON_PREV");
|
||||
prevButton.OnClick = () => { currentSong = GetPrevSong(); Play(); };
|
||||
prevButton.IsDisabled = noMusic;
|
||||
|
||||
|
||||
var shuffleCheckbox = panel.GetWidget<CheckboxWidget>("SHUFFLE");
|
||||
shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle;
|
||||
shuffleCheckbox.OnClick = () => Game.Settings.Sound.Shuffle ^= true;
|
||||
|
||||
|
||||
var repeatCheckbox = panel.GetWidget<CheckboxWidget>("REPEAT");
|
||||
repeatCheckbox.IsChecked = () => Game.Settings.Sound.Repeat;
|
||||
repeatCheckbox.OnClick = () => Game.Settings.Sound.Repeat ^= true;
|
||||
|
||||
panel.GetWidget<LabelWidget>("TIME_LABEL").GetText = () => (currentSong == null) ? "" :
|
||||
panel.GetWidget<LabelWidget>("TIME_LABEL").GetText = () => (currentSong == null) ? "" :
|
||||
"{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60,
|
||||
currentSong.Length / 60, currentSong.Length % 60);
|
||||
panel.GetWidget<LabelWidget>("TITLE_LABEL").GetText = () => (currentSong == null) ? "" : currentSong.Title;
|
||||
|
||||
|
||||
var musicSlider = panel.GetWidget<SliderWidget>("MUSIC_SLIDER");
|
||||
musicSlider.OnChange += x => Sound.MusicVolume = x;
|
||||
musicSlider.Value = Sound.MusicVolume;
|
||||
}
|
||||
|
||||
|
||||
void BuildMusicTable(Widget list)
|
||||
{
|
||||
music = Rules.Music.Where(a => a.Value.Exists).Select(a => a.Value).ToArray();
|
||||
random = music.Shuffle(Game.CosmeticRandom).ToArray();
|
||||
|
||||
|
||||
list.RemoveChildren();
|
||||
foreach (var s in music)
|
||||
{
|
||||
var song = s;
|
||||
if (currentSong == null)
|
||||
currentSong = song;
|
||||
|
||||
|
||||
var item = ScrollItemWidget.Setup(itemTemplate, () => currentSong == song, () => { currentSong = song; Play(); });
|
||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => song.Title;
|
||||
item.GetWidget<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
|
||||
list.AddChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Play()
|
||||
{
|
||||
if (currentSong == null)
|
||||
return;
|
||||
|
||||
|
||||
Sound.PlayMusicThen(currentSong, () =>
|
||||
{
|
||||
if (!Game.Settings.Sound.Repeat)
|
||||
currentSong = GetNextSong();
|
||||
Play();
|
||||
});
|
||||
|
||||
|
||||
panel.GetWidget("BUTTON_PLAY").Visible = false;
|
||||
panel.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||
}
|
||||
|
||||
|
||||
void Pause()
|
||||
{
|
||||
Sound.PauseMusic();
|
||||
panel.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||
panel.GetWidget("BUTTON_PLAY").Visible = true;
|
||||
}
|
||||
|
||||
|
||||
void Stop()
|
||||
{
|
||||
Sound.StopMusic();
|
||||
panel.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||
panel.GetWidget("BUTTON_PLAY").Visible = true;
|
||||
panel.GetWidget("BUTTON_PLAY").Visible = true;
|
||||
}
|
||||
|
||||
|
||||
string SongLengthLabel(MusicInfo song)
|
||||
{
|
||||
return "{0:D1}:{1:D2}".F(song.Length / 60, song.Length % 60);
|
||||
}
|
||||
|
||||
|
||||
MusicInfo GetNextSong()
|
||||
{
|
||||
if (!music.Any())
|
||||
return null;
|
||||
|
||||
|
||||
var songs = Game.Settings.Sound.Shuffle ? random : music;
|
||||
return songs.SkipWhile(m => m != currentSong)
|
||||
.Skip(1).FirstOrDefault() ?? songs.FirstOrDefault();
|
||||
@@ -177,14 +177,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
{
|
||||
if (!music.Any())
|
||||
return null;
|
||||
|
||||
|
||||
var songs = Game.Settings.Sound.Shuffle ? random : music;
|
||||
return songs.Reverse().SkipWhile(m => m != currentSong)
|
||||
.Skip(1).FirstOrDefault() ?? songs.Reverse().FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class CncInstallMusicLogic
|
||||
{
|
||||
Widget panel;
|
||||
@@ -193,7 +193,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Action afterInstall;
|
||||
ButtonWidget retryButton, backButton;
|
||||
Widget installingContainer, insertDiskContainer;
|
||||
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public CncInstallMusicLogic([ObjectCreator.Param] Widget widget,
|
||||
[ObjectCreator.Param] Action afterInstall)
|
||||
@@ -202,18 +202,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
panel = widget.GetWidget("INSTALL_MUSIC_PANEL");
|
||||
progressBar = panel.GetWidget<ProgressBarWidget>("PROGRESS_BAR");
|
||||
statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL");
|
||||
|
||||
|
||||
backButton = panel.GetWidget<ButtonWidget>("BACK_BUTTON");
|
||||
backButton.OnClick = Widget.CloseWindow;
|
||||
|
||||
|
||||
retryButton = panel.GetWidget<ButtonWidget>("RETRY_BUTTON");
|
||||
retryButton.OnClick = CheckForDisk;
|
||||
|
||||
|
||||
installingContainer = panel.GetWidget("INSTALLING");
|
||||
insertDiskContainer = panel.GetWidget("INSERT_DISK");
|
||||
CheckForDisk();
|
||||
}
|
||||
|
||||
|
||||
void CheckForDisk()
|
||||
{
|
||||
Func<string, bool> ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"CONQUER.MIX") &&
|
||||
@@ -230,7 +230,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
installingContainer.IsVisible = () => false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Install(string source)
|
||||
{
|
||||
backButton.IsDisabled = () => true;
|
||||
@@ -240,34 +240,34 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
|
||||
var dest = new string[] { Platform.SupportDir, "Content", "cnc" }.Aggregate(Path.Combine);
|
||||
var copyFiles = new string[] { "SCORES.MIX" };
|
||||
|
||||
|
||||
var extractPackage = "INSTALL/SETUP.Z";
|
||||
var extractFiles = new string[] { "transit.mix" };
|
||||
|
||||
|
||||
var installCounter = 0;
|
||||
var installTotal = copyFiles.Count() + extractFiles.Count();
|
||||
var onProgress = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||
var onProgress = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||
{
|
||||
progressBar.Percentage = installCounter*100/installTotal;
|
||||
installCounter++;
|
||||
|
||||
|
||||
statusLabel.GetText = () => s;
|
||||
}));
|
||||
|
||||
var onError = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||
|
||||
var onError = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||
{
|
||||
statusLabel.GetText = () => "Error: "+s;
|
||||
backButton.IsDisabled = () => false;
|
||||
retryButton.IsDisabled = () => false;
|
||||
}));
|
||||
|
||||
|
||||
var t = new Thread( _ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!InstallUtils.CopyFiles(source, copyFiles, dest, onProgress, onError))
|
||||
return;
|
||||
|
||||
|
||||
if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError))
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user