Added: Missing IngameObserverChromeDelegate.cs file (for spectator)

Fixed: Some spectator gui issues (@ gamelobby.yaml / LobbyDelegate.cs)
This commit is contained in:
geckosoft
2010-11-01 03:35:55 +01:00
parent 030bd4b28d
commit 2fb72155eb
3 changed files with 102 additions and 2 deletions

View File

@@ -237,8 +237,8 @@ namespace OpenRA.Widgets.Delegates
if (slot.Spectator)
{
template = EmptySlotTemplateHost.Clone();
var btn = template.GetWidget<ButtonWidget>("JOIN");
var name = template.GetWidget<ButtonWidget>("NAME");
var btn = template.GetWidget<ButtonWidget>("JOIN");
btn.GetText = () => "Spectate in this slot";
name.GetText = () => s.Closed ? "Closed" : "Open";
name.OnMouseUp = _ =>
@@ -282,6 +282,12 @@ namespace OpenRA.Widgets.Delegates
template = EmptySlotTemplate.Clone();
var name = template.GetWidget<LabelWidget>("NAME");
name.GetText = () => s.Closed ? "Closed" : "Open";
if (slot.Spectator)
{
var btn = template.GetWidget<ButtonWidget>("JOIN");
btn.GetText = () => "Spectate in this slot";
}
}
var join = template.GetWidget<ButtonWidget>("JOIN");
@@ -384,6 +390,15 @@ namespace OpenRA.Widgets.Delegates
var status = template.GetWidget<CheckboxWidget>("STATUS");
status.Checked = () => c.State == Session.ClientState.Ready;
if (c.Index == orderManager.LocalClient.Index) status.OnMouseDown = CycleReady;
Session.Slot slot1 = slot;
color.IsVisible = () => !slot1.Spectator;
//colorBlock.IsVisible = () => !slot1.Spectator;
faction.IsVisible = () => !slot1.Spectator;
factionname.IsVisible = () => !slot1.Spectator;
factionflag.IsVisible = () => !slot1.Spectator;
team.IsVisible = () => !slot1.Spectator;
}
template.Id = "SLOT_{0}".F(s.Index);

View File

@@ -0,0 +1,85 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* 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 LICENSE.
*/
#endregion
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Delegates
{
public class IngameObserverChromeDelegate : IWidgetDelegate
{
[ObjectCreator.UseCtor]
public IngameObserverChromeDelegate([ObjectCreator.Param] World world)
{
var r = Widget.RootWidget;
var gameRoot = r.GetWidget("OBSERVER_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
r.GetWidget("INGAME_OPTIONS_BUTTON").OnMouseUp = mi => {
optionsBG.Visible = !optionsBG.Visible;
return true;
};
optionsBG.GetWidget("DISCONNECT").OnMouseUp = mi => {
optionsBG.Visible = false;
Game.Disconnect();
return true;
};
optionsBG.GetWidget("SETTINGS").OnMouseUp = mi => {
Widget.OpenWindow("SETTINGS_MENU");
return true;
};
optionsBG.GetWidget("MUSIC").OnMouseUp = mi => {
Widget.OpenWindow("MUSIC_MENU");
return true;
};
optionsBG.GetWidget("RESUME").OnMouseUp = mi =>
{
optionsBG.Visible = false;
return true;
};
/*
optionsBG.GetWidget("SURRENDER").OnMouseUp = mi =>
{
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor));
return true;
};
*/
optionsBG.GetWidget("SURRENDER").IsVisible = () => false;
optionsBG.GetWidget("QUIT").OnMouseUp = mi => {
Game.Exit();
return true;
};
Game.AddChatLine += gameRoot.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine;
/*
var postgameBG = gameRoot.GetWidget("POSTGAME_BG");
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
postgameBG.IsVisible = () =>
{
return world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
};
postgameText.GetText = () =>
{
if (world.LocalPlayer == null)
return "";
var state = world.LocalPlayer.WinState;
return (state == WinState.Undefined)? "" :
((state == WinState.Lost)? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
};*/
}
}
}

View File

@@ -157,7 +157,7 @@ Background@SERVER_LOBBY:
Bold: false
Checkbox@STATUS:
Id:STATUS
X:455
X:450
Y:2
Width:20
Height:20