fix trailing whitespace everywhere

This commit is contained in:
Chris Forbes
2011-09-25 14:37:12 +13:00
parent 0eb98ef3b5
commit 55036cd58c
596 changed files with 3194 additions and 3194 deletions

View File

@@ -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.
@@ -31,12 +31,12 @@ namespace OpenRA.Mods.Cnc
Undock,
Dragout
};
readonly Actor proc;
readonly Harvester harv;
readonly RenderUnit ru;
State state;
int2 startDock;
int2 endDock;
public HarvesterDockSequence(Actor self, Actor proc)
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc
startDock = self.Trait<IHasLocation>().PxPosition;
endDock = proc.Trait<IHasLocation>().PxPosition + new int2(-15,8);
}
public override Activity Tick(Actor self)
{
switch (state)

View File

@@ -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.
@@ -21,15 +21,15 @@ namespace OpenRA.Mods.Cnc
public string PlayerPalette = "player";
public object Create( ActorInitializer init ) { return new CncColorPickerPaletteModifier( this ); }
}
class CncColorPickerPaletteModifier : IPalette, IPaletteModifier
{
{
CncColorPickerPaletteModifierInfo Info;
PaletteFormat format;
public ColorRamp Ramp;
public CncColorPickerPaletteModifier(CncColorPickerPaletteModifierInfo info) { Info = info; }
public void InitPalette( WorldRenderer wr )
{
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()

View File

@@ -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.

View File

@@ -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.
@@ -18,19 +18,19 @@ namespace OpenRA.Mods.Cnc
public class CncMenuPaletteEffectInfo : ITraitInfo
{
public readonly int FadeLength = 10;
public object Create(ActorInitializer init) { return new CncMenuPaletteEffect(this); }
}
public class CncMenuPaletteEffect : IPaletteModifier, ITick
{
{
public enum EffectType { None, Black, Desaturated }
public readonly CncMenuPaletteEffectInfo Info;
int remainingFrames;
EffectType from = EffectType.Black;
EffectType to = EffectType.Black;
public CncMenuPaletteEffect(CncMenuPaletteEffectInfo info) { Info = info; }
public void Fade(EffectType type)
{
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Cnc
if (remainingFrames > 0)
remainingFrames--;
}
Color ColorForEffect(EffectType t, Color orig)
{
switch(t)
@@ -59,23 +59,23 @@ namespace OpenRA.Mods.Cnc
return orig;
}
}
public void AdjustPalette(Dictionary<string,Palette> palettes)
{
if (to == EffectType.None && remainingFrames == 0)
return;
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker", "shroud", "fog"};
foreach (var pal in palettes)
{
if (excludePalettes.Contains(pal.Key))
continue;
for (var x = 0; x < 256; x++)
{
var orig = pal.Value.GetColor(x);
var t = ColorForEffect(to, orig);
if (remainingFrames == 0)
pal.Value.SetColor(x, t);
else

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
class CncShellmapScriptInfo : TraitInfo<CncShellmapScript> { }
class CncShellmapScript: IWorldLoaded, ITick
{
{
Dictionary<string, Actor> Actors;
static int2 ViewportOrigin;
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self)
{
SetViewport();
if (ticks == 0)
{
LoopTrack(Actors["boat1"], Actors["tl1"].Location, Actors["tr1"].Location);
@@ -62,10 +62,10 @@ namespace OpenRA.Mods.RA
LoopTrack(Actors["lst2"], Actors["tl2"].Location, Actors["tr2"].Location);
LoopTrack(Actors["lst3"], Actors["tl2"].Location, Actors["tr2"].Location);
}
ticks++;
}
void CreateUnitsInTransport(Actor transport, string[] cargo)
{
var f = transport.Trait<IFacing>();
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA
new FacingInit( f.Facing ),
}));
}
void LoopTrack(Actor self, int2 left, int2 right)
{
var mobile = self.Trait<Mobile>();

View File

@@ -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.
@@ -23,31 +23,31 @@ namespace OpenRA.Mods.Cnc
class Gdi01ScriptInfo : TraitInfo<Gdi01Script>, Requires<LoadWidgetAtGameStartInfo> { }
class Gdi01Script: IWorldLoaded, ITick
{
{
Dictionary<string, Actor> Actors;
Dictionary<string, Player> Players;
public void WorldLoaded(World w)
{
Players = w.Players.ToDictionary(p => p.InternalName);
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
var b = w.Map.Bounds;
Game.MoveViewport(new int2(b.Left + b.Width/2, b.Top + b.Height/2));
Scripting.Media.PlayFMVFullscreen(w, "gdi1.vqa",
Scripting.Media.PlayFMVFullscreen(w, "gdi1.vqa",
() => Scripting.Media.PlayFMVFullscreen(w, "landing.vqa", () =>
{
Sound.PlayMusic(Rules.Music["aoi"]);
started = true;
}));
}
public void OnVictory(World w)
{
started = false;
Sound.PlayToPlayer(Players["GoodGuy"], "accom1.aud");
Players["GoodGuy"].WinState = WinState.Won;
Action afterFMV = () =>
{
Sound.StopMusic();
@@ -57,13 +57,13 @@ namespace OpenRA.Mods.Cnc
};
Game.RunAfterDelay(5000, () => Scripting.Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV));
}
public void OnLose(World w)
{
started = false;
Sound.PlayToPlayer(Players["GoodGuy"], "fail1.aud");
Players["GoodGuy"].WinState = WinState.Lost;
Action afterFMV = () =>
{
Sound.StopMusic();
@@ -73,16 +73,16 @@ namespace OpenRA.Mods.Cnc
};
Game.RunAfterDelay(5000, () => Scripting.Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV));
}
int ticks = 0;
bool started = false;
int lastBadCount = -1;
public void Tick(Actor self)
{
if (!started)
return;
if (ticks == 0)
{
SetGunboatPath();
@@ -113,61 +113,61 @@ namespace OpenRA.Mods.Cnc
{
Game.Debug("{0} badguys remain".F(badcount));
lastBadCount = badcount;
if (badcount == 0)
OnVictory(self.World);
}
//GoodGuy lose conditions: MCV/cyard must survive
var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
.Any( a => a.Actor.Owner == Players["GoodGuy"] );
if (!hasAnything)
OnLose(self.World);
// GoodGuy reinforcements
if (ticks == 25*5)
{
ReinforceFromSea(self.World,
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new string[] {"e1","e1","e1"},
Players["GoodGuy"]);
}
if (ticks == 25*15)
{
ReinforceFromSea(self.World,
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new string[] {"e1","e1","e1"},
Players["GoodGuy"]);
}
if (ticks == 25*30)
{
ReinforceFromSea(self.World,
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new string[] {"jeep"},
Players["GoodGuy"]);
}
if (ticks == 25*60)
{
ReinforceFromSea(self.World,
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new string[] {"jeep"},
Players["GoodGuy"]);
}
ticks++;
}
void SetGunboatPath()
{
var self = Actors[ "Gunboat" ];
@@ -176,14 +176,14 @@ namespace OpenRA.Mods.Cnc
self.QueueActivity(mobile.ScriptedMove( Actors["gunboatRight"].Location ));
self.QueueActivity(new CallFunc(() => SetGunboatPath()));
}
void ReinforceFromSea(World world, int2 startPos, int2 endPos, int2 unload, string[] items, Player player)
{
world.AddFrameEndTask(w =>
{
Sound.PlayToPlayer(w.LocalPlayer,"reinfor1.aud");
Sound.PlayToPlayer(w.LocalPlayer,"reinfor1.aud");
var a = w.CreateActor("lst", new TypeDictionary
var a = w.CreateActor("lst", new TypeDictionary
{
new LocationInit( startPos ),
new OwnerInit( player ),
@@ -198,7 +198,7 @@ namespace OpenRA.Mods.Cnc
new OwnerInit( player ),
new FacingInit( 0 ),
}));
a.CancelActivity();
a.QueueActivity(mobile.ScriptedMove(endPos));
a.QueueActivity(new CallFunc(() =>

View File

@@ -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.
@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc
{
class PoisonedByTiberiumInfo : ITraitInfo
{
{
[WeaponReference]
public readonly string Weapon = "Tiberium";
public readonly string[] Resources = { "Tiberium", "BlueTiberium" };

View File

@@ -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.
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc
public readonly string ReadyAudio = "reinfor1.aud";
public override object Create(ActorInitializer init) { return new ProductionAirdrop(this); }
}
class ProductionAirdrop : Production
{
public ProductionAirdrop(ProductionAirdropInfo info) : base(info) {}
@@ -31,34 +31,34 @@ namespace OpenRA.Mods.Cnc
public override bool Produce( Actor self, ActorInfo producee )
{
var owner = self.Owner;
// Start a fixed distance away: the width of the map.
// This makes the production timing indepent of spawnpoint
var startPos = self.Location + new int2(owner.World.Map.Bounds.Width, 0);
var endPos = new int2(owner.World.Map.Bounds.Left - 5, self.Location.Y);
// Assume a single exit point for simplicity
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
var rb = self.Trait<RenderBuilding>();
rb.PlayCustomAnimRepeating(self, "active");
owner.World.AddFrameEndTask(w =>
{
var a = w.CreateActor("C17", new TypeDictionary
var a = w.CreateActor("C17", new TypeDictionary
{
new LocationInit( startPos ),
new OwnerInit( owner ),
new FacingInit( 64 ),
new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
});
a.QueueActivity(Fly.ToCell(self.Location + new int2(6,0)));
a.QueueActivity(new Land(Target.FromActor(self)));
a.QueueActivity(new CallFunc(() =>
a.QueueActivity(new CallFunc(() =>
{
if (!self.IsInWorld || self.IsDead())
return;
rb.PlayCustomAnimRepeating(self, "idle");
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
Sound.PlayToPlayer(self.Owner, (Info as ProductionAirdropInfo).ReadyAudio);

View File

@@ -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.

View File

@@ -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.
@@ -12,7 +12,7 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Mods.Cnc")]
@@ -24,8 +24,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
@@ -35,11 +35,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]

View File

@@ -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.

View File

@@ -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.
@@ -19,18 +19,18 @@ namespace OpenRA.Mods.Cnc
{
public object Create(ActorInitializer init) { return new RenderCargo(init.self); }
}
public class RenderCargo : IRenderModifier
{
Cargo cargo;
IFacing facing;
public RenderCargo(Actor self)
{
cargo = self.Trait<Cargo>();
facing = self.TraitOrDefault<IFacing>();
}
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{
foreach (var c in cargo.Passengers)

View File

@@ -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.
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Render
}
base.Tick(self);
}
public void DamageStateChanged(Actor self, AttackInfo e)
{
if (e.DamageState >= DamageState.Critical)

View File

@@ -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.
@@ -21,31 +21,31 @@ namespace OpenRA.Mods.Cnc
public readonly int Probability = 10;
public readonly string Owner = "Creeps";
public readonly int InfDeath = 5;
public object Create(ActorInitializer init) { return new SpawnViceroid(this); }
}
class SpawnViceroid : INotifyKilled
{
readonly SpawnViceroidInfo Info;
public SpawnViceroid(SpawnViceroidInfo info)
{
Info = info;
}
public void Killed(Actor self, AttackInfo e)
{
if (e.Warhead != null && e.Warhead.InfDeath == Info.InfDeath
&& self.World.SharedRandom.Next(100) <= Info.Probability)
self.World.AddFrameEndTask(w =>
{
var td = new TypeDictionary
var td = new TypeDictionary
{
new LocationInit( self.Location ),
new OwnerInit( self.World.Players.First(p => p.InternalName == Info.Owner) )
};
if (self.HasTrait<IFacing>())
td.Add(new FacingInit( self.Trait<IFacing>().Facing ));
w.CreateActor(Info.ViceroidActor, td);

View File

@@ -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.
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Cnc
{
public TiberiumRefinery(Actor self, TiberiumRefineryInfo info)
: base(self, info as OreRefineryInfo) {}
public override Activity DockSequence(Actor harv, Actor self)
{
return new HarvesterDockSequence(harv, self);

View File

@@ -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.

View File

@@ -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.
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Cnc.Widgets
Keyboard = ScrollDirection.None;
return base.LoseFocus(mi);
}
public override bool HandleKeyPress(KeyInput e)
{
switch (e.KeyName)

View File

@@ -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.

View File

@@ -2,17 +2,17 @@
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -32,24 +32,24 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
[ObjectCreator.Param] World world)
{
var panel = widget.GetWidget("CHEATS_PANEL");
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
var shroudCheckbox = panel.GetWidget<CheckboxWidget>("SHROUD_CHECKBOX");
shroudCheckbox.IsChecked = () => devTrait.DisableShroud;
shroudCheckbox.OnClick = () => Order(world, "DevShroud");
var pathCheckbox = panel.GetWidget<CheckboxWidget>("PATHDEBUG_CHECKBOX");
pathCheckbox.IsChecked = () => devTrait.PathDebug;
pathCheckbox.OnClick = () => Order(world, "DevPathDebug");
panel.GetWidget<ButtonWidget>("GIVE_CASH_BUTTON").OnClick = () =>
panel.GetWidget<ButtonWidget>("GIVE_CASH_BUTTON").OnClick = () =>
world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false));
var fastBuildCheckbox = panel.GetWidget<CheckboxWidget>("INSTANT_BUILD_CHECKBOX");
fastBuildCheckbox.IsChecked = () => devTrait.FastBuild;
fastBuildCheckbox.OnClick = () => Order(world, "DevFastBuild");
var fastChargeCheckbox = panel.GetWidget<CheckboxWidget>("INSTANT_CHARGE_CHECKBOX");
fastChargeCheckbox.IsChecked = () => devTrait.FastCharge;
fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge");
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var allTechCheckbox = panel.GetWidget<CheckboxWidget>("ENABLE_TECH_CHECKBOX");
allTechCheckbox.IsChecked = () => devTrait.AllTech;
allTechCheckbox.OnClick = () => Order(world, "DevEnableTech");
var powerCheckbox = panel.GetWidget<CheckboxWidget>("UNLIMITED_POWER_CHECKBOX");
powerCheckbox.IsChecked = () => devTrait.UnlimitedPower;
powerCheckbox.OnClick = () => Order(world, "DevUnlimitedPower");
@@ -65,16 +65,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var buildAnywhereCheckbox = panel.GetWidget<CheckboxWidget>("BUILD_ANYWHERE_CHECKBOX");
buildAnywhereCheckbox.IsChecked = () => devTrait.BuildAnywhere;
buildAnywhereCheckbox.OnClick = () => Order(world, "DevBuildAnywhere");
panel.GetWidget<ButtonWidget>("GIVE_EXPLORATION_BUTTON").OnClick = () =>
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false));
panel.GetWidget<ButtonWidget>("CLOSE_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
}
public void Order(World world, string order)
{
world.IssueOrder(new Order(order, world.LocalPlayer.PlayerActor, false));
world.IssueOrder(new Order(order, world.LocalPlayer.PlayerActor, false));
}
}
}

View File

@@ -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.
@@ -30,8 +30,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var hueSlider = panel.GetWidget<SliderWidget>("HUE_SLIDER");
var satSlider = panel.GetWidget<SliderWidget>("SAT_SLIDER");
var lumSlider = panel.GetWidget<SliderWidget>("LUM_SLIDER");
Action sliderChanged = () =>
Action sliderChanged = () =>
{
ramp = new ColorRamp((byte)(255*hueSlider.Value),
(byte)(255*satSlider.Value),
@@ -39,25 +39,25 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
10);
onChange(ramp);
};
hueSlider.OnChange += _ => sliderChanged();
satSlider.OnChange += _ => sliderChanged();
lumSlider.OnChange += _ => sliderChanged();
Action updateSliders = () =>
{
hueSlider.Value = ramp.H / 255f;
satSlider.Value = ramp.S / 255f;
lumSlider.Value = ramp.L / 255f;
};
panel.GetWidget<ButtonWidget>("SAVE_BUTTON").OnClick = () => onSelect(ramp);
panel.GetWidget<ButtonWidget>("RANDOM_BUTTON").OnClick = () =>
panel.GetWidget<ButtonWidget>("RANDOM_BUTTON").OnClick = () =>
{
var hue = (byte)Game.CosmeticRandom.Next(255);
var sat = (byte)Game.CosmeticRandom.Next(255);
var lum = (byte)Game.CosmeticRandom.Next(51,255);
ramp = new ColorRamp(hue, sat, lum, 10);
updateSliders();
sliderChanged();

View File

@@ -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.
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Action onConnect, onRetry, onAbort;
string host;
int port;
void ConnectionStateChanged(OrderManager om)
{
if (om.Connection.ConnectionState == ConnectionState.Connected)
@@ -40,13 +40,13 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
});
}
}
public void CloseWindow()
{
Game.ConnectionStateChanged -= ConnectionStateChanged;
Widget.CloseWindow();
}
[ObjectCreator.UseCtor]
public CncConnectingLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] string host,
@@ -60,16 +60,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
this.onConnect = onConnect;
this.onRetry = onRetry;
this.onAbort = onAbort;
Game.ConnectionStateChanged += ConnectionStateChanged;
var panel = widget.GetWidget("CONNECTING_PANEL");
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); };
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
"Connecting to {0}:{1}...".F(host, port);
}
public static void Connect(string host, int port, Action onConnect, Action onAbort)
{
Game.JoinServer(host, port);
@@ -83,9 +83,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
});
}
}
public class CncConnectionFailedLogic
{
{
[ObjectCreator.UseCtor]
public CncConnectionFailedLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] string host,
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var panel = widget.GetWidget("CONNECTIONFAILED_PANEL");
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); };
panel.GetWidget<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Widget.CloseWindow(); onRetry(); };
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
"Could not connect to {0}:{1}".F(host, port);
}

View File

@@ -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.

View File

@@ -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.
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
ProgressBarWidget progressBar;
LabelWidget statusLabel;
Action continueLoading;
[ObjectCreator.UseCtor]
public CncDownloadPackagesLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Dictionary<string,string> installData,
@@ -34,50 +34,50 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
this.installData = installData;
this.continueLoading = continueLoading;
panel = widget.GetWidget("INSTALL_DOWNLOAD_PANEL");
progressBar = panel.GetWidget<ProgressBarWidget>("PROGRESS_BAR");
statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL");
ShowDownloadDialog();
}
void ShowDownloadDialog()
{
statusLabel.GetText = () => "Initializing...";
statusLabel.GetText = () => "Initializing...";
progressBar.SetIndeterminate(true);
var retryButton = panel.GetWidget<ButtonWidget>("RETRY_BUTTON");
retryButton.IsVisible = () => false;
var cancelButton = panel.GetWidget<ButtonWidget>("CANCEL_BUTTON");
// Save the package to a temp file
var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var dest = new string[] { Platform.SupportDir, "Content", "cnc" }.Aggregate(Path.Combine);
Action<DownloadProgressChangedEventArgs> onDownloadProgress = i =>
{
if (progressBar.Indeterminate)
progressBar.SetIndeterminate(false);
progressBar.Percentage = i.ProgressPercentage;
progressBar.Percentage = i.ProgressPercentage;
statusLabel.GetText = () => "Downloading {1}/{2} kB ({0}%)".F(i.ProgressPercentage, i.BytesReceived / 1024, i.TotalBytesToReceive / 1024);
};
Action<string> onExtractProgress = s =>
{
Game.RunAfterTick(() => statusLabel.GetText = () => s);
};
Action<string> onError = s =>
{
Game.RunAfterTick(() =>
Game.RunAfterTick(() =>
{
statusLabel.GetText = () => "Error: "+s;
retryButton.IsVisible = () => true;
});
};
Action<AsyncCompletedEventArgs, bool> onDownloadComplete = (i, cancelled) =>
{
if (i.Error != null)
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
onError("Download cancelled");
return;
}
// Automatically extract
statusLabel.GetText = () => "Extracting...";
progressBar.SetIndeterminate(true);
@@ -103,9 +103,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
});
}
};
var dl = new Download(installData["PackageURL"], file, onDownloadProgress, onDownloadComplete);
cancelButton.OnClick = () => { dl.Cancel(); Widget.CloseWindow(); };
retryButton.OnClick = () => { dl.Cancel(); ShowDownloadDialog(); };
}

View File

@@ -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.

View File

@@ -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.
@@ -16,7 +16,7 @@ using OpenRA.Widgets;
using OpenRA.Mods.RA.Activities;
namespace OpenRA.Mods.Cnc.Widgets.Logic
{
{
public class CncIngameMenuLogic
{
Widget menu;
@@ -30,12 +30,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
menu = widget.GetWidget("INGAME_MENU");
var mpe = world.WorldActor.Trait<CncMenuPaletteEffect>();
mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
menu.GetWidget<LabelWidget>("VERSION_LABEL").GetText = WidgetUtils.ActiveModVersion;
bool hideButtons = false;
menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons;
// TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions
Action onQuit = () =>
{
@@ -49,18 +49,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Game.LoadShellMap();
});
};
Action doNothing = () => {};
menu.GetWidget<ButtonWidget>("QUIT_BUTTON").OnClick = () =>
CncWidgetUtils.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, doNothing);
Action onSurrender = () => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
var surrenderButton = menu.GetWidget<ButtonWidget>("SURRENDER_BUTTON");
surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined);
surrenderButton.OnClick = () =>
CncWidgetUtils.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, doNothing);
menu.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{
hideButtons = true;
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ "onExit", () => hideButtons = false },
});
};
menu.GetWidget<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{
hideButtons = true;
@@ -79,10 +79,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ "onExit", () => hideButtons = false },
});
};
var resumeButton = menu.GetWidget<ButtonWidget>("RESUME_BUTTON");
resumeButton.IsDisabled = () => resumeDisabled;
resumeButton.OnClick = () =>
resumeButton.OnClick = () =>
{
Widget.CloseWindow();
Widget.RootWidget.RemoveChild(menu);

View File

@@ -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.
@@ -17,7 +17,7 @@ using OpenRA.FileFormats.Graphics;
using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets.Logic
{
{
public class CncInstallFromCDLogic
{
Widget panel;
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Action continueLoading;
ButtonWidget retryButton, backButton;
Widget installingContainer, insertDiskContainer;
[ObjectCreator.UseCtor]
public CncInstallFromCDLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Action continueLoading)
@@ -35,18 +35,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
panel = widget.GetWidget("INSTALL_FROMCD_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") &&
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
installingContainer.IsVisible = () => false;
}
}
void Install(string source)
{
backButton.IsDisabled = () => true;
@@ -74,34 +74,34 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var dest = new string[] { Platform.SupportDir, "Content", "cnc" }.Aggregate(Path.Combine);
var copyFiles = new string[] { "CONQUER.MIX", "DESERT.MIX",
"SCORES.MIX", "SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" };
var extractPackage = "INSTALL/SETUP.Z";
var extractFiles = new string[] { "speech.mix", "tempicnh.mix", "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;

View File

@@ -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.

View File

@@ -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.
@@ -25,12 +25,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
EditableSpectatorTemplate, NonEditableSpectatorTemplate, NewSpectatorTemplate;
ScrollPanelWidget chatPanel;
Widget chatTemplate;
ScrollPanelWidget Players;
Dictionary<string, string> CountryNames;
string MapUid;
Map Map;
CncColorPickerPaletteModifier PlayerPalettePreview;
readonly Action OnGameStart;
@@ -44,8 +44,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
// Show connection failed dialog
CloseWindow();
Action onConnect = () =>
Action onConnect = () =>
{
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
{
@@ -54,23 +54,23 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ "addBots", false }
});
};
Action onRetry = () =>
{
CloseWindow();
CncConnectingLogic.Connect(om.Host, om.Port, onConnect, onExit);
};
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{
{ "onAbort", onExit },
{ "onRetry", onRetry },
{ "host", om.Host },
{ "port", om.Port }
});
});
}
}
public void CloseWindow()
{
Game.LobbyInfoChanged -= UpdateCurrentMap;
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Game.BeforeGameStart -= OnGameStart;
Game.AddChatLine -= AddChatLine;
Game.ConnectionStateChanged -= ConnectionStateChanged;
Widget.CloseWindow();
}
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
this.orderManager = orderManager;
this.OnGameStart = () => { CloseWindow(); onStart(); };
this.onExit = onExit;
Game.LobbyInfoChanged += UpdateCurrentMap;
Game.LobbyInfoChanged += UpdatePlayerList;
Game.BeforeGameStart += OnGameStart;
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
chatLabel.Text = (teamChat) ? "Team:" : "Chat:";
return true;
};
chatPanel = lobby.GetWidget<ScrollPanelWidget>("CHAT_DISPLAY");
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
chatPanel.RemoveChildren();
@@ -238,7 +238,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
orderManager.IssueOrder(Order.Command("slot_bot {0} {1}".F(slot, bot)));
});
}
public void AddChatLine(Color c, string from, string text)
{
var template = chatTemplate.Clone() as ContainerWidget;
@@ -288,7 +288,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public string Title;
public string Order;
public Func<bool> Selected;
public SlotDropDownOption(string title, string order, Func<bool> selected)
{
Title = title;
@@ -296,7 +296,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Selected = selected;
}
}
void ShowSlotDropDown(DropDownButtonWidget dropdown, Session.Slot slot, Session.Client client)
{
var options = new List<SlotDropDownOption>()
@@ -322,10 +322,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
item.GetWidget<LabelWidget>("LABEL").GetText = () => o.Title;
return item;
};
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 150, options, setupItem);
}
void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client)
{
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (race, itemTemplate) =>
@@ -339,10 +339,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
flag.GetImageName = () => race;
return item;
};
dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, CountryNames.Keys.ToList(), setupItem);
}
void ShowTeamDropDown(DropDownButtonWidget dropdown, Session.Client client)
{
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
@@ -353,7 +353,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
item.GetWidget<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
return item;
};
var options = Graphics.Util.MakeArray(Map.SpawnPoints.Count()+1, i => i).ToList();
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
}
@@ -363,7 +363,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
{
var item = ScrollItemWidget.Setup(itemTemplate,
() => client.SpawnPoint == ii,
() => client.SpawnPoint == ii,
() => orderManager.IssueOrder(Order.Command("spawn {0} {1}".F(client.Index, ii))));
item.GetWidget<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
return item;
@@ -390,25 +390,25 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
color.RemovePanel();
orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, c)));
};
Action<ColorRamp> onChange = c => PlayerPalettePreview.Ramp = c;
var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs()
{
{ "onSelect", onSelect },
{ "onChange", onChange },
{ "initialRamp", client.ColorRamp }
});
color.AttachPanel(colorChooser);
}
void UpdatePlayerList()
{
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)
// Todo: handle this nicer
Players.RemoveChildren();
foreach (var kv in orderManager.LobbyInfo.Slots)
{
var key = kv.Key;
@@ -487,14 +487,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
color.IsDisabled = () => slot.LockColor || ready;
color.OnMouseDown = _ => ShowColorDropDown(color, client);
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
colorBlock.GetColor = () => client.ColorRamp.GetColor(0);
var faction = template.GetWidget<DropDownButtonWidget>("FACTION");
faction.IsDisabled = () => slot.LockRace || ready;
faction.OnMouseDown = _ => ShowRaceDropDown(faction, client);
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
factionname.GetText = () => CountryNames[client.Country];
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
@@ -543,7 +543,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var spawn = template.GetWidget<LabelWidget>("SPAWN");
spawn.GetText = () => (client.SpawnPoint == 0) ? "-" : client.SpawnPoint.ToString();
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () =>
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () =>
client.Bot != null || client.State == Session.ClientState.Ready;
var kickButton = template.GetWidget<ButtonWidget>("KICK");
@@ -605,7 +605,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var color = template.GetWidget<ColorBlockWidget>("COLOR");
color.GetColor = () => c.ColorRamp.GetColor(0);
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () =>
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () =>
c.Bot != null || c.State == Session.ClientState.Ready;
var kickButton = template.GetWidget<ButtonWidget>("KICK");

View File

@@ -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.
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Map map;
Widget scrollpanel;
ScrollItemWidget itemTemplate;
[ObjectCreator.UseCtor]
internal CncMapChooserLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] string initialMap,
@@ -28,9 +28,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
[ObjectCreator.Param] Action<Map> onSelect)
{
map = Game.modData.AvailableMaps[ CncWidgetUtils.ChooseInitialMap(initialMap) ];
var panel = widget.GetWidget("MAPCHOOSER_PANEL");
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => map;
panel.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => map.Title;
panel.GetWidget<LabelWidget>("CURMAP_AUTHOR").GetText = () => map.Author;
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
panel.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); };
panel.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); };
scrollpanel = panel.GetWidget<ScrollPanelWidget>("MAP_LIST");
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
EnumerateMaps();

View File

@@ -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.
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ "onExit", () => Menu = MenuType.Multiplayer },
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
});
};
};
// Settings menu
var settingsMenu = widget.GetWidget("SETTINGS_MENU");
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
rootMenu.Parent.RemoveChild(rootMenu);
}
void OpenLobbyPanel(MenuType menu, bool addBots)
{
Menu = MenuType.None;
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ "addBots", addBots }
});
}
void StartSkirmishGame()
{
var map = CncWidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);

View File

@@ -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.
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncModBrowserLogic
{
Mod currentMod;
[ObjectCreator.UseCtor]
public CncModBrowserLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Action onSwitch,
@@ -30,13 +30,13 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var loadButton = panel.GetWidget<ButtonWidget>("LOAD_BUTTON");
loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch);
loadButton.IsDisabled = () => currentMod.Id == Game.CurrentMods.Keys.First();
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
currentMod = Mod.AllMods[Game.modData.Manifest.Mods[0]];
// Mod list
var modTemplate = modList.GetWidget<ScrollItemWidget>("MOD_TEMPLATE");
foreach (var m in Mod.AllMods)
{
var mod = m.Value;
@@ -47,12 +47,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
modList.AddChild(item);
}
}
void LoadMod(string mod, Action onSwitch)
{
var mods = Mod.AllMods[mod].WithPrerequisites();
Game.RunAfterTick(() =>
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
onSwitch();

View File

@@ -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;

View File

@@ -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.
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
perfRoot.GetWidget("PERF_GRAPH").IsVisible = () => Game.Settings.Debug.PerfGraph;
var text = perfRoot.GetWidget<LabelWidget>("PERF_TEXT");
text.IsVisible = () => Game.Settings.Debug.PerfText;
text.GetText = () =>
text.GetText = () =>
"Tick {0} @ {1:F1} ms\nRender {2} @ {3:F1} ms\nBatches: {4}".F(
Game.LocalTick, PerfHistory.items["tick_time"].Average(Game.Settings.Debug.Samples),
Game.RenderFrame, PerfHistory.items["render"].Average(Game.Settings.Debug.Samples),

View File

@@ -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.

View File

@@ -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.
@@ -16,7 +16,7 @@ using OpenRA.Network;
using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets.Logic
{
{
public class CncServerBrowserLogic
{
GameServer currentServer;
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Hidden
}
SearchStatus searchStatus = SearchStatus.Fetching;
public string ProgressLabelText()
{
switch (searchStatus)
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
var panel = widget.GetWidget("SERVERBROWSER_PANEL");
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");
// Menu buttons
var refreshButton = panel.GetWidget<ButtonWidget>("REFRESH_BUTTON");
refreshButton.IsDisabled = () => refreshing;
@@ -61,11 +61,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
searchStatus = SearchStatus.Fetching;
sl.RemoveChildren();
currentServer = null;
currentServer = null;
ServerList.Query(games => RefreshServerList(panel, games));
refreshing = true;
};
var join = panel.GetWidget<ButtonWidget>("JOIN_BUTTON");
join.IsDisabled = () => currentServer == null || !ServerBrowserLogic.CanJoin(currentServer);
join.OnClick = () =>
@@ -79,23 +79,23 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget.CloseWindow();
CncConnectingLogic.Connect(host, port, openLobby, onExit);
};
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
// Server list
serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
// Display the progress label over the server list
// The text is only visible when the list is empty
var progressText = panel.GetWidget<LabelWidget>("PROGRESS_LABEL");
progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
progressText.GetText = ProgressLabelText;
// Map preview
var preview = panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
preview.Map = () => CurrentMap();
preview.IsVisible = () => CurrentMap() != null;
// Server info
var infoPanel = panel.GetWidget("SERVER_INFO");
infoPanel.IsVisible = () => currentServer != null;
@@ -103,16 +103,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
infoPanel.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => ServerBrowserLogic.GenerateModsLabel(currentServer);
infoPanel.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
infoPanel.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () => GetPlayersLabel(currentServer);
refreshing = true;
ServerList.Query(games => RefreshServerList(panel, games));
}
string GetPlayersLabel(GameServer game)
{
if (game == null)
return "";
var map = GetMap(game.Map);
return map == null ? "{0}".F(currentServer.Players) : "{0} / {1}".F(currentServer.Players, map.PlayerCount);
}
@@ -121,18 +121,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
return (currentServer == null) ? null : GetMap(currentServer.Map);
}
static Map GetMap(string uid)
{
return (!Game.modData.AvailableMaps.ContainsKey(uid))
? null : Game.modData.AvailableMaps[uid];
}
public void RefreshServerList(Widget panel, IEnumerable<GameServer> games)
{
refreshing = false;
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");
sl.RemoveChildren();
currentServer = null;
@@ -149,14 +149,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
searchStatus = SearchStatus.NoGames;
return;
}
searchStatus = SearchStatus.Hidden;
int i = 0;
foreach (var loop in gamesWaiting)
{
var game = loop;
var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game);
item.GetWidget<LabelWidget>("TITLE").GetText = () => game.Name;
// TODO: Use game.MapTitle once the server supports it
@@ -182,7 +182,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var panel = widget.GetWidget("DIRECTCONNECT_PANEL");
var ipField = panel.GetWidget<TextFieldWidget>("IP");
var portField = panel.GetWidget<TextFieldWidget>("PORT");
var last = Game.Settings.Player.LastServer.Split(':').ToArray();
ipField.Text = last.Length > 1 ? last[0] : "localhost";
portField.Text = last.Length > 2 ? last[1] : "1234";
@@ -192,10 +192,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
int port;
if (!int.TryParse(portField.Text, out port))
port = 1234;
Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port);
Game.Settings.Save();
Widget.CloseWindow();
CncConnectingLogic.Connect(ipField.Text, port, openLobby, onExit);
};

View File

@@ -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.

View File

@@ -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.
@@ -20,7 +20,7 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets.Logic
{
public class CncSettingsLogic
{
{
enum PanelType { General, Input }
PanelType Settings = PanelType.General;
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// Video
var windowModeDropdown = generalPane.GetWidget<DropDownButtonWidget>("MODE_DROPDOWN");
windowModeDropdown.OnMouseDown = _ => SettingsMenuLogic.ShowWindowModeDropdown(windowModeDropdown, graphicsSettings);
windowModeDropdown.GetText = () => graphicsSettings.Mode == WindowMode.Windowed ?
windowModeDropdown.GetText = () => graphicsSettings.Mode == WindowMode.Windowed ?
"Windowed" : graphicsSettings.Mode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen";
var pixelDoubleCheckbox = generalPane.GetWidget<CheckboxWidget>("PIXELDOUBLE_CHECKBOX");

View File

@@ -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.
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var costString = "$: {0}".F(cost);
costLabel.GetText = () => costString;
costLabel.GetColor = () => pr.DisplayCash + pr.DisplayOre >= cost
costLabel.GetColor = () => pr.DisplayCash + pr.DisplayOre >= cost
? Color.White : Color.Red;
var leftWidth = Math.Max(font.Measure(tooltip.Name).X, requiresFont.Measure(requiresString).X);

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var doubleHeight = 45;
var singleHeight = 25;
tooltipContainer.BeforeRender = () =>
tooltipContainer.BeforeRender = () =>
{
if (wic == null || wic.TooltipType == Type.None)
return;

View File

@@ -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.

View File

@@ -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.
@@ -63,22 +63,22 @@ namespace OpenRA.Mods.Cnc.Widgets
color = Color.Orange;
if (pm.PowerState == PowerState.Critical)
color = Color.Red;
var b = RenderBounds;
var rect = new RectangleF(b.X,
b.Y + (1-providedFrac)*b.Height,
(float)b.Width,
providedFrac*b.Height);
Game.Renderer.LineRenderer.FillRect(rect, color);
var indicator = ChromeProvider.GetImage("sidebar-bits", "left-indicator");
var drainedFrac = pm.PowerDrained / powerScaleBy;
lastDrainedFrac = drainedFrac = float2.Lerp(lastDrainedFrac.GetValueOrDefault(drainedFrac), drainedFrac, .3f);
float2 pos = new float2(b.X + b.Width - indicator.size.X,
b.Y + (1-drainedFrac)*b.Height - indicator.size.Y / 2);
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos);
}
}

View File

@@ -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.
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Cnc.Widgets
cantBuild = new Animation("clock");
cantBuild.PlayFetchIndex("idle", () => 0);
clock = new Animation("clock");
iconSprites = Rules.Info.Values
.Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
.ToDictionary(
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Cnc.Widgets
}
public override bool HandleMouseInput(MouseInput mi)
{
{
if (mi.Event == MouseInputEvent.Move)
{
var hover = Icons.Where(i => i.Key.Contains(mi.Location))
@@ -129,13 +129,13 @@ namespace OpenRA.Mods.Cnc.Widgets
var clicked = Icons.Where(i => i.Key.Contains(mi.Location))
.Select(i => i.Value).FirstOrDefault();
if (clicked == null)
return true;
var actor = Rules.Info[clicked.Name];
var first = clicked.Queued.FirstOrDefault();
if (mi.Button == MouseButton.Left)
{
// Pick up a completed building
@@ -155,7 +155,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{
Sound.Play(TabClick);
Sound.Play(CurrentQueue.Info.QueuedAudio);
world.IssueOrder(Order.StartProduction(CurrentQueue.self, clicked.Name,
world.IssueOrder(Order.StartProduction(CurrentQueue.self, clicked.Name,
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
}
else
@@ -223,7 +223,7 @@ namespace OpenRA.Mods.Cnc.Widgets
var isBuildingSomething = CurrentQueue.CurrentItem() != null;
var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
// Background
foreach (var rect in Icons.Keys)
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1,1,1,1));

View File

@@ -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.
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Cnc.Widgets
SelectNextTab(false);
}
}
public ProductionQueue CurrentQueue
{
get

View File

@@ -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.
@@ -64,21 +64,21 @@ namespace OpenRA.Mods.Cnc.Widgets
color = Color.Orange;
if (pr.Ore == pr.OreCapacity)
color = Color.Red;
var b = RenderBounds;
var rect = new RectangleF(b.X,
b.Y + (1-capacityFrac)*b.Height,
(float)b.Width,
capacityFrac*b.Height);
Game.Renderer.LineRenderer.FillRect(rect, color);
var indicator = ChromeProvider.GetImage("sidebar-bits", "right-indicator");
var storedFrac = pr.Ore / scaleBy;
lastStoredFrac = storedFrac = float2.Lerp(lastStoredFrac.GetValueOrDefault(storedFrac), storedFrac, .3f);
float2 pos = new float2(b.X, b.Y + (1-storedFrac)*b.Height - indicator.size.Y / 2);
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos);
}
}

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.