Prototype new music player
This commit is contained in:
@@ -16,7 +16,7 @@ namespace OpenRA.GameRules
|
||||
{
|
||||
public readonly string Filename = null;
|
||||
public readonly string Title = null;
|
||||
public readonly float Length = 0; // seconds
|
||||
public readonly int Length = 0; // seconds
|
||||
|
||||
public MusicInfo( string key, MiniYaml value )
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using System.Drawing;
|
||||
using OpenRA.Support;
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
@@ -61,6 +63,44 @@ namespace OpenRA.Widgets.Delegates
|
||||
CurrentSong = GetPrevSong();
|
||||
return bg.GetWidget("BUTTON_PLAY").OnMouseUp(mi);
|
||||
};
|
||||
|
||||
bg.GetWidget<LabelWidget>("TIME").GetText = () => "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F(0,0,Rules.Music[CurrentSong].Length / 60, Rules.Music[CurrentSong].Length % 60);
|
||||
|
||||
var ml = bg.GetWidget<ListBoxWidget>("MUSIC_LIST");
|
||||
var itemTemplate = ml.GetWidget<LabelWidget>("MUSIC_TEMPLATE");
|
||||
int offset = itemTemplate.Bounds.Y;
|
||||
|
||||
foreach (var kv in Rules.Music)
|
||||
{
|
||||
var song = kv.Key;
|
||||
if (!FileSystem.Exists(Rules.Music[song].Filename))
|
||||
continue;
|
||||
|
||||
if (CurrentSong == null)
|
||||
CurrentSong = song;
|
||||
|
||||
var template = itemTemplate.Clone() as LabelWidget;
|
||||
template.Id = "SONG_{0}".F(song);
|
||||
template.GetBackground = () => ((song == CurrentSong) ? "dialog2" : null);
|
||||
template.OnMouseDown = mi =>
|
||||
{
|
||||
CurrentSong = song;
|
||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp(mi);
|
||||
return true;
|
||||
};
|
||||
template.Parent = ml;
|
||||
|
||||
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
template.IsVisible = () => true;
|
||||
|
||||
template.GetWidget<LabelWidget>("TITLE").GetText = () => " " + Rules.Music[song].Title;
|
||||
template.GetWidget<LabelWidget>("LENGTH").GetText = () => "{0:D2}:{1:D2}".F(Rules.Music[song].Length / 60, Rules.Music[song].Length % 60);
|
||||
|
||||
ml.AddChild(template);
|
||||
|
||||
offset += template.Bounds.Height;
|
||||
ml.ContentHeight += template.Bounds.Height;
|
||||
}
|
||||
}
|
||||
|
||||
string GetNextSong()
|
||||
|
||||
@@ -65,14 +65,6 @@ namespace OpenRA.Widgets.Delegates
|
||||
musicslider.OnChange += x => { Sound.MusicVolume = x; };
|
||||
musicslider.GetOffset = () => { return Sound.MusicVolume; };
|
||||
|
||||
var music = audio.GetWidget<CheckboxWidget>("MUSICPLAYER_CHECKBOX");
|
||||
music.Checked = () => { return Game.Settings.MusicPlayer; };
|
||||
music.OnMouseDown = mi =>
|
||||
{
|
||||
Game.Settings.MusicPlayer ^= true;
|
||||
Widget.RootWidget.GetWidget("MUSIC_BG").Visible = Game.Settings.MusicPlayer;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Display
|
||||
var display = bg.GetWidget("DISPLAY_PANE");
|
||||
|
||||
@@ -96,15 +96,14 @@ Background@PERF_BG:
|
||||
Background@MUSIC_BG:
|
||||
Id:MUSIC_BG
|
||||
Delegate:MusicPlayerDelegate
|
||||
X:WINDOW_RIGHT - 175
|
||||
Y:WINDOW_BOTTOM - 95
|
||||
Width: 160
|
||||
Height: 55
|
||||
X:WINDOW_RIGHT - WIDTH - 20
|
||||
Y:WINDOW_BOTTOM - HEIGHT - 20
|
||||
Width: 300
|
||||
Height: 210
|
||||
Visible: true
|
||||
Children:
|
||||
Button@BUTTON_PLAY:
|
||||
Id:BUTTON_PLAY
|
||||
Visible:false
|
||||
X:50
|
||||
Y:15
|
||||
Width:25
|
||||
@@ -120,6 +119,7 @@ Background@MUSIC_BG:
|
||||
ImageName:play
|
||||
Button@BUTTON_PAUSE:
|
||||
Id:BUTTON_PAUSE
|
||||
Visible:false
|
||||
X:50
|
||||
Y:15
|
||||
Width:25
|
||||
@@ -178,3 +178,52 @@ Background@MUSIC_BG:
|
||||
Height:25
|
||||
ImageCollection:music
|
||||
ImageName:prev
|
||||
Label@TIME:
|
||||
Id:TIME
|
||||
X:PARENT_RIGHT - WIDTH - 20
|
||||
Y:15
|
||||
Width:100
|
||||
Height:25
|
||||
Align: Right
|
||||
ListBox@MUSIC_LIST:
|
||||
Id:MUSIC_LIST
|
||||
X:10
|
||||
Y:50
|
||||
Width:280
|
||||
Height:120
|
||||
Children:
|
||||
Label@MUSIC_TEMPLATE:
|
||||
Id:MUSIC_TEMPLATE
|
||||
Width:PARENT_RIGHT-28
|
||||
Height:25
|
||||
ClickThrough:false
|
||||
X:2
|
||||
Y:0
|
||||
Visible:false
|
||||
Children:
|
||||
Label@TITLE:
|
||||
Id:TITLE
|
||||
X:5
|
||||
Width:PARENT_RIGHT - 10
|
||||
Height:PARENT_BOTTOM
|
||||
Align: Left
|
||||
Label@LENGTH:
|
||||
Id:LENGTH
|
||||
X:5
|
||||
Width:PARENT_RIGHT - 10
|
||||
Height:PARENT_BOTTOM
|
||||
Align: Right
|
||||
Checkbox@SHUFFLE:
|
||||
Id:SHUFFLE
|
||||
X:15
|
||||
Y:175
|
||||
Width:100
|
||||
Height:20
|
||||
Text:Shuffle
|
||||
Checkbox@REPEAT:
|
||||
Id:REPEAT
|
||||
X:120
|
||||
Y:175
|
||||
Width:100
|
||||
Height:20
|
||||
Text:Repeat
|
||||
@@ -123,13 +123,6 @@ Background@SETTINGS_MENU:
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Checkbox@MUSICPLAYER_CHECKBOX:
|
||||
Id:MUSICPLAYER_CHECKBOX
|
||||
X:0
|
||||
Y:70
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Music Player
|
||||
Container@DISPLAY_PANE:
|
||||
Id:DISPLAY_PANE
|
||||
X:37
|
||||
|
||||
Reference in New Issue
Block a user