Enable music player

This commit is contained in:
Paul Chote
2010-09-10 19:45:22 +12:00
parent b0e5bb3718
commit ca32d51375
6 changed files with 359 additions and 131 deletions

View File

@@ -19,10 +19,20 @@ namespace OpenRA.Widgets.Delegates
string CurrentSong = null;
public MusicPlayerDelegate()
{
var bg = Widget.RootWidget.GetWidget("MUSIC_BG");
//bg.Visible = Game.Settings.MusicPlayer;
var bg = Widget.RootWidget.GetWidget("MUSIC_MENU");
CurrentSong = GetNextSong();
bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => {
Game.Settings.Save();
Widget.RootWidget.CloseWindow();
return true;
};
Widget.RootWidget.GetWidget("MAINMENU_BUTTON_MUSIC").OnMouseUp = mi => {
Widget.RootWidget.OpenWindow("MUSIC_MENU");
return true;
};
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi =>
{
if (CurrentSong == null)
@@ -64,8 +74,13 @@ namespace OpenRA.Widgets.Delegates
return bg.GetWidget("BUTTON_PLAY").OnMouseUp(mi);
};
bg.GetWidget<LabelWidget>("TIME").GetText = () => "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60,
bg.GetWidget<LabelWidget>("TIME").GetText = () =>
{
if (CurrentSong == null)
return "";
return "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60,
Rules.Music[CurrentSong].Length / 60, Rules.Music[CurrentSong].Length % 60);
};
var ml = bg.GetWidget<ListBoxWidget>("MUSIC_LIST");
var itemTemplate = ml.GetWidget<LabelWidget>("MUSIC_TEMPLATE");

View File

@@ -29,30 +29,35 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
return true;
};
optionsBG.GetWidget("BUTTON_DISCONNECT").OnMouseUp = mi => {
optionsBG.GetWidget("DISCONNECT").OnMouseUp = mi => {
optionsBG.Visible = false;
Game.Disconnect();
return true;
};
optionsBG.GetWidget("BUTTON_SETTINGS").OnMouseUp = mi => {
optionsBG.GetWidget("SETTINGS").OnMouseUp = mi => {
r.OpenWindow("SETTINGS_MENU");
return true;
};
optionsBG.GetWidget("BUTTON_RESUME").OnMouseUp = mi =>
optionsBG.GetWidget("MUSIC").OnMouseUp = mi => {
r.OpenWindow("MUSIC_MENU");
return true;
};
optionsBG.GetWidget("RESUME").OnMouseUp = mi =>
{
optionsBG.Visible = false;
return true;
};
optionsBG.GetWidget("BUTTON_SURRENDER").OnMouseUp = mi =>
optionsBG.GetWidget("SURRENDER").OnMouseUp = mi =>
{
Game.IssueOrder(new Order("Surrender", Game.world.LocalPlayer.PlayerActor));
return true;
};
optionsBG.GetWidget("BUTTON_QUIT").OnMouseUp = mi => {
optionsBG.GetWidget("QUIT").OnMouseUp = mi => {
Game.Exit();
return true;
};

View File

@@ -110,7 +110,7 @@ Container@INGAME_ROOT:
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:300
Height:280
Height:320
Visible:false
Children:
Label@LABEL_TITLE:
@@ -122,44 +122,52 @@ Container@INGAME_ROOT:
Text:Options
Align:Center
Bold:True
Button@BUTTON_RESUME:
Id:BUTTON_RESUME
Button@RESUME:
Id:RESUME
X:(PARENT_RIGHT - WIDTH)/2
Y:60
Width:160
Height:25
Text:Resume
Bold:True
Button@BUTTON_SURRENDER:
Id:BUTTON_SURRENDER
Button@SETTINGS:
Id:SETTINGS
X:(PARENT_RIGHT - WIDTH)/2
Y:100
Width:160
Height:25
Text:Surrender
Text:Settings
Bold:True
Button@BUTTON_SETTINGS:
Id:BUTTON_SETTINGS
Button@MUSIC:
Id:MUSIC
X:(PARENT_RIGHT - WIDTH)/2
Y:140
Width:160
Height:25
Text:Settings
Text:Music
Bold:True
Button@BUTTON_DISCONNECT:
Id:BUTTON_DISCONNECT
Button@SURRENDER:
Id:SURRENDER
X:(PARENT_RIGHT - WIDTH)/2
Y:180
Width:160
Height:25
Text:Disconnect
Text:Surrender
Bold:True
Button@BUTTON_QUIT:
Id:BUTTON_QUIT
Button@DISCONNECT:
Id:DISCONNECT
X:(PARENT_RIGHT - WIDTH)/2
Y:220
Width:160
Height:25
Text:Disconnect
Bold:True
Button@QUIT:
Id:QUIT
X:(PARENT_RIGHT - WIDTH)/2
Y:260
Width:160
Height:25
Text:Quit
Bold:True
Background@DIPLOMACY_BG:

View File

@@ -3,7 +3,7 @@ Background@MAINMENU_BG:
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:250
Height:250
Height:290
Delegate:MainMenuButtonsDelegate
Children:
Label@MAINMENU_LABEL_TITLE:
@@ -39,10 +39,18 @@ Background@MAINMENU_BG:
Height:25
Text:Settings
Bold:True
Button@MAINMENU_BUTTON_MUSIC:
Id:MAINMENU_BUTTON_MUSIC
X:45
Y:190
Width:160
Height:25
Text:Music
Bold:True
Button@MAINMENU_BUTTON_QUIT:
Id:MAINMENU_BUTTON_QUIT
X:45
Y:190
Y:230
Width:160
Height:25
Text:Quit
@@ -51,7 +59,7 @@ Background@MAINMENU_BG:
Id:MAINMENU_BUTTON_VIDEOPLAYER
Visible:false
X:45
Y:230
Y:260
Width:160
Height:25
Text:Video Player
@@ -88,3 +96,158 @@ Background@PERF_BG:
Y:205
Width:170
Height:40
Background@MUSIC_MENU:
Id:MUSIC_MENU
Delegate:MusicPlayerDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width: 450
Height: 250
Visible: false
Children:
Label@SETTINGS_LABEL_TITLE:
Id:SETTINGS_LABEL_TITLE
X:0
Y:20
Width:450
Height:25
Text:Music
Align:Center
Bold:True
Button@BUTTON_CLOSE:
Id:BUTTON_CLOSE
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Close
Bold:True
Container@BUTTONS:
X:PARENT_RIGHT - 150
Y:50
Children:
Button@BUTTON_PLAY:
Id:BUTTON_PLAY
X:35
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PLAY:
Id:IMAGE_PLAY
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:play
Button@BUTTON_PAUSE:
Id:BUTTON_PAUSE
Visible:false
X:35
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PAUSE:
Id:IMAGE_PAUSE
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:pause
Button@BUTTON_STOP:
Id:BUTTON_STOP
X:70
Y:0
Width:25
Height:25
Children:
Image@IMAGE_STOP:
Id:IMAGE_STOP
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:stop
Button@BUTTON_NEXT:
Id:BUTTON_NEXT
X:105
Y:0
Width:25
Height:25
Children:
Image@IMAGE_NEXT:
Id:IMAGE_NEXT
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:next
Button@BUTTON_PREV:
Id:BUTTON_PREV
X:0
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PREV:
Id:IMAGE_PREV
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:prev
Label@TIME:
Id:TIME
X:PARENT_RIGHT - 150
Y:75
Width:140
Height:25
Align: Center
ListBox@MUSIC_LIST:
Id:MUSIC_LIST
X:10
Y:50
Width:280
Height:140
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:PARENT_RIGHT - 150
Y:110
Width:100
Height:20
Text:Shuffle
Checkbox@REPEAT:
Id:REPEAT
X:PARENT_RIGHT - 150
Y:140
Width:100
Height:20
Text:Repeat

View File

@@ -119,7 +119,7 @@ Container@INGAME_ROOT:
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:300
Height:280
Height:320
Visible:false
Children:
Label@LABEL_TITLE:
@@ -131,44 +131,52 @@ Container@INGAME_ROOT:
Text:Options
Align:Center
Bold:True
Button@BUTTON_RESUME:
Id:BUTTON_RESUME
Button@RESUME:
Id:RESUME
X:(PARENT_RIGHT - WIDTH)/2
Y:60
Width:160
Height:25
Text:Resume
Bold:True
Button@BUTTON_SURRENDER:
Id:BUTTON_SURRENDER
Button@SETTINGS:
Id:SETTINGS
X:(PARENT_RIGHT - WIDTH)/2
Y:100
Width:160
Height:25
Text:Surrender
Text:Settings
Bold:True
Button@BUTTON_SETTINGS:
Id:BUTTON_SETTINGS
Button@MUSIC:
Id:MUSIC
X:(PARENT_RIGHT - WIDTH)/2
Y:140
Width:160
Height:25
Text:Settings
Text:Music
Bold:True
Button@BUTTON_DISCONNECT:
Id:BUTTON_DISCONNECT
Button@SURRENDER:
Id:SURRENDER
X:(PARENT_RIGHT - WIDTH)/2
Y:180
Width:160
Height:25
Text:Disconnect
Text:Surrender
Bold:True
Button@BUTTON_QUIT:
Id:BUTTON_QUIT
Button@DISCONNECT:
Id:DISCONNECT
X:(PARENT_RIGHT - WIDTH)/2
Y:220
Width:160
Height:25
Text:Disconnect
Bold:True
Button@QUIT:
Id:QUIT
X:(PARENT_RIGHT - WIDTH)/2
Y:260
Width:160
Height:25
Text:Quit
Bold:True
Background@DIPLOMACY_BG:

View File

@@ -3,7 +3,7 @@ Background@MAINMENU_BG:
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:250
Height:250
Height:290
Delegate:MainMenuButtonsDelegate
Children:
Label@MAINMENU_LABEL_TITLE:
@@ -39,10 +39,18 @@ Background@MAINMENU_BG:
Height:25
Text:Settings
Bold:True
Button@MAINMENU_BUTTON_MUSIC:
Id:MAINMENU_BUTTON_MUSIC
X:45
Y:190
Width:160
Height:25
Text:Music
Bold:True
Button@MAINMENU_BUTTON_QUIT:
Id:MAINMENU_BUTTON_QUIT
X:45
Y:190
Y:230
Width:160
Height:25
Text:Quit
@@ -51,7 +59,7 @@ Background@MAINMENU_BG:
Id:MAINMENU_BUTTON_VIDEOPLAYER
Visible:false
X:45
Y:230
Y:260
Width:160
Height:25
Text:Video Player
@@ -88,19 +96,40 @@ Background@PERF_BG:
Y:205
Width:170
Height:40
Background@MUSIC_BG:
Id:MUSIC_BG
Background@MUSIC_MENU:
Id:MUSIC_MENU
Delegate:MusicPlayerDelegate
X:WINDOW_RIGHT - WIDTH - 20
Y:WINDOW_BOTTOM - HEIGHT - 20
Width: 300
Height: 210
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width: 450
Height: 250
Visible: false
Children:
Label@SETTINGS_LABEL_TITLE:
Id:SETTINGS_LABEL_TITLE
X:0
Y:20
Width:450
Height:25
Text:Music
Align:Center
Bold:True
Button@BUTTON_CLOSE:
Id:BUTTON_CLOSE
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Close
Bold:True
Container@BUTTONS:
X:PARENT_RIGHT - 150
Y:50
Children:
Button@BUTTON_PLAY:
Id:BUTTON_PLAY
X:50
Y:15
X:35
Y:0
Width:25
Height:25
Children:
@@ -115,8 +144,8 @@ Background@MUSIC_BG:
Button@BUTTON_PAUSE:
Id:BUTTON_PAUSE
Visible:false
X:50
Y:15
X:35
Y:0
Width:25
Height:25
Children:
@@ -130,8 +159,8 @@ Background@MUSIC_BG:
ImageName:pause
Button@BUTTON_STOP:
Id:BUTTON_STOP
X:85
Y:15
X:70
Y:0
Width:25
Height:25
Children:
@@ -145,8 +174,8 @@ Background@MUSIC_BG:
ImageName:stop
Button@BUTTON_NEXT:
Id:BUTTON_NEXT
X:120
Y:15
X:105
Y:0
Width:25
Height:25
Children:
@@ -160,8 +189,8 @@ Background@MUSIC_BG:
ImageName:next
Button@BUTTON_PREV:
Id:BUTTON_PREV
X:15
Y:15
X:0
Y:0
Width:25
Height:25
Children:
@@ -175,17 +204,17 @@ Background@MUSIC_BG:
ImageName:prev
Label@TIME:
Id:TIME
X:PARENT_RIGHT - WIDTH - 20
Y:15
Width:100
X:PARENT_RIGHT - 150
Y:75
Width:140
Height:25
Align: Right
Align: Center
ListBox@MUSIC_LIST:
Id:MUSIC_LIST
X:10
Y:50
Width:280
Height:120
Height:140
Children:
Label@MUSIC_TEMPLATE:
Id:MUSIC_TEMPLATE
@@ -210,15 +239,15 @@ Background@MUSIC_BG:
Align: Right
Checkbox@SHUFFLE:
Id:SHUFFLE
X:15
Y:175
X:PARENT_RIGHT - 150
Y:110
Width:100
Height:20
Text:Shuffle
Checkbox@REPEAT:
Id:REPEAT
X:120
Y:175
X:PARENT_RIGHT - 150
Y:140
Width:100
Height:20
Text:Repeat