Merge pull request #9387 from pchote/mission-gamespeed

Add game speed dropdown to the mission browser.
This commit is contained in:
Oliver Brakmann
2015-09-28 21:05:30 +02:00
10 changed files with 153 additions and 63 deletions

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly LabelWidget description; readonly LabelWidget description;
readonly SpriteFont descriptionFont; readonly SpriteFont descriptionFont;
readonly DropDownButtonWidget difficultyButton; readonly DropDownButtonWidget difficultyButton;
readonly DropDownButtonWidget gameSpeedButton;
readonly ButtonWidget startBriefingVideoButton; readonly ButtonWidget startBriefingVideoButton;
readonly ButtonWidget stopBriefingVideoButton; readonly ButtonWidget stopBriefingVideoButton;
readonly ButtonWidget startInfoVideoButton; readonly ButtonWidget startInfoVideoButton;
@@ -46,6 +47,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
PlayingVideo playingVideo; PlayingVideo playingVideo;
string difficulty; string difficulty;
string gameSpeed;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MissionBrowserLogic(Widget widget, World world, Action onStart, Action onExit) public MissionBrowserLogic(Widget widget, World world, Action onStart, Action onExit)
@@ -77,6 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
descriptionFont = Game.Renderer.Fonts[description.Font]; descriptionFont = Game.Renderer.Fonts[description.Font];
difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON"); difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
gameSpeedButton = widget.GetOrNull<DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON");
startBriefingVideoButton = widget.Get<ButtonWidget>("START_BRIEFING_VIDEO_BUTTON"); startBriefingVideoButton = widget.Get<ButtonWidget>("START_BRIEFING_VIDEO_BUTTON");
stopBriefingVideoButton = widget.Get<ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON"); stopBriefingVideoButton = widget.Get<ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON");
@@ -186,27 +189,57 @@ namespace OpenRA.Mods.Common.Widgets.Logic
descriptionPanel.ScrollToTop(); descriptionPanel.ScrollToTop();
descriptionPanel.Layout.AdjustChildren(); descriptionPanel.Layout.AdjustChildren();
difficultyButton.IsVisible = () => map.Options.Difficulties.Any(); if (difficultyButton != null)
if (!map.Options.Difficulties.Any())
return;
difficulty = map.Options.Difficulties.First();
difficultyButton.OnMouseDown = _ =>
{ {
var options = map.Options.Difficulties.Select(d => new DropDownOption difficultyButton.IsDisabled = () => !map.Options.Difficulties.Any();
difficulty = map.Options.Difficulties.FirstOrDefault();
difficultyButton.GetText = () => difficulty ?? "Normal";
difficultyButton.OnMouseDown = _ =>
{ {
Title = d, var options = map.Options.Difficulties.Select(d => new DropDownOption
IsSelected = () => difficulty == d, {
OnClick = () => difficulty = d Title = d,
}); IsSelected = () => difficulty == d,
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => OnClick = () => difficulty = d
{ });
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
item.Get<LabelWidget>("LABEL").GetText = () => option.Title; Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
return item; {
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
return item;
};
difficultyButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
}; };
difficultyButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }
};
if (gameSpeedButton != null)
{
var speeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
gameSpeed = "default";
gameSpeedButton.GetText = () => speeds[gameSpeed].Name;
gameSpeedButton.OnMouseDown = _ =>
{
var options = speeds.Select(s => new DropDownOption
{
Title = s.Value.Name,
IsSelected = () => gameSpeed == s.Key,
OnClick = () => gameSpeed = s.Key
});
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
{
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
return item;
};
gameSpeedButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
};
}
} }
float cachedSoundVolume; float cachedSoundVolume;
@@ -280,6 +313,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Action lobbyReady = null; Action lobbyReady = null;
lobbyReady = () => lobbyReady = () =>
{ {
om.IssueOrder(Order.Command("gamespeed {0}".F(gameSpeed)));
om.IssueOrder(Order.Command("difficulty {0}".F(difficulty))); om.IssueOrder(Order.Command("difficulty {0}".F(difficulty)));
Game.LobbyInfoChanged -= lobbyReady; Game.LobbyInfoChanged -= lobbyReady;
onStart(); onStart();

View File

@@ -21,7 +21,7 @@ Container@MISSIONBROWSER_PANEL:
X: 15 X: 15
Y: 15 Y: 15
Width: 239 Width: 239
Height: 307 Height: 347
Children: Children:
ScrollItem@HEADER: ScrollItem@HEADER:
Width: PARENT_RIGHT-27 Width: PARENT_RIGHT-27
@@ -66,7 +66,7 @@ Container@MISSIONBROWSER_PANEL:
ScrollPanel@MISSION_DESCRIPTION_PANEL: ScrollPanel@MISSION_DESCRIPTION_PANEL:
Y: 213 Y: 213
Width: PARENT_RIGHT Width: PARENT_RIGHT
Height: 134 Height: 99
Children: Children:
Label@MISSION_DESCRIPTION: Label@MISSION_DESCRIPTION:
X: 4 X: 4
@@ -74,13 +74,31 @@ Container@MISSIONBROWSER_PANEL:
Width: PARENT_RIGHT - 32 Width: PARENT_RIGHT - 32
VAlign: Top VAlign: Top
Font: Small Font: Small
DropDownButton@DIFFICULTY_DROPDOWNBUTTON: Label@DIFFICULTY_DESC:
X: 15 Y: 322
Y: 337 Width: 56
Width: 239 Height: 25
Height: 25 Text: Difficulty:
Text: Difficulty Align: Right
Font: Regular DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
X: 61
Y: 322
Width: 120
Height: 25
Font: Regular
Label@GAMESPEED_DESC:
X: PARENT_RIGHT - WIDTH - 125
Y: 322
Width: 120
Height: 25
Text: Speed:
Align: Right
DropDownButton@GAMESPEED_DROPDOWNBUTTON:
X: PARENT_RIGHT - WIDTH
Y: 322
Width: 120
Height: 25
Font: Regular
Button@BACK_BUTTON: Button@BACK_BUTTON:
Y: 376 Y: 376
Width: 140 Width: 140

View File

@@ -223,7 +223,7 @@ GameSpeeds:
Timestep: 50 Timestep: 50
OrderLatency: 3 OrderLatency: 3
default: default:
Name: Default Name: Normal
Timestep: 40 Timestep: 40
OrderLatency: 3 OrderLatency: 3
faster: faster:

View File

@@ -2,8 +2,8 @@ Background@MISSIONBROWSER_PANEL:
Logic: MissionBrowserLogic Logic: MissionBrowserLogic
X: (WINDOW_RIGHT - WIDTH)/2 X: (WINDOW_RIGHT - WIDTH)/2
Y: (WINDOW_BOTTOM - HEIGHT)/2 Y: (WINDOW_BOTTOM - HEIGHT)/2
Width: 960 Width: 880
Height: 690 Height: 591
Children: Children:
Label@MISSIONBROWSER_TITLE: Label@MISSIONBROWSER_TITLE:
Y: 20 Y: 20
@@ -15,8 +15,8 @@ Background@MISSIONBROWSER_PANEL:
ScrollPanel@MISSION_LIST: ScrollPanel@MISSION_LIST:
X: 20 X: 20
Y: 50 Y: 50
Width: 270 Width: 190
Height: 542 Height: 405
Children: Children:
ScrollItem@HEADER: ScrollItem@HEADER:
BaseName: scrollheader BaseName: scrollheader
@@ -39,15 +39,41 @@ Background@MISSIONBROWSER_PANEL:
X: 10 X: 10
Width: PARENT_RIGHT-20 Width: PARENT_RIGHT-20
Height: 25 Height: 25
Label@DIFFICULTY_DESC:
X: 210 - WIDTH - 125
Y: 468
Width: 56
Height: 25
Text: Difficulty:
Align: Right
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
X: 210 - WIDTH
Y: 468
Width: 120
Height: 25
Font: Regular
Label@GAMESPEED_DESC:
X: 210 - WIDTH - 125
Y: 508
Width: 120
Height: 25
Text: Speed:
Align: Right
DropDownButton@GAMESPEED_DROPDOWNBUTTON:
X: 210 - WIDTH
Y: 508
Width: 120
Height: 25
Font: Regular
Container@MISSION_INFO: Container@MISSION_INFO:
X: 300 X: 220
Y: 50 Y: 50
Width: 642 Width: 642
Height: 800 Height: 800
Children: Children:
Background@MISSION_BG: Background@MISSION_BG:
Width: PARENT_RIGHT Width: PARENT_RIGHT
Height: 402 Height: 327
Background: dialog3 Background: dialog3
Children: Children:
MapPreview@MISSION_PREVIEW: MapPreview@MISSION_PREVIEW:
@@ -59,9 +85,9 @@ Background@MISSIONBROWSER_PANEL:
IgnoreMouseInput: True IgnoreMouseInput: True
ShowSpawnPoints: False ShowSpawnPoints: False
ScrollPanel@MISSION_DESCRIPTION_PANEL: ScrollPanel@MISSION_DESCRIPTION_PANEL:
Y: 412 Y: 337
Width: PARENT_RIGHT Width: PARENT_RIGHT
Height: 170 Height: 146
Children: Children:
Label@MISSION_DESCRIPTION: Label@MISSION_DESCRIPTION:
X: 4 X: 4
@@ -70,28 +96,28 @@ Background@MISSIONBROWSER_PANEL:
VAlign: Top VAlign: Top
Font: Small Font: Small
Button@START_BRIEFING_VIDEO_BUTTON: Button@START_BRIEFING_VIDEO_BUTTON:
X: 20 X: 220
Y: PARENT_BOTTOM - 45 Y: PARENT_BOTTOM - 45
Width: 130 Width: 130
Height: 25 Height: 25
Text: Watch Briefing Text: Watch Briefing
Font: Bold Font: Bold
Button@STOP_BRIEFING_VIDEO_BUTTON: Button@STOP_BRIEFING_VIDEO_BUTTON:
X: 20 X: 220
Y: PARENT_BOTTOM - 45 Y: PARENT_BOTTOM - 45
Width: 130 Width: 130
Height: 25 Height: 25
Text: Stop Briefing Text: Stop Briefing
Font: Bold Font: Bold
Button@START_INFO_VIDEO_BUTTON: Button@START_INFO_VIDEO_BUTTON:
X: 160 X: 360
Y: PARENT_BOTTOM - 45 Y: PARENT_BOTTOM - 45
Width: 130 Width: 130
Height: 25 Height: 25
Text: Watch Info Video Text: Watch Info Video
Font: Bold Font: Bold
Button@STOP_INFO_VIDEO_BUTTON: Button@STOP_INFO_VIDEO_BUTTON:
X: 160 X: 360
Y: PARENT_BOTTOM - 45 Y: PARENT_BOTTOM - 45
Width: 130 Width: 130
Height: 25 Height: 25
@@ -112,26 +138,19 @@ Background@MISSIONBROWSER_PANEL:
Text: Back Text: Back
Font: Bold Font: Bold
Key: escape Key: escape
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
X: 20
Y: 632 - HEIGHT
Width: 270
Height: 25
Text: Difficulty
Font: Bold
Background@MISSION_BIN: Background@MISSION_BIN:
X: 300 X: 220
Y: 50 Y: 50
Width: 642 Width: 642
Height: 402 Height: 483
Background: dialog3 Background: dialog3
Children: Children:
VqaPlayer@MISSION_VIDEO: VqaPlayer@MISSION_VIDEO:
X: 1 X: 1
Y: 1 Y: 1
Width: 640 Width: 640
Height: 400 Height: 480
AspectRatio: 1 AspectRatio: 1.2
DrawOverlay: False DrawOverlay: False
Background@FULLSCREEN_PLAYER: Background@FULLSCREEN_PLAYER:
Width: WINDOW_RIGHT Width: WINDOW_RIGHT

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 73 KiB

View File

@@ -199,7 +199,7 @@ GameSpeeds:
Timestep: 50 Timestep: 50
OrderLatency: 3 OrderLatency: 3
default: default:
Name: Default Name: Normal
Timestep: 40 Timestep: 40
OrderLatency: 3 OrderLatency: 3
faster: faster:

View File

@@ -16,7 +16,7 @@ Background@MISSIONBROWSER_PANEL:
X: 20 X: 20
Y: 50 Y: 50
Width: 270 Width: 270
Height: 332 Height: 377
Children: Children:
ScrollItem@HEADER: ScrollItem@HEADER:
BaseName: scrollheader BaseName: scrollheader
@@ -61,7 +61,7 @@ Background@MISSIONBROWSER_PANEL:
ScrollPanel@MISSION_DESCRIPTION_PANEL: ScrollPanel@MISSION_DESCRIPTION_PANEL:
Y: 212 Y: 212
Width: PARENT_RIGHT Width: PARENT_RIGHT
Height: 165 Height: 130
Children: Children:
Label@MISSION_DESCRIPTION: Label@MISSION_DESCRIPTION:
X: 4 X: 4
@@ -69,6 +69,32 @@ Background@MISSIONBROWSER_PANEL:
Width: PARENT_RIGHT - 32 Width: PARENT_RIGHT - 32
VAlign: Top VAlign: Top
Font: Small Font: Small
Label@DIFFICULTY_DESC:
Y: 352
Width: 56
Height: 25
Text: Difficulty:
Align: Right
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
X: 61
Y: 352
Width: 120
Height: 25
Font: Regular
Label@GAMESPEED_DESC:
X: PARENT_RIGHT - WIDTH - 125
Y: 352
Width: 120
Height: 25
Text: Speed:
Align: Right
DropDownButton@GAMESPEED_DROPDOWNBUTTON:
X: PARENT_RIGHT - WIDTH
Y: 352
Width: 120
Height: 25
Font: Regular
Button@START_BRIEFING_VIDEO_BUTTON: Button@START_BRIEFING_VIDEO_BUTTON:
X: 20 X: 20
Y: PARENT_BOTTOM - 45 Y: PARENT_BOTTOM - 45
@@ -112,13 +138,6 @@ Background@MISSIONBROWSER_PANEL:
Text: Back Text: Back
Font: Bold Font: Bold
Key: escape Key: escape
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
X: 20
Y: 427 - HEIGHT
Width: 270
Height: 25
Text: Difficulty
Font: Bold
Background@MISSION_BIN: Background@MISSION_BIN:
X: 20 X: 20
Y: 50 Y: 50

View File

@@ -222,7 +222,7 @@ GameSpeeds:
Timestep: 50 Timestep: 50
OrderLatency: 3 OrderLatency: 3
default: default:
Name: Default Name: Normal
Timestep: 40 Timestep: 40
OrderLatency: 3 OrderLatency: 3
faster: faster:

View File

@@ -263,7 +263,7 @@ GameSpeeds:
Timestep: 50 Timestep: 50
OrderLatency: 3 OrderLatency: 3
default: default:
Name: Default Name: Normal
Timestep: 40 Timestep: 40
OrderLatency: 3 OrderLatency: 3
faster: faster: