StyleCop clean Cnc DLL
This commit is contained in:
@@ -19,19 +19,19 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
public class CncLoadScreen : ILoadScreen
|
public class CncLoadScreen : ILoadScreen
|
||||||
{
|
{
|
||||||
Dictionary<string, string> Info;
|
Dictionary<string, string> loadInfo;
|
||||||
Stopwatch loadTimer = new Stopwatch();
|
Stopwatch loadTimer = new Stopwatch();
|
||||||
Sprite[] ss;
|
Sprite[] ss;
|
||||||
int loadTick;
|
int loadTick;
|
||||||
float2 nodPos, gdiPos, evaPos;
|
float2 nodPos, gdiPos, evaPos;
|
||||||
Sprite nodLogo, gdiLogo, evaLogo, brightBlock, dimBlock;
|
Sprite nodLogo, gdiLogo, evaLogo, brightBlock, dimBlock;
|
||||||
Rectangle Bounds;
|
Rectangle bounds;
|
||||||
Renderer r;
|
Renderer r;
|
||||||
NullInputHandler nih = new NullInputHandler();
|
NullInputHandler nih = new NullInputHandler();
|
||||||
|
|
||||||
public void Init(Dictionary<string, string> info)
|
public void Init(Dictionary<string, string> info)
|
||||||
{
|
{
|
||||||
Info = info;
|
loadInfo = info;
|
||||||
|
|
||||||
// Avoid standard loading mechanisms so we
|
// Avoid standard loading mechanisms so we
|
||||||
// can display loadscreen as early as possible
|
// can display loadscreen as early as possible
|
||||||
@@ -40,26 +40,26 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
var s = new Sheet("mods/cnc/uibits/chrome.png");
|
var s = new Sheet("mods/cnc/uibits/chrome.png");
|
||||||
var res = Renderer.Resolution;
|
var res = Renderer.Resolution;
|
||||||
Bounds = new Rectangle(0, 0, res.Width, res.Height);
|
bounds = new Rectangle(0, 0, res.Width, res.Height);
|
||||||
|
|
||||||
ss = new []
|
ss = new[]
|
||||||
{
|
{
|
||||||
new Sprite(s, new Rectangle(161,128,62,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(161, 128, 62, 33), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(161,223,62,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(161, 223, 62, 33), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(128,161,33,62), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(128, 161, 33, 62), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(223,161,33,62), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(223, 161, 33, 62), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(128,128,33,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(128, 128, 33, 33), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(223,128,33,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(223, 128, 33, 33), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(128,223,33,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(128, 223, 33, 33), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(223,223,33,33), TextureChannel.Alpha)
|
new Sprite(s, new Rectangle(223, 223, 33, 33), TextureChannel.Alpha)
|
||||||
};
|
};
|
||||||
|
|
||||||
nodLogo = new Sprite(s, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha);
|
nodLogo = new Sprite(s, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha);
|
||||||
gdiLogo = new Sprite(s, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha);
|
gdiLogo = new Sprite(s, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha);
|
||||||
evaLogo = new Sprite(s, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha);
|
evaLogo = new Sprite(s, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha);
|
||||||
nodPos = new float2(Bounds.Width / 2 - 384, Bounds.Height / 2 - 128);
|
nodPos = new float2(bounds.Width / 2 - 384, bounds.Height / 2 - 128);
|
||||||
gdiPos = new float2(Bounds.Width / 2 + 128, Bounds.Height / 2 - 128);
|
gdiPos = new float2(bounds.Width / 2 + 128, bounds.Height / 2 - 128);
|
||||||
evaPos = new float2(Bounds.Width - 43 - 128, 43);
|
evaPos = new float2(bounds.Width - 43 - 128, 43);
|
||||||
|
|
||||||
brightBlock = new Sprite(s, new Rectangle(320, 0, 16, 35), TextureChannel.Alpha);
|
brightBlock = new Sprite(s, new Rectangle(320, 0, 16, 35), TextureChannel.Alpha);
|
||||||
dimBlock = new Sprite(s, new Rectangle(336, 0, 16, 35), TextureChannel.Alpha);
|
dimBlock = new Sprite(s, new Rectangle(336, 0, 16, 35), TextureChannel.Alpha);
|
||||||
@@ -83,19 +83,19 @@ namespace OpenRA.Mods.Cnc
|
|||||||
r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
|
r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
|
||||||
r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);
|
r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);
|
||||||
|
|
||||||
WidgetUtils.DrawPanelPartial(ss, Bounds, PanelSides.Edges);
|
WidgetUtils.DrawPanelPartial(ss, bounds, PanelSides.Edges);
|
||||||
var barY = Bounds.Height - 78;
|
var barY = bounds.Height - 78;
|
||||||
|
|
||||||
if (!setup && r.Fonts != null)
|
if (!setup && r.Fonts != null)
|
||||||
{
|
{
|
||||||
loadingFont = r.Fonts["BigBold"];
|
loadingFont = r.Fonts["BigBold"];
|
||||||
loadingText = "Loading";
|
loadingText = "Loading";
|
||||||
loadingPos = new float2((Bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);
|
loadingPos = new float2((bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);
|
||||||
|
|
||||||
versionFont = r.Fonts["Regular"];
|
versionFont = r.Fonts["Regular"];
|
||||||
versionText = WidgetUtils.ActiveModVersion();
|
versionText = WidgetUtils.ActiveModVersion();
|
||||||
var versionSize = versionFont.Measure(versionText);
|
var versionSize = versionFont.Measure(versionText);
|
||||||
versionPos = new float2(Bounds.Width - 107 - versionSize.X/2, 115 - versionSize.Y/2);
|
versionPos = new float2(bounds.Width - 107 - versionSize.X / 2, 115 - versionSize.Y / 2);
|
||||||
|
|
||||||
setup = true;
|
setup = true;
|
||||||
}
|
}
|
||||||
@@ -109,9 +109,9 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
var block = loadTick == i ? brightBlock : dimBlock;
|
var block = loadTick == i ? brightBlock : dimBlock;
|
||||||
r.RgbaSpriteRenderer.DrawSprite(block,
|
r.RgbaSpriteRenderer.DrawSprite(block,
|
||||||
new float2(Bounds.Width / 2 - 114 - i * 32, barY));
|
new float2(bounds.Width / 2 - 114 - i * 32, barY));
|
||||||
r.RgbaSpriteRenderer.DrawSprite(block,
|
r.RgbaSpriteRenderer.DrawSprite(block,
|
||||||
new float2(Bounds.Width / 2 + 114 + i * 32 - 16, barY));
|
new float2(bounds.Width / 2 + 114 + i * 32 - 16, barY));
|
||||||
}
|
}
|
||||||
|
|
||||||
r.EndFrame(nih);
|
r.EndFrame(nih);
|
||||||
@@ -125,19 +125,18 @@ namespace OpenRA.Mods.Cnc
|
|||||||
void TestAndContinue()
|
void TestAndContinue()
|
||||||
{
|
{
|
||||||
Ui.ResetAll();
|
Ui.ResetAll();
|
||||||
if (!FileSystem.Exists(Info["TestFile"]))
|
if (!FileSystem.Exists(loadInfo["TestFile"]))
|
||||||
{
|
{
|
||||||
var args = new WidgetArgs()
|
var args = new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "continueLoading", () => TestAndContinue() },
|
{ "continueLoading", () => TestAndContinue() },
|
||||||
{ "installData", Info }
|
{ "installData", loadInfo }
|
||||||
};
|
};
|
||||||
Ui.LoadWidget(Info["InstallerBackgroundWidget"], Ui.Root, args);
|
Ui.LoadWidget(loadInfo["InstallerBackgroundWidget"], Ui.Root, args);
|
||||||
Ui.OpenWindow(Info["InstallerMenuWidget"], args);
|
Ui.OpenWindow(loadInfo["InstallerMenuWidget"], args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Game.LoadShellMap();
|
Game.LoadShellMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
Color ColorForEffect(EffectType t, Color orig)
|
Color ColorForEffect(EffectType t, Color orig)
|
||||||
{
|
{
|
||||||
switch(t)
|
switch (t)
|
||||||
{
|
{
|
||||||
case EffectType.Black:
|
case EffectType.Black:
|
||||||
return Color.FromArgb(orig.A, Color.Black);
|
return Color.FromArgb(orig.A, Color.Black);
|
||||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
||||||
{
|
{
|
||||||
if (to == EffectType.None && remainingFrames == 0)
|
if (to == EffectType.None && remainingFrames == 0)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -19,18 +19,18 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class CncShellmapScriptInfo : TraitInfo<CncShellmapScript> { }
|
class CncShellmapScriptInfo : TraitInfo<CncShellmapScript> { }
|
||||||
|
|
||||||
class CncShellmapScript: IWorldLoaded, ITick
|
class CncShellmapScript : IWorldLoaded, ITick
|
||||||
{
|
{
|
||||||
Dictionary<string, Actor> Actors;
|
static CPos viewportOrigin;
|
||||||
static CPos ViewportOrigin;
|
Dictionary<string, Actor> actors;
|
||||||
|
|
||||||
public void WorldLoaded(World w)
|
public void WorldLoaded(World w)
|
||||||
{
|
{
|
||||||
var b = w.Map.Bounds;
|
var b = w.Map.Bounds;
|
||||||
ViewportOrigin = new CPos(b.Left + b.Width/2, b.Top + b.Height/2);
|
viewportOrigin = new CPos(b.Left + b.Width / 2, b.Top + b.Height / 2);
|
||||||
Game.MoveViewport(ViewportOrigin.ToFloat2());
|
Game.MoveViewport(viewportOrigin.ToFloat2());
|
||||||
|
|
||||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||||
|
|
||||||
SetViewport();
|
SetViewport();
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA
|
|||||||
void SetViewport()
|
void SetViewport()
|
||||||
{
|
{
|
||||||
var t = (ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed;
|
var t = (ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed;
|
||||||
var loc = ViewportOrigin.ToFloat2() + (new float2(-15,4) * float2.FromAngle( (float)t ));
|
var loc = viewportOrigin.ToFloat2() + (new float2(-15, 4) * float2.FromAngle((float)t));
|
||||||
Game.viewport.Center(loc);
|
Game.viewport.Center(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,16 +51,16 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (ticks == 0)
|
if (ticks == 0)
|
||||||
{
|
{
|
||||||
LoopTrack(Actors["boat1"], Actors["tl1"].Location, Actors["tr1"].Location);
|
LoopTrack(actors["boat1"], actors["tl1"].Location, actors["tr1"].Location);
|
||||||
LoopTrack(Actors["boat3"], Actors["tl1"].Location, Actors["tr1"].Location);
|
LoopTrack(actors["boat3"], actors["tl1"].Location, actors["tr1"].Location);
|
||||||
LoopTrack(Actors["boat2"], Actors["tl3"].Location, Actors["tr3"].Location);
|
LoopTrack(actors["boat2"], actors["tl3"].Location, actors["tr3"].Location);
|
||||||
LoopTrack(Actors["boat4"], Actors["tl3"].Location, Actors["tr3"].Location);
|
LoopTrack(actors["boat4"], actors["tl3"].Location, actors["tr3"].Location);
|
||||||
CreateUnitsInTransport(Actors["lst1"], new string[] {"htnk"});
|
CreateUnitsInTransport(actors["lst1"], new string[] { "htnk" });
|
||||||
CreateUnitsInTransport(Actors["lst2"], new string[] {"mcv"});
|
CreateUnitsInTransport(actors["lst2"], new string[] { "mcv" });
|
||||||
CreateUnitsInTransport(Actors["lst3"], new string[] {"htnk"});
|
CreateUnitsInTransport(actors["lst3"], new string[] { "htnk" });
|
||||||
LoopTrack(Actors["lst1"], Actors["tl2"].Location, Actors["tr2"].Location);
|
LoopTrack(actors["lst1"], actors["tl2"].Location, actors["tr2"].Location);
|
||||||
LoopTrack(Actors["lst2"], Actors["tl2"].Location, Actors["tr2"].Location);
|
LoopTrack(actors["lst2"], actors["tl2"].Location, actors["tr2"].Location);
|
||||||
LoopTrack(Actors["lst3"], Actors["tl2"].Location, Actors["tr2"].Location);
|
LoopTrack(actors["lst3"], actors["tl2"].Location, actors["tr2"].Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
ticks++;
|
ticks++;
|
||||||
@@ -73,8 +73,8 @@ namespace OpenRA.Mods.RA
|
|||||||
foreach (var i in cargo)
|
foreach (var i in cargo)
|
||||||
c.Load(transport, transport.World.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary
|
c.Load(transport, transport.World.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary
|
||||||
{
|
{
|
||||||
new OwnerInit( transport.Owner ),
|
new OwnerInit(transport.Owner),
|
||||||
new FacingInit( f.Facing ),
|
new FacingInit(f.Facing),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA
|
|||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
self.QueueActivity(mobile.ScriptedMove(left));
|
self.QueueActivity(mobile.ScriptedMove(left));
|
||||||
self.QueueActivity(new SimpleTeleport(right));
|
self.QueueActivity(new SimpleTeleport(right));
|
||||||
self.QueueActivity(new CallFunc(() => LoopTrack(self,left,right)));
|
self.QueueActivity(new CallFunc(() => LoopTrack(self, left, right)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,25 +15,25 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Mods.RA.Move;
|
using OpenRA.Mods.RA.Move;
|
||||||
|
using OpenRA.Scripting;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using OpenRA.Scripting;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Missions
|
namespace OpenRA.Mods.Cnc.Missions
|
||||||
{
|
{
|
||||||
class Gdi01ScriptInfo : TraitInfo<Gdi01Script> { }
|
class Gdi01ScriptInfo : TraitInfo<Gdi01Script> { }
|
||||||
|
|
||||||
class Gdi01Script: IWorldLoaded, ITick
|
class Gdi01Script : IWorldLoaded, ITick
|
||||||
{
|
{
|
||||||
Dictionary<string, Actor> Actors;
|
Dictionary<string, Actor> actors;
|
||||||
Dictionary<string, Player> Players;
|
Dictionary<string, Player> players;
|
||||||
|
|
||||||
public void WorldLoaded(World w)
|
public void WorldLoaded(World w)
|
||||||
{
|
{
|
||||||
Players = w.Players.ToDictionary(p => p.InternalName);
|
players = w.Players.ToDictionary(p => p.InternalName);
|
||||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||||
var b = w.Map.Bounds;
|
var b = w.Map.Bounds;
|
||||||
Game.MoveViewport(new CPos(b.Left + b.Width/2, b.Top + b.Height/2).ToFloat2());
|
Game.MoveViewport(new CPos(b.Left + b.Width / 2, b.Top + b.Height / 2).ToFloat2());
|
||||||
|
|
||||||
Action afterFMV = () =>
|
Action afterFMV = () =>
|
||||||
{
|
{
|
||||||
@@ -48,10 +48,10 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
{
|
{
|
||||||
Action afterFMV = () =>
|
Action afterFMV = () =>
|
||||||
{
|
{
|
||||||
Players["GoodGuy"].WinState = WinState.Won;
|
players["GoodGuy"].WinState = WinState.Won;
|
||||||
started = false;
|
started = false;
|
||||||
Sound.StopMusic();
|
Sound.StopMusic();
|
||||||
Sound.PlayToPlayer(Players["GoodGuy"], "accom1.aud");
|
Sound.PlayToPlayer(players["GoodGuy"], "accom1.aud");
|
||||||
};
|
};
|
||||||
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV));
|
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV));
|
||||||
}
|
}
|
||||||
@@ -60,10 +60,10 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
{
|
{
|
||||||
Action afterFMV = () =>
|
Action afterFMV = () =>
|
||||||
{
|
{
|
||||||
Players["GoodGuy"].WinState = WinState.Lost;
|
players["GoodGuy"].WinState = WinState.Lost;
|
||||||
started = false;
|
started = false;
|
||||||
Sound.StopMusic();
|
Sound.StopMusic();
|
||||||
Sound.PlayToPlayer(Players["GoodGuy"], "fail1.aud");
|
Sound.PlayToPlayer(players["GoodGuy"], "fail1.aud");
|
||||||
};
|
};
|
||||||
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV));
|
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV));
|
||||||
}
|
}
|
||||||
@@ -82,27 +82,29 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
SetGunboatPath();
|
SetGunboatPath();
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
//Initial Nod reinforcements
|
// Initial Nod reinforcements
|
||||||
foreach (var i in new[]{ "e1", "e1" })
|
foreach (var i in new[] { "e1", "e1" })
|
||||||
{
|
{
|
||||||
var a = self.World.CreateActor(i.ToLowerInvariant(), new TypeDictionary
|
var a = self.World.CreateActor(i.ToLowerInvariant(), new TypeDictionary
|
||||||
{
|
{
|
||||||
new OwnerInit(Players["BadGuy"]),
|
new OwnerInit(players["BadGuy"]),
|
||||||
new FacingInit(0),
|
new FacingInit(0),
|
||||||
new LocationInit(Actors["nod0"].Location),
|
new LocationInit(actors["nod0"].Location),
|
||||||
});
|
});
|
||||||
var mobile = a.Trait<Mobile>();
|
var mobile = a.Trait<Mobile>();
|
||||||
a.QueueActivity(mobile.MoveTo(Actors["nod1"].Location, 2 ));
|
a.QueueActivity(mobile.MoveTo(actors["nod1"].Location, 2));
|
||||||
a.QueueActivity(mobile.MoveTo(Actors["nod2"].Location, 2 ));
|
a.QueueActivity(mobile.MoveTo(actors["nod2"].Location, 2));
|
||||||
a.QueueActivity(mobile.MoveTo(Actors["nod3"].Location, 2 ));
|
a.QueueActivity(mobile.MoveTo(actors["nod3"].Location, 2));
|
||||||
|
|
||||||
// TODO: Queue hunt order
|
// TODO: Queue hunt order
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// GoodGuy win conditions
|
// GoodGuy win conditions
|
||||||
// BadGuy is dead
|
// BadGuy is dead
|
||||||
var badcount = self.World.Actors.Count(a => a != a.Owner.PlayerActor &&
|
var badcount = self.World.Actors.Count(a => a != a.Owner.PlayerActor &&
|
||||||
a.Owner == Players["BadGuy"] && !a.IsDead());
|
a.Owner == players["BadGuy"] && !a.IsDead());
|
||||||
if (badcount != lastBadCount)
|
if (badcount != lastBadCount)
|
||||||
{
|
{
|
||||||
Game.Debug("{0} badguys remain".F(badcount));
|
Game.Debug("{0} badguys remain".F(badcount));
|
||||||
@@ -112,51 +114,51 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
OnVictory(self.World);
|
OnVictory(self.World);
|
||||||
}
|
}
|
||||||
|
|
||||||
//GoodGuy lose conditions: MCV/cyard must survive
|
// GoodGuy lose conditions: MCV/cyard must survive
|
||||||
var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
|
var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
|
||||||
.Any( a => a.Actor.Owner == Players["GoodGuy"] );
|
.Any(a => a.Actor.Owner == players["GoodGuy"]);
|
||||||
if (!hasAnything)
|
if (!hasAnything)
|
||||||
OnLose(self.World);
|
OnLose(self.World);
|
||||||
|
|
||||||
// GoodGuy reinforcements
|
// GoodGuy reinforcements
|
||||||
if (ticks == 25*5)
|
if (ticks == 25 * 5)
|
||||||
{
|
{
|
||||||
ReinforceFromSea(self.World,
|
ReinforceFromSea(self.World,
|
||||||
Actors["lstStart"].Location,
|
actors["lstStart"].Location,
|
||||||
Actors["lstEnd"].Location,
|
actors["lstEnd"].Location,
|
||||||
new CPos(53, 53),
|
new CPos(53, 53),
|
||||||
new string[] {"e1","e1","e1"},
|
new string[] { "e1", "e1", "e1" },
|
||||||
Players["GoodGuy"]);
|
players["GoodGuy"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticks == 25*15)
|
if (ticks == 25 * 15)
|
||||||
{
|
{
|
||||||
ReinforceFromSea(self.World,
|
ReinforceFromSea(self.World,
|
||||||
Actors["lstStart"].Location,
|
actors["lstStart"].Location,
|
||||||
Actors["lstEnd"].Location,
|
actors["lstEnd"].Location,
|
||||||
new CPos(53, 53),
|
new CPos(53, 53),
|
||||||
new string[] {"e1","e1","e1"},
|
new string[] { "e1", "e1", "e1" },
|
||||||
Players["GoodGuy"]);
|
players["GoodGuy"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticks == 25*30)
|
if (ticks == 25 * 30)
|
||||||
{
|
{
|
||||||
ReinforceFromSea(self.World,
|
ReinforceFromSea(self.World,
|
||||||
Actors["lstStart"].Location,
|
actors["lstStart"].Location,
|
||||||
Actors["lstEnd"].Location,
|
actors["lstEnd"].Location,
|
||||||
new CPos(53, 53),
|
new CPos(53, 53),
|
||||||
new string[] {"jeep"},
|
new string[] { "jeep" },
|
||||||
Players["GoodGuy"]);
|
players["GoodGuy"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticks == 25*60)
|
if (ticks == 25 * 60)
|
||||||
{
|
{
|
||||||
ReinforceFromSea(self.World,
|
ReinforceFromSea(self.World,
|
||||||
Actors["lstStart"].Location,
|
actors["lstStart"].Location,
|
||||||
Actors["lstEnd"].Location,
|
actors["lstEnd"].Location,
|
||||||
new CPos(53, 53),
|
new CPos(53, 53),
|
||||||
new string[] {"jeep"},
|
new string[] { "jeep" },
|
||||||
Players["GoodGuy"]);
|
players["GoodGuy"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ticks++;
|
ticks++;
|
||||||
@@ -164,11 +166,11 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
|
|
||||||
void SetGunboatPath()
|
void SetGunboatPath()
|
||||||
{
|
{
|
||||||
var self = Actors[ "Gunboat" ];
|
var self = actors["Gunboat"];
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
self.Trait<AutoTarget>().stance = UnitStance.AttackAnything; //TODO: this is ignored
|
self.Trait<AutoTarget>().stance = UnitStance.AttackAnything; // TODO: this is ignored
|
||||||
self.QueueActivity(mobile.ScriptedMove(Actors["gunboatLeft"].Location));
|
self.QueueActivity(mobile.ScriptedMove(actors["gunboatLeft"].Location));
|
||||||
self.QueueActivity(mobile.ScriptedMove(Actors["gunboatRight"].Location));
|
self.QueueActivity(mobile.ScriptedMove(actors["gunboatRight"].Location));
|
||||||
self.QueueActivity(new CallFunc(() => SetGunboatPath()));
|
self.QueueActivity(new CallFunc(() => SetGunboatPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,13 +178,13 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
{
|
{
|
||||||
world.AddFrameEndTask(w =>
|
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 LocationInit(startPos),
|
||||||
new OwnerInit( player ),
|
new OwnerInit(player),
|
||||||
new FacingInit( 0 ),
|
new FacingInit(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
var mobile = a.Trait<Mobile>();
|
var mobile = a.Trait<Mobile>();
|
||||||
@@ -190,8 +192,8 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
foreach (var i in items)
|
foreach (var i in items)
|
||||||
cargo.Load(a, world.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary
|
cargo.Load(a, world.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary
|
||||||
{
|
{
|
||||||
new OwnerInit( player ),
|
new OwnerInit(player),
|
||||||
new FacingInit( 0 ),
|
new FacingInit(0),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
a.CancelActivity();
|
a.CancelActivity();
|
||||||
|
|||||||
@@ -11,16 +11,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Mods.Cnc;
|
using OpenRA.Mods.Cnc;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Mods.RA.Air;
|
|
||||||
using OpenRA.Mods.RA.Move;
|
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Mods.RA.Missions;
|
using OpenRA.Mods.RA.Air;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
using OpenRA.Mods.RA.Missions;
|
||||||
|
using OpenRA.Mods.RA.Move;
|
||||||
using OpenRA.Scripting;
|
using OpenRA.Scripting;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.FileFormats;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Missions
|
namespace OpenRA.Mods.Cnc.Missions
|
||||||
{
|
{
|
||||||
@@ -90,6 +90,7 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
NODReinforceNthA();
|
NODReinforceNthA();
|
||||||
Sound.Play("reinfor1.aud");
|
Sound.Play("reinfor1.aud");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.FrameNumber == 1400)
|
if (world.FrameNumber == 1400)
|
||||||
{
|
{
|
||||||
NODReinforceNthB();
|
NODReinforceNthB();
|
||||||
@@ -107,6 +108,7 @@ namespace OpenRA.Mods.Cnc.Missions
|
|||||||
Sound.Play("reinfor1.aud");
|
Sound.Play("reinfor1.aud");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (levelvillage.Status == ObjectiveStatus.InProgress)
|
if (levelvillage.Status == ObjectiveStatus.InProgress)
|
||||||
{
|
{
|
||||||
if (vil01.Destroyed && vil02.Destroyed && vil03.Destroyed && vil04.Destroyed && vil05.Destroyed && vil06.Destroyed &&
|
if (vil01.Destroyed && vil02.Destroyed && vil03.Destroyed && vil04.Destroyed && vil05.Destroyed && vil06.Destroyed &&
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
var rl = self.World.WorldActor.Trait<ResourceLayer>();
|
var rl = self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
var r = rl.GetResource(self.Location);
|
var r = rl.GetResource(self.Location);
|
||||||
if( r == null ) return;
|
if (r == null) return;
|
||||||
if( !info.Resources.Contains(r.info.Name) ) return;
|
if (!info.Resources.Contains(r.info.Name)) return;
|
||||||
|
|
||||||
var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
||||||
|
|
||||||
self.InflictDamage( self.World.WorldActor, weapon.Warheads[ 0 ].Damage, weapon.Warheads[ 0 ] );
|
self.InflictDamage(self.World.WorldActor, weapon.Warheads[0].Damage, weapon.Warheads[0]);
|
||||||
poisonTicks = weapon.ROF;
|
poisonTicks = weapon.ROF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
public string ProductionTabsWidget = null;
|
public string ProductionTabsWidget = null;
|
||||||
|
|
||||||
public object Create( ActorInitializer init ) { return new ProductionQueueFromSelection(init.world, this); }
|
public object Create(ActorInitializer init) { return new ProductionQueueFromSelection(init.world, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProductionQueueFromSelection : INotifySelection
|
class ProductionQueueFromSelection : INotifySelection
|
||||||
{
|
{
|
||||||
Lazy<ProductionTabsWidget> tabsWidget;
|
|
||||||
readonly World world;
|
readonly World world;
|
||||||
|
Lazy<ProductionTabsWidget> tabsWidget;
|
||||||
|
|
||||||
public ProductionQueueFromSelection(World world, ProductionQueueFromSelectionInfo info)
|
public ProductionQueueFromSelection(World world, ProductionQueueFromSelectionInfo info)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,28 +26,28 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
class SpawnViceroid : INotifyKilled
|
class SpawnViceroid : INotifyKilled
|
||||||
{
|
{
|
||||||
readonly SpawnViceroidInfo Info;
|
readonly SpawnViceroidInfo spawnViceroidInfo;
|
||||||
|
|
||||||
public SpawnViceroid(SpawnViceroidInfo info) { Info = info; }
|
public SpawnViceroid(SpawnViceroidInfo info) { spawnViceroidInfo = info; }
|
||||||
|
|
||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.Warhead == null || e.Warhead.InfDeath != Info.InfDeath) return;
|
if (e.Warhead == null || e.Warhead.InfDeath != spawnViceroidInfo.InfDeath) return;
|
||||||
if (self.World.SharedRandom.Next(100) > Info.Probability) return;
|
if (self.World.SharedRandom.Next(100) > spawnViceroidInfo.Probability) return;
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var td = new TypeDictionary
|
var td = new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit( self.Location ),
|
new LocationInit(self.Location),
|
||||||
new OwnerInit( self.World.Players.First(p => p.InternalName == Info.Owner) )
|
new OwnerInit(self.World.Players.First(p => p.InternalName == spawnViceroidInfo.Owner))
|
||||||
};
|
};
|
||||||
|
|
||||||
var facing = self.TraitOrDefault<IFacing>();
|
var facing = self.TraitOrDefault<IFacing>();
|
||||||
if (facing != null)
|
if (facing != null)
|
||||||
td.Add(new FacingInit( facing.Facing ));
|
td.Add(new FacingInit(facing.Facing));
|
||||||
|
|
||||||
w.CreateActor(Info.ViceroidActor, td);
|
w.CreateActor(spawnViceroidInfo.ViceroidActor, td);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
public class TiberiumRefinery : OreRefinery
|
public class TiberiumRefinery : OreRefinery
|
||||||
{
|
{
|
||||||
public TiberiumRefinery(Actor self, TiberiumRefineryInfo info)
|
public TiberiumRefinery(Actor self, TiberiumRefineryInfo info) : base(self, info) { }
|
||||||
: base(self, info) {}
|
|
||||||
|
|
||||||
public override Activity DockSequence(Actor harv, Actor self)
|
public override Activity DockSequence(Actor harv, Actor self)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,12 +26,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
var hotkeyLabel = "({0})".F(button.Key.ToUpperInvariant());
|
var hotkeyLabel = "({0})".F(button.Key.ToUpperInvariant());
|
||||||
hotkey.GetText = () => hotkeyLabel;
|
hotkey.GetText = () => hotkeyLabel;
|
||||||
hotkey.Bounds.X = labelWidth + 2*label.Bounds.X;
|
hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X;
|
||||||
|
|
||||||
var panelWidth = hotkey.Bounds.X + label.Bounds.X
|
var panelWidth = hotkey.Bounds.X + label.Bounds.X
|
||||||
+ Game.Renderer.Fonts[label.Font].Measure(hotkeyLabel).X;
|
+ Game.Renderer.Fonts[label.Font].Measure(hotkeyLabel).X;
|
||||||
widget.Bounds.Width = panelWidth;
|
widget.Bounds.Width = panelWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +24,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
Widget ingameRoot;
|
Widget ingameRoot;
|
||||||
World world;
|
World world;
|
||||||
|
|
||||||
|
static void BindOrderButton<T>(World world, Widget parent, string button, string icon)
|
||||||
|
where T : IOrderGenerator, new()
|
||||||
|
{
|
||||||
|
var w = parent.Get<ButtonWidget>(button);
|
||||||
|
w.OnClick = () => world.ToggleInputMode<T>();
|
||||||
|
w.IsHighlighted = () => world.OrderGenerator is T;
|
||||||
|
|
||||||
|
w.Get<ImageWidget>("ICON").GetImageName =
|
||||||
|
() => world.OrderGenerator is T ? icon + "-active" : icon;
|
||||||
|
}
|
||||||
|
|
||||||
void AddChatLine(Color c, string from, string text)
|
void AddChatLine(Color c, string from, string text)
|
||||||
{
|
{
|
||||||
ingameRoot.Get<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
|
ingameRoot.Get<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
|
||||||
@@ -114,7 +125,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
|
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
|
||||||
|
|
||||||
if (radarEnabled != cachedRadarEnabled)
|
if (radarEnabled != cachedRadarEnabled)
|
||||||
Sound.PlayNotification(null, "Sounds", (radarEnabled ? "RadarUp" : "RadarDown"), null);
|
Sound.PlayNotification(null, "Sounds", radarEnabled ? "RadarUp" : "RadarDown", null);
|
||||||
cachedRadarEnabled = radarEnabled;
|
cachedRadarEnabled = radarEnabled;
|
||||||
|
|
||||||
// Switch to observer mode after win/loss
|
// Switch to observer mode after win/loss
|
||||||
@@ -152,16 +163,5 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
return Color.LimeGreen;
|
return Color.LimeGreen;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BindOrderButton<T>(World world, Widget parent, string button, string icon)
|
|
||||||
where T : IOrderGenerator, new()
|
|
||||||
{
|
|
||||||
var w = parent.Get<ButtonWidget>(button);
|
|
||||||
w.OnClick = () => world.ToggleInputMode<T>();
|
|
||||||
w.IsHighlighted = () => world.OrderGenerator is T;
|
|
||||||
|
|
||||||
w.Get<ImageWidget>("ICON").GetImageName =
|
|
||||||
() => world.OrderGenerator is T ? icon+"-active" : icon;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Action doNothing = () => {};
|
Action doNothing = () => { };
|
||||||
|
|
||||||
menu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = () =>
|
menu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = () =>
|
||||||
CncWidgetUtils.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, doNothing);
|
CncWidgetUtils.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, doNothing);
|
||||||
@@ -92,35 +92,35 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
// Menu panels - ordered from lowest to highest priority
|
// Menu panels - ordered from lowest to highest priority
|
||||||
var panelParent = Game.OpenWindow(world, "INGAME_MENU_PANEL");
|
var panelParent = Game.OpenWindow(world, "INGAME_MENU_PANEL");
|
||||||
PanelType Panel = PanelType.Objectives;
|
PanelType panelType = PanelType.Objectives;
|
||||||
var visibleButtons = 0;
|
var visibleButtons = 0;
|
||||||
|
|
||||||
// Debug / Cheats panel
|
// Debug / Cheats panel
|
||||||
var debugButton = panelParent.Get<ButtonWidget>("DEBUG_BUTTON");
|
var debugButton = panelParent.Get<ButtonWidget>("DEBUG_BUTTON");
|
||||||
debugButton.OnClick = () => Panel = PanelType.Debug;
|
debugButton.OnClick = () => panelType = PanelType.Debug;
|
||||||
debugButton.IsHighlighted = () => Panel == PanelType.Debug;
|
debugButton.IsHighlighted = () => panelType == PanelType.Debug;
|
||||||
|
|
||||||
if (world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats)
|
if (world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats)
|
||||||
{
|
{
|
||||||
Panel = PanelType.Debug;
|
panelType = PanelType.Debug;
|
||||||
visibleButtons++;
|
visibleButtons++;
|
||||||
var debugPanel = Game.LoadWidget(world, "CHEATS_PANEL", panelParent, new WidgetArgs(){{"onExit", doNothing}});
|
var debugPanel = Game.LoadWidget(world, "CHEATS_PANEL", panelParent, new WidgetArgs() { { "onExit", doNothing } });
|
||||||
debugPanel.IsVisible = () => Panel == PanelType.Debug;
|
debugPanel.IsVisible = () => panelType == PanelType.Debug;
|
||||||
debugButton.IsVisible = () => visibleButtons > 1;
|
debugButton.IsVisible = () => visibleButtons > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mission objectives
|
// Mission objectives
|
||||||
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
||||||
var objectivesButton = panelParent.Get<ButtonWidget>("OBJECTIVES_BUTTON");
|
var objectivesButton = panelParent.Get<ButtonWidget>("OBJECTIVES_BUTTON");
|
||||||
objectivesButton.OnClick = () => Panel = PanelType.Objectives;
|
objectivesButton.OnClick = () => panelType = PanelType.Objectives;
|
||||||
objectivesButton.IsHighlighted = () => Panel == PanelType.Objectives;
|
objectivesButton.IsHighlighted = () => panelType == PanelType.Objectives;
|
||||||
|
|
||||||
if (iop != null && iop.ObjectivesPanel != null)
|
if (iop != null && iop.ObjectivesPanel != null)
|
||||||
{
|
{
|
||||||
Panel = PanelType.Objectives;
|
panelType = PanelType.Objectives;
|
||||||
visibleButtons++;
|
visibleButtons++;
|
||||||
var objectivesPanel = Game.LoadWidget(world, iop.ObjectivesPanel, panelParent, new WidgetArgs());
|
var objectivesPanel = Game.LoadWidget(world, iop.ObjectivesPanel, panelParent, new WidgetArgs());
|
||||||
objectivesPanel.IsVisible = () => Panel == PanelType.Objectives;
|
objectivesPanel.IsVisible = () => panelType == PanelType.Objectives;
|
||||||
objectivesButton.IsVisible = () => visibleButtons > 1;
|
objectivesButton.IsVisible = () => visibleButtons > 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
public static bool IsValidDisk(string diskRoot)
|
public static bool IsValidDisk(string diskRoot)
|
||||||
{
|
{
|
||||||
var files = new string[][] {
|
var files = new string[][] {
|
||||||
new [] { diskRoot, "CONQUER.MIX" },
|
new[] { diskRoot, "CONQUER.MIX" },
|
||||||
new [] { diskRoot, "DESERT.MIX" },
|
new[] { diskRoot, "DESERT.MIX" },
|
||||||
new [] { diskRoot, "INSTALL", "SETUP.Z" },
|
new[] { diskRoot, "INSTALL", "SETUP.Z" },
|
||||||
};
|
};
|
||||||
|
|
||||||
return files.All(f => File.Exists(f.Aggregate(Path.Combine)));
|
return files.All(f => File.Exists(f.Aggregate(Path.Combine)));
|
||||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var installTotal = filesToExtract.Count() + filesToExtract.Count();
|
var installTotal = filesToExtract.Count() + filesToExtract.Count();
|
||||||
var onProgress = (Action<string>)(s => Game.RunAfterTick(() =>
|
var onProgress = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||||
{
|
{
|
||||||
progressBar.Percentage = installCounter*100/installTotal;
|
progressBar.Percentage = installCounter * 100 / installTotal;
|
||||||
installCounter++;
|
installCounter++;
|
||||||
|
|
||||||
statusLabel.GetText = () => s;
|
statusLabel.GetText = () => s;
|
||||||
@@ -97,12 +97,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
var onError = (Action<string>)(s => Game.RunAfterTick(() =>
|
var onError = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||||
{
|
{
|
||||||
statusLabel.GetText = () => "Error: "+s;
|
statusLabel.GetText = () => "Error: " + s;
|
||||||
backButton.IsDisabled = () => false;
|
backButton.IsDisabled = () => false;
|
||||||
retryButton.IsDisabled = () => false;
|
retryButton.IsDisabled = () => false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
new Thread( _ =>
|
new Thread(_ =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
public class CncInstallLogic
|
public class CncInstallLogic
|
||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncInstallLogic(Widget widget, Dictionary<string,string> installData, Action continueLoading)
|
public CncInstallLogic(Widget widget, Dictionary<string, string> installData, Action continueLoading)
|
||||||
{
|
{
|
||||||
var panel = widget.Get("INSTALL_PANEL");
|
var panel = widget.Get("INSTALL_PANEL");
|
||||||
var args = new WidgetArgs()
|
var args = new WidgetArgs()
|
||||||
@@ -43,8 +43,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
|
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => {} },
|
{ "onExit", () => { } },
|
||||||
// Close this panel
|
|
||||||
{ "onSwitch", Ui.CloseWindow },
|
{ "onSwitch", Ui.CloseWindow },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class CncMenuLogic
|
public class CncMenuLogic
|
||||||
{
|
{
|
||||||
enum MenuType { Main, Multiplayer, Settings, None }
|
enum MenuType { Main, Multiplayer, Settings, None }
|
||||||
|
|
||||||
MenuType Menu = MenuType.Main;
|
MenuType menuType = MenuType.Main;
|
||||||
Widget rootMenu;
|
Widget rootMenu;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
@@ -32,85 +32,85 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
// Menu buttons
|
// Menu buttons
|
||||||
var mainMenu = widget.Get("MAIN_MENU");
|
var mainMenu = widget.Get("MAIN_MENU");
|
||||||
mainMenu.IsVisible = () => Menu == MenuType.Main;
|
mainMenu.IsVisible = () => menuType == MenuType.Main;
|
||||||
|
|
||||||
mainMenu.Get<ButtonWidget>("SOLO_BUTTON").OnClick = StartSkirmishGame;
|
mainMenu.Get<ButtonWidget>("SOLO_BUTTON").OnClick = StartSkirmishGame;
|
||||||
mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = () => Menu = MenuType.Multiplayer;
|
mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = () => menuType = MenuType.Multiplayer;
|
||||||
|
|
||||||
mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
|
mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
menuType = MenuType.None;
|
||||||
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
|
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => Menu = MenuType.Main },
|
{ "onExit", () => menuType = MenuType.Main },
|
||||||
{ "onSwitch", RemoveShellmapUI }
|
{ "onSwitch", RemoveShellmapUI }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => Menu = MenuType.Settings;
|
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => menuType = MenuType.Settings;
|
||||||
mainMenu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
mainMenu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
||||||
|
|
||||||
// Multiplayer menu
|
// Multiplayer menu
|
||||||
var multiplayerMenu = widget.Get("MULTIPLAYER_MENU");
|
var multiplayerMenu = widget.Get("MULTIPLAYER_MENU");
|
||||||
multiplayerMenu.IsVisible = () => Menu == MenuType.Multiplayer;
|
multiplayerMenu.IsVisible = () => menuType == MenuType.Multiplayer;
|
||||||
|
|
||||||
multiplayerMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main;
|
multiplayerMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => menuType = MenuType.Main;
|
||||||
multiplayerMenu.Get<ButtonWidget>("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL");
|
multiplayerMenu.Get<ButtonWidget>("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL");
|
||||||
multiplayerMenu.Get<ButtonWidget>("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL");
|
multiplayerMenu.Get<ButtonWidget>("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL");
|
||||||
multiplayerMenu.Get<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL");
|
multiplayerMenu.Get<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL");
|
||||||
|
|
||||||
// Settings menu
|
// Settings menu
|
||||||
var settingsMenu = widget.Get("SETTINGS_MENU");
|
var settingsMenu = widget.Get("SETTINGS_MENU");
|
||||||
settingsMenu.IsVisible = () => Menu == MenuType.Settings;
|
settingsMenu.IsVisible = () => menuType == MenuType.Settings;
|
||||||
|
|
||||||
settingsMenu.Get<ButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
|
settingsMenu.Get<ButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
menuType = MenuType.None;
|
||||||
Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
|
Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => Menu = MenuType.Settings },
|
{ "onExit", () => menuType = MenuType.Settings },
|
||||||
{ "onStart", RemoveShellmapUI }
|
{ "onStart", RemoveShellmapUI }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
settingsMenu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
settingsMenu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
menuType = MenuType.None;
|
||||||
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
|
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => Menu = MenuType.Settings },
|
{ "onExit", () => menuType = MenuType.Settings },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
settingsMenu.Get<ButtonWidget>("CREDITS_BUTTON").OnClick = () =>
|
settingsMenu.Get<ButtonWidget>("CREDITS_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
menuType = MenuType.None;
|
||||||
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs()
|
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => Menu = MenuType.Settings },
|
{ "onExit", () => menuType = MenuType.Settings },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
|
settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
menuType = MenuType.None;
|
||||||
Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
|
Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => Menu = MenuType.Settings },
|
{ "onExit", () => menuType = MenuType.Settings },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
settingsMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main;
|
settingsMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => menuType = MenuType.Main;
|
||||||
|
|
||||||
rootMenu.Get<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
|
rootMenu.Get<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGamePanel(string id)
|
void OpenGamePanel(string id)
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
menuType = MenuType.None;
|
||||||
Ui.OpenWindow(id, new WidgetArgs()
|
Ui.OpenWindow(id, new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => Menu = MenuType.Multiplayer },
|
{ "onExit", () => menuType = MenuType.Multiplayer },
|
||||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -122,10 +122,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
void OpenLobbyPanel(MenuType menu, bool addBots)
|
void OpenLobbyPanel(MenuType menu, bool addBots)
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
menuType = MenuType.None;
|
||||||
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", () => { Game.Disconnect(); Menu = menu; } },
|
{ "onExit", () => { Game.Disconnect(); menuType = menu; } },
|
||||||
{ "onStart", RemoveShellmapUI },
|
{ "onStart", RemoveShellmapUI },
|
||||||
{ "addBots", addBots }
|
{ "addBots", addBots }
|
||||||
});
|
});
|
||||||
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
ConnectionLogic.Connect(IPAddress.Loopback.ToString(),
|
ConnectionLogic.Connect(IPAddress.Loopback.ToString(),
|
||||||
Game.CreateLocalServer(map),
|
Game.CreateLocalServer(map),
|
||||||
() => OpenLobbyPanel(MenuType.Main, true),
|
() => OpenLobbyPanel(MenuType.Main, true),
|
||||||
() => { Game.CloseServer(); Menu = MenuType.Main; });
|
() => { Game.CloseServer(); menuType = MenuType.Main; });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.FileFormats.Graphics;
|
using OpenRA.FileFormats.Graphics;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
|
using OpenRA.Mods.RA.Widgets;
|
||||||
using OpenRA.Mods.RA.Widgets.Logic;
|
using OpenRA.Mods.RA.Widgets.Logic;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using OpenRA.Mods.RA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
{
|
{
|
||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
enum PanelType { General, Input }
|
enum PanelType { General, Input }
|
||||||
|
|
||||||
SoundDevice soundDevice;
|
SoundDevice soundDevice;
|
||||||
PanelType Settings = PanelType.General;
|
PanelType settingsPanel = PanelType.General;
|
||||||
ColorPreviewManagerWidget colorPreview;
|
ColorPreviewManagerWidget colorPreview;
|
||||||
World world;
|
World world;
|
||||||
|
|
||||||
@@ -39,11 +39,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
// General pane
|
// General pane
|
||||||
var generalButton = panel.Get<ButtonWidget>("GENERAL_BUTTON");
|
var generalButton = panel.Get<ButtonWidget>("GENERAL_BUTTON");
|
||||||
generalButton.OnClick = () => Settings = PanelType.General;
|
generalButton.OnClick = () => settingsPanel = PanelType.General;
|
||||||
generalButton.IsHighlighted = () => Settings == PanelType.General;
|
generalButton.IsHighlighted = () => settingsPanel == PanelType.General;
|
||||||
|
|
||||||
var generalPane = panel.Get("GENERAL_CONTROLS");
|
var generalPane = panel.Get("GENERAL_CONTROLS");
|
||||||
generalPane.IsVisible = () => Settings == PanelType.General;
|
generalPane.IsVisible = () => settingsPanel == PanelType.General;
|
||||||
|
|
||||||
var gameSettings = Game.Settings.Game;
|
var gameSettings = Game.Settings.Game;
|
||||||
var playerSettings = Game.Settings.Player;
|
var playerSettings = Game.Settings.Player;
|
||||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
var soundSlider = generalPane.Get<SliderWidget>("SOUND_SLIDER");
|
var soundSlider = generalPane.Get<SliderWidget>("SOUND_SLIDER");
|
||||||
soundSlider.OnChange += x => { soundSettings.SoundVolume = x; Sound.SoundVolume = x;};
|
soundSlider.OnChange += x => { soundSettings.SoundVolume = x; Sound.SoundVolume = x; };
|
||||||
soundSlider.Value = soundSettings.SoundVolume;
|
soundSlider.Value = soundSettings.SoundVolume;
|
||||||
|
|
||||||
var musicSlider = generalPane.Get<SliderWidget>("MUSIC_SLIDER");
|
var musicSlider = generalPane.Get<SliderWidget>("MUSIC_SLIDER");
|
||||||
@@ -122,11 +122,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
// Input pane
|
// Input pane
|
||||||
var inputPane = panel.Get("INPUT_CONTROLS");
|
var inputPane = panel.Get("INPUT_CONTROLS");
|
||||||
inputPane.IsVisible = () => Settings == PanelType.Input;
|
inputPane.IsVisible = () => settingsPanel == PanelType.Input;
|
||||||
|
|
||||||
var inputButton = panel.Get<ButtonWidget>("INPUT_BUTTON");
|
var inputButton = panel.Get<ButtonWidget>("INPUT_BUTTON");
|
||||||
inputButton.OnClick = () => Settings = PanelType.Input;
|
inputButton.OnClick = () => settingsPanel = PanelType.Input;
|
||||||
inputButton.IsHighlighted = () => Settings == PanelType.Input;
|
inputButton.IsHighlighted = () => settingsPanel == PanelType.Input;
|
||||||
|
|
||||||
var classicMouseCheckbox = inputPane.Get<CheckboxWidget>("CLASSICORDERS_CHECKBOX");
|
var classicMouseCheckbox = inputPane.Get<CheckboxWidget>("CLASSICORDERS_CHECKBOX");
|
||||||
classicMouseCheckbox.IsChecked = () => gameSettings.UseClassicMouseStyle;
|
classicMouseCheckbox.IsChecked = () => gameSettings.UseClassicMouseStyle;
|
||||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
int x, y;
|
int x, y;
|
||||||
int.TryParse(windowWidth.Text, out x);
|
int.TryParse(windowWidth.Text, out x);
|
||||||
int.TryParse(windowHeight.Text, out y);
|
int.TryParse(windowHeight.Text, out y);
|
||||||
graphicsSettings.WindowedSize = new int2(x,y);
|
graphicsSettings.WindowedSize = new int2(x, y);
|
||||||
soundSettings.Device = soundDevice.Device;
|
soundSettings.Device = soundDevice.Device;
|
||||||
soundSettings.Engine = soundDevice.Engine;
|
soundSettings.Engine = soundDevice.Engine;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
@@ -163,6 +163,28 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ShowMouseScrollDropdown(DropDownButtonWidget dropdown, GameSettings s)
|
||||||
|
{
|
||||||
|
var options = new Dictionary<string, MouseScrollType>()
|
||||||
|
{
|
||||||
|
{ "Disabled", MouseScrollType.Disabled },
|
||||||
|
{ "Standard", MouseScrollType.Standard },
|
||||||
|
{ "Inverted", MouseScrollType.Inverted },
|
||||||
|
};
|
||||||
|
|
||||||
|
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
|
() => s.MouseScroll == options[o],
|
||||||
|
() => s.MouseScroll = options[o]);
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
|
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
|
||||||
{
|
{
|
||||||
Action<HSLColor> onChange = c => colorPreview.Color = c;
|
Action<HSLColor> onChange = c => colorPreview.Color = c;
|
||||||
@@ -183,28 +205,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ShowMouseScrollDropdown(DropDownButtonWidget dropdown, GameSettings s)
|
|
||||||
{
|
|
||||||
var options = new Dictionary<string, MouseScrollType>()
|
|
||||||
{
|
|
||||||
{ "Disabled", MouseScrollType.Disabled },
|
|
||||||
{ "Standard", MouseScrollType.Standard },
|
|
||||||
{ "Inverted", MouseScrollType.Inverted },
|
|
||||||
};
|
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
|
||||||
{
|
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
|
||||||
() => s.MouseScroll == options[o],
|
|
||||||
() => s.MouseScroll = options[o]);
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
|
||||||
return item;
|
|
||||||
};
|
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundSettings s, SoundDevice[] devices)
|
bool ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundSettings s, SoundDevice[] devices)
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Mods.RA.Orders;
|
|
||||||
using OpenRA.Mods.RA.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
using OpenRA.Mods.RA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
||||||
var icon = button.Get<ImageWidget>("ICON");
|
var icon = button.Get<ImageWidget>("ICON");
|
||||||
icon.GetImageName = () => button.IsDisabled() ? chromeName+"-disabled" :
|
icon.GetImageName = () => button.IsDisabled() ? chromeName + "-disabled" :
|
||||||
tabs.Groups[button.ProductionGroup].Alert ? chromeName+"-alert" : chromeName;
|
tabs.Groups[button.ProductionGroup].Alert ? chromeName + "-alert" : chromeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public ProductionTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ProductionPaletteWidget palette)
|
public ProductionTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ProductionPaletteWidget palette)
|
||||||
{
|
{
|
||||||
var pm = palette.world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
var pm = palette.World.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
||||||
var pr = palette.world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
var pr = palette.World.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
||||||
|
|
||||||
widget.IsVisible = () => palette.TooltipActor != null;
|
widget.IsVisible = () => palette.TooltipActor != null;
|
||||||
var nameLabel = widget.Get<LabelWidget>("NAME");
|
var nameLabel = widget.Get<LabelWidget>("NAME");
|
||||||
@@ -75,20 +75,20 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var descString = tooltip.Description.Replace("\\n", "\n");
|
var descString = tooltip.Description.Replace("\\n", "\n");
|
||||||
descLabel.GetText = () => descString;
|
descLabel.GetText = () => descString;
|
||||||
|
|
||||||
var leftWidth = new [] {font.Measure(tooltip.Name).X, requiresFont.Measure(requiresString).X, descFont.Measure(descString).X}.Aggregate(Math.Max);
|
var leftWidth = new[] { font.Measure(tooltip.Name).X, requiresFont.Measure(requiresString).X, descFont.Measure(descString).X }.Aggregate(Math.Max);
|
||||||
var rightWidth = new [] {font.Measure(powerString).X, font.Measure(timeString).X, font.Measure(costString).X}.Aggregate(Math.Max);
|
var rightWidth = new[] { font.Measure(powerString).X, font.Measure(timeString).X, font.Measure(costString).X }.Aggregate(Math.Max);
|
||||||
timeLabel.Bounds.X = powerLabel.Bounds.X = costLabel.Bounds.X = leftWidth + 2*nameLabel.Bounds.X;
|
timeLabel.Bounds.X = powerLabel.Bounds.X = costLabel.Bounds.X = leftWidth + 2 * nameLabel.Bounds.X;
|
||||||
widget.Bounds.Width = leftWidth + rightWidth + 3*nameLabel.Bounds.X;
|
widget.Bounds.Width = leftWidth + rightWidth + 3 * nameLabel.Bounds.X;
|
||||||
|
|
||||||
var leftHeight = font.Measure(tooltip.Name).Y + requiresFont.Measure(requiresString).Y + descFont.Measure(descString).Y;
|
var leftHeight = font.Measure(tooltip.Name).Y + requiresFont.Measure(requiresString).Y + descFont.Measure(descString).Y;
|
||||||
var rightHeight = font.Measure(powerString).Y + font.Measure(timeString).Y + font.Measure(costString).Y;
|
var rightHeight = font.Measure(powerString).Y + font.Measure(timeString).Y + font.Measure(costString).Y;
|
||||||
widget.Bounds.Height = Math.Max(leftHeight, rightHeight)*3/2 + 3*nameLabel.Bounds.Y;
|
widget.Bounds.Height = Math.Max(leftHeight, rightHeight) * 3 / 2 + 3 * nameLabel.Bounds.Y;
|
||||||
|
|
||||||
lastActor = actor;
|
lastActor = actor;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static string ActorName( string a )
|
static string ActorName(string a)
|
||||||
{
|
{
|
||||||
ActorInfo ai;
|
ActorInfo ai;
|
||||||
Rules.Info.TryGetValue(a.ToLowerInvariant(), out ai);
|
Rules.Info.TryGetValue(a.ToLowerInvariant(), out ai);
|
||||||
@@ -98,5 +98,4 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
return; // no instances actually exist (race with destroy)
|
return; // no instances actually exist (race with destroy)
|
||||||
|
|
||||||
time = "{0} / {1}".F(WidgetUtils.FormatTime(sp.RemainingTime),
|
time = "{0} / {1}".F(WidgetUtils.FormatTime(sp.RemainingTime),
|
||||||
WidgetUtils.FormatTime(sp.Info.ChargeTime*25));
|
WidgetUtils.FormatTime(sp.Info.ChargeTime * 25));
|
||||||
|
|
||||||
if (sp == lastPower)
|
if (sp == lastPower)
|
||||||
return;
|
return;
|
||||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var timeWidth = timeFont.Measure(time).X;
|
var timeWidth = timeFont.Measure(time).X;
|
||||||
var topWidth = nameFont.Measure(name).X + timeWidth + timeOffset;
|
var topWidth = nameFont.Measure(name).X + timeWidth + timeOffset;
|
||||||
var descSize = descFont.Measure(desc);
|
var descSize = descFont.Measure(desc);
|
||||||
widget.Bounds.Width = 2*nameLabel.Bounds.X + Math.Max(topWidth, descSize.X);
|
widget.Bounds.Width = 2 * nameLabel.Bounds.X + Math.Max(topWidth, descSize.X);
|
||||||
widget.Bounds.Height = baseHeight + descSize.Y;
|
widget.Bounds.Height = baseHeight + descSize.Y;
|
||||||
timeLabel.Bounds.X = widget.Bounds.Width - nameLabel.Bounds.X - timeWidth;
|
timeLabel.Bounds.X = widget.Bounds.Width - nameLabel.Bounds.X - timeWidth;
|
||||||
lastPower = sp;
|
lastPower = sp;
|
||||||
@@ -64,5 +64,4 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
descLabel.GetText = () => desc;
|
descLabel.GetText = () => desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
public readonly string HoldText = "";
|
public readonly string HoldText = "";
|
||||||
|
|
||||||
public string TooltipActor { get; private set; }
|
public string TooltipActor { get; private set; }
|
||||||
public readonly World world;
|
public readonly World World;
|
||||||
|
|
||||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||||
ProductionQueue currentQueue;
|
ProductionQueue currentQueue;
|
||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override Rectangle EventBounds { get { return eventBounds; } }
|
public override Rectangle EventBounds { get { return eventBounds; } }
|
||||||
Dictionary<Rectangle, ProductionIcon> Icons = new Dictionary<Rectangle, ProductionIcon>();
|
Dictionary<Rectangle, ProductionIcon> icons = new Dictionary<Rectangle, ProductionIcon>();
|
||||||
Dictionary<string, Sprite> iconSprites;
|
Dictionary<string, Sprite> iconSprites;
|
||||||
Animation cantBuild, clock;
|
Animation cantBuild, clock;
|
||||||
Rectangle eventBounds = Rectangle.Empty;
|
Rectangle eventBounds = Rectangle.Empty;
|
||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public ProductionPaletteWidget(World world, WorldRenderer worldRenderer)
|
public ProductionPaletteWidget(World world, WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.World = world;
|
||||||
this.worldRenderer = worldRenderer;
|
this.worldRenderer = worldRenderer;
|
||||||
tooltipContainer = Lazy.New(() =>
|
tooltipContainer = Lazy.New(() =>
|
||||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
if (TooltipContainer != null)
|
if (TooltipContainer != null)
|
||||||
tooltipContainer.Value.SetTooltip(TooltipTemplate,
|
tooltipContainer.Value.SetTooltip(TooltipTemplate,
|
||||||
new WidgetArgs() {{ "palette", this }});
|
new WidgetArgs() { { "palette", this } });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void MouseExited()
|
public override void MouseExited()
|
||||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
public override bool HandleMouseInput(MouseInput mi)
|
public override bool HandleMouseInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
var icon = Icons.Where(i => i.Key.Contains(mi.Location))
|
var icon = icons.Where(i => i.Key.Contains(mi.Location))
|
||||||
.Select(i => i.Value).FirstOrDefault();
|
.Select(i => i.Value).FirstOrDefault();
|
||||||
|
|
||||||
if (mi.Event == MouseInputEvent.Move)
|
if (mi.Event == MouseInputEvent.Move)
|
||||||
@@ -126,29 +126,28 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
if (first != null && first.Done && actor.Traits.Contains<BuildingInfo>())
|
if (first != null && first.Done && actor.Traits.Contains<BuildingInfo>())
|
||||||
{
|
{
|
||||||
Sound.Play(TabClick);
|
Sound.Play(TabClick);
|
||||||
world.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, icon.Name);
|
World.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, icon.Name);
|
||||||
}
|
}
|
||||||
// Resume a paused item
|
|
||||||
else if (first != null && first.Paused)
|
else if (first != null && first.Paused)
|
||||||
{
|
{
|
||||||
|
// Resume a paused item
|
||||||
Sound.Play(TabClick);
|
Sound.Play(TabClick);
|
||||||
world.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, false));
|
World.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, false));
|
||||||
}
|
}
|
||||||
// Queue a new item
|
|
||||||
else if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
|
else if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
|
||||||
{
|
{
|
||||||
|
// Queue a new item
|
||||||
Sound.Play(TabClick);
|
Sound.Play(TabClick);
|
||||||
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Country.Race);
|
||||||
world.IssueOrder(Order.StartProduction(CurrentQueue.self, icon.Name,
|
World.IssueOrder(Order.StartProduction(CurrentQueue.self, icon.Name,
|
||||||
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
|
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Sound.Play(DisabledTabClick);
|
Sound.Play(DisabledTabClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hold/Cancel an existing item
|
|
||||||
else if (mi.Button == MouseButton.Right)
|
else if (mi.Button == MouseButton.Right)
|
||||||
{
|
{
|
||||||
|
// Hold/Cancel an existing item
|
||||||
if (first != null)
|
if (first != null)
|
||||||
{
|
{
|
||||||
Sound.Play(TabClick);
|
Sound.Play(TabClick);
|
||||||
@@ -156,25 +155,26 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
// instant cancel of things we havent started yet and things that are finished
|
// instant cancel of things we havent started yet and things that are finished
|
||||||
if (first.Paused || first.Done || first.TotalCost == first.RemainingCost)
|
if (first.Paused || first.Done || first.TotalCost == first.RemainingCost)
|
||||||
{
|
{
|
||||||
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Country.Race);
|
||||||
world.IssueOrder(Order.CancelProduction(CurrentQueue.self, icon.Name,
|
World.IssueOrder(Order.CancelProduction(CurrentQueue.self, icon.Name,
|
||||||
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
|
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Country.Race);
|
||||||
world.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, true));
|
World.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Sound.Play(DisabledTabClick);
|
Sound.Play(DisabledTabClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshIcons()
|
public void RefreshIcons()
|
||||||
{
|
{
|
||||||
Icons = new Dictionary<Rectangle, ProductionIcon>();
|
icons = new Dictionary<Rectangle, ProductionIcon>();
|
||||||
if (CurrentQueue == null)
|
if (CurrentQueue == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
var x = i % Columns;
|
var x = i % Columns;
|
||||||
var y = i / Columns;
|
var y = i / Columns;
|
||||||
var rect = new Rectangle(rb.X + x * 64 + 1, rb.Y + y * 48 + 1, 64, 48);
|
var rect = new Rectangle(rb.X + x * 64 + 1, rb.Y + y * 48 + 1, 64, 48);
|
||||||
var pi = new ProductionIcon()
|
var pi = new ProductionIcon()
|
||||||
{
|
{
|
||||||
Name = item.Name,
|
Name = item.Name,
|
||||||
@@ -193,20 +193,20 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
Pos = new float2(rect.Location),
|
Pos = new float2(rect.Location),
|
||||||
Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
|
Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
|
||||||
};
|
};
|
||||||
Icons.Add(rect, pi);
|
icons.Add(rect, pi);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBounds = Icons.Keys.Aggregate(Rectangle.Union);
|
eventBounds = icons.Keys.Aggregate(Rectangle.Union);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
overlayFont = Game.Renderer.Fonts["TinyBold"];
|
overlayFont = Game.Renderer.Fonts["TinyBold"];
|
||||||
timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
|
timeOffset = new float2(32, 24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
|
||||||
queuedOffset = new float2(4,2);
|
queuedOffset = new float2(4, 2);
|
||||||
holdOffset = new float2(32,24) - overlayFont.Measure(HoldText) / 2;
|
holdOffset = new float2(32, 24) - overlayFont.Measure(HoldText) / 2;
|
||||||
readyOffset = new float2(32,24) - overlayFont.Measure(ReadyText) / 2;
|
readyOffset = new float2(32, 24) - overlayFont.Measure(ReadyText) / 2;
|
||||||
|
|
||||||
if (CurrentQueue == null)
|
if (CurrentQueue == null)
|
||||||
return;
|
return;
|
||||||
@@ -214,11 +214,11 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
|
var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
foreach (var rect in Icons.Keys)
|
foreach (var rect in icons.Keys)
|
||||||
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1,1,1,1));
|
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1));
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
foreach (var icon in Icons.Values)
|
foreach (var icon in icons.Values)
|
||||||
{
|
{
|
||||||
WidgetUtils.DrawSHP(icon.Sprite, icon.Pos, worldRenderer);
|
WidgetUtils.DrawSHP(icon.Sprite, icon.Pos, worldRenderer);
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
foreach (var icon in Icons.Values)
|
foreach (var icon in icons.Values)
|
||||||
{
|
{
|
||||||
var total = icon.Queued.Count;
|
var total = icon.Queued.Count;
|
||||||
if (total > 0)
|
if (total > 0)
|
||||||
@@ -267,7 +267,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
public override string GetCursor(int2 pos)
|
public override string GetCursor(int2 pos)
|
||||||
{
|
{
|
||||||
var icon = Icons.Where(i => i.Key.Contains(pos))
|
var icon = icons.Where(i => i.Key.Contains(pos))
|
||||||
.Select(i => i.Value).FirstOrDefault();
|
.Select(i => i.Value).FirstOrDefault();
|
||||||
|
|
||||||
return icon != null ? base.GetCursor(pos) : null;
|
return icon != null ? base.GetCursor(pos) : null;
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
public readonly int ArrowWidth = 20;
|
public readonly int ArrowWidth = 20;
|
||||||
public Dictionary<string, ProductionTabGroup> Groups;
|
public Dictionary<string, ProductionTabGroup> Groups;
|
||||||
|
|
||||||
int ContentWidth = 0;
|
int contentWidth = 0;
|
||||||
float ListOffset = 0;
|
float listOffset = 0;
|
||||||
bool leftPressed = false;
|
bool leftPressed = false;
|
||||||
bool rightPressed = false;
|
bool rightPressed = false;
|
||||||
Rectangle leftButtonRect;
|
Rectangle leftButtonRect;
|
||||||
@@ -107,10 +107,14 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
public string QueueGroup
|
public string QueueGroup
|
||||||
{
|
{
|
||||||
get { return queueGroup; }
|
get
|
||||||
|
{
|
||||||
|
return queueGroup;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
ListOffset = 0;
|
listOffset = 0;
|
||||||
queueGroup = value;
|
queueGroup = value;
|
||||||
SelectNextTab(false);
|
SelectNextTab(false);
|
||||||
}
|
}
|
||||||
@@ -118,7 +122,11 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
public ProductionQueue CurrentQueue
|
public ProductionQueue CurrentQueue
|
||||||
{
|
{
|
||||||
get { return paletteWidget.Value.CurrentQueue; }
|
get
|
||||||
|
{
|
||||||
|
return paletteWidget.Value.CurrentQueue;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
paletteWidget.Value.CurrentQueue = value;
|
paletteWidget.Value.CurrentQueue = value;
|
||||||
@@ -134,9 +142,9 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
leftButtonRect = new Rectangle(rb.X, rb.Y, ArrowWidth, rb.Height);
|
leftButtonRect = new Rectangle(rb.X, rb.Y, ArrowWidth, rb.Height);
|
||||||
rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height);
|
rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height);
|
||||||
|
|
||||||
var leftDisabled = ListOffset >= 0;
|
var leftDisabled = listOffset >= 0;
|
||||||
var leftHover = Ui.MouseOverWidget == this && leftButtonRect.Contains(Viewport.LastMousePos);
|
var leftHover = Ui.MouseOverWidget == this && leftButtonRect.Contains(Viewport.LastMousePos);
|
||||||
var rightDisabled = ListOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth;
|
var rightDisabled = listOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth;
|
||||||
var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos);
|
var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos);
|
||||||
|
|
||||||
WidgetUtils.DrawPanel("panel-black", rb);
|
WidgetUtils.DrawPanel("panel-black", rb);
|
||||||
@@ -150,20 +158,20 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
// Draw tab buttons
|
// Draw tab buttons
|
||||||
Game.Renderer.EnableScissor(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height);
|
Game.Renderer.EnableScissor(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height);
|
||||||
var origin = new int2(leftButtonRect.Right - 1 + (int)ListOffset, leftButtonRect.Y);
|
var origin = new int2(leftButtonRect.Right - 1 + (int)listOffset, leftButtonRect.Y);
|
||||||
SpriteFont font = Game.Renderer.Fonts["TinyBold"];
|
SpriteFont font = Game.Renderer.Fonts["TinyBold"];
|
||||||
ContentWidth = 0;
|
contentWidth = 0;
|
||||||
|
|
||||||
foreach (var tab in Groups[queueGroup].Tabs)
|
foreach (var tab in Groups[queueGroup].Tabs)
|
||||||
{
|
{
|
||||||
var rect = new Rectangle(origin.X + ContentWidth, origin.Y, TabWidth, rb.Height);
|
var rect = new Rectangle(origin.X + contentWidth, origin.Y, TabWidth, rb.Height);
|
||||||
var hover = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos);
|
var hover = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos);
|
||||||
var baseName = tab.Queue == CurrentQueue ? "button-highlighted" : "button";
|
var baseName = tab.Queue == CurrentQueue ? "button-highlighted" : "button";
|
||||||
ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false);
|
ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false);
|
||||||
ContentWidth += TabWidth - 1;
|
contentWidth += TabWidth - 1;
|
||||||
|
|
||||||
int2 textSize = font.Measure(tab.Name);
|
int2 textSize = font.Measure(tab.Name);
|
||||||
int2 position = new int2(rect.X + (rect.Width - textSize.X)/2, rect.Y + (rect.Height - textSize.Y)/2);
|
int2 position = new int2(rect.X + (rect.Width - textSize.X) / 2, rect.Y + (rect.Height - textSize.Y) / 2);
|
||||||
font.DrawTextWithContrast(tab.Name, position, tab.Queue.CurrentDone ? Color.Gold : Color.White, Color.Black, 1);
|
font.DrawTextWithContrast(tab.Name, position, tab.Queue.CurrentDone ? Color.Gold : Color.White, Color.Black, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +180,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
void Scroll(int direction)
|
void Scroll(int direction)
|
||||||
{
|
{
|
||||||
ListOffset += direction*ScrollVelocity;
|
listOffset += direction * ScrollVelocity;
|
||||||
ListOffset = Math.Min(0,Math.Max(Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth, ListOffset));
|
listOffset = Math.Min(0, Math.Max(Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth, listOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is added to world.ActorAdded by the SidebarLogic handler
|
// Is added to world.ActorAdded by the SidebarLogic handler
|
||||||
@@ -242,8 +250,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
leftPressed = leftButtonRect.Contains(mi.Location);
|
leftPressed = leftButtonRect.Contains(mi.Location);
|
||||||
rightPressed = rightButtonRect.Contains(mi.Location);
|
rightPressed = rightButtonRect.Contains(mi.Location);
|
||||||
var leftDisabled = ListOffset >= 0;
|
var leftDisabled = listOffset >= 0;
|
||||||
var rightDisabled = ListOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth;
|
var rightDisabled = listOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth;
|
||||||
|
|
||||||
if (leftPressed || rightPressed)
|
if (leftPressed || rightPressed)
|
||||||
{
|
{
|
||||||
@@ -254,10 +262,10 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check production tabs
|
// Check production tabs
|
||||||
var offsetloc = mi.Location - new int2(leftButtonRect.Right - 1 + (int)ListOffset, leftButtonRect.Y);
|
var offsetloc = mi.Location - new int2(leftButtonRect.Right - 1 + (int)listOffset, leftButtonRect.Y);
|
||||||
if (offsetloc.X > 0 && offsetloc.X < ContentWidth)
|
if (offsetloc.X > 0 && offsetloc.X < contentWidth)
|
||||||
{
|
{
|
||||||
CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X/(TabWidth - 1)].Queue;
|
CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X / (TabWidth - 1)].Queue;
|
||||||
Sound.PlayNotification(null, "Sounds", "ClickSound", null);
|
Sound.PlayNotification(null, "Sounds", "ClickSound", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
public readonly string ProductionGroup;
|
public readonly string ProductionGroup;
|
||||||
|
|
||||||
public ProductionTypeButtonWidget() : base() {}
|
public ProductionTypeButtonWidget() : base() { }
|
||||||
protected ProductionTypeButtonWidget(ProductionTypeButtonWidget other)
|
protected ProductionTypeButtonWidget(ProductionTypeButtonWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,31 +14,33 @@ using System.Drawing;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Widgets;
|
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
namespace OpenRA.Mods.Cnc.Widgets
|
||||||
{
|
{
|
||||||
public class SupportPowersWidget : Widget
|
public class SupportPowersWidget : Widget
|
||||||
{
|
{
|
||||||
public int Spacing = 10;
|
|
||||||
|
|
||||||
public readonly string ReadyText = "";
|
public readonly string ReadyText = "";
|
||||||
public readonly string HoldText = "";
|
public readonly string HoldText = "";
|
||||||
|
|
||||||
Dictionary<string, Sprite> iconSprites;
|
|
||||||
Animation clock;
|
|
||||||
Dictionary<Rectangle, SupportPowerIcon> Icons = new Dictionary<Rectangle, SupportPowerIcon>();
|
|
||||||
|
|
||||||
public readonly string TooltipContainer;
|
public readonly string TooltipContainer;
|
||||||
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
|
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
|
||||||
|
|
||||||
|
public int Spacing = 10;
|
||||||
|
|
||||||
|
readonly WorldRenderer worldRenderer;
|
||||||
|
readonly SupportPowerManager spm;
|
||||||
|
|
||||||
|
Dictionary<string, Sprite> iconSprites;
|
||||||
|
Animation clock;
|
||||||
|
Dictionary<Rectangle, SupportPowerIcon> icons = new Dictionary<Rectangle, SupportPowerIcon>();
|
||||||
|
|
||||||
public SupportPowerInstance TooltipPower { get; private set; }
|
public SupportPowerInstance TooltipPower { get; private set; }
|
||||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||||
|
|
||||||
Rectangle eventBounds;
|
Rectangle eventBounds;
|
||||||
public override Rectangle EventBounds { get { return eventBounds; } }
|
public override Rectangle EventBounds { get { return eventBounds; } }
|
||||||
readonly WorldRenderer worldRenderer;
|
|
||||||
readonly SupportPowerManager spm;
|
|
||||||
SpriteFont overlayFont;
|
SpriteFont overlayFont;
|
||||||
float2 holdOffset, readyOffset, timeOffset;
|
float2 holdOffset, readyOffset, timeOffset;
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
tooltipContainer = Lazy.New(() =>
|
tooltipContainer = Lazy.New(() =>
|
||||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||||
|
|
||||||
iconSprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() )
|
iconSprites = Rules.Info.Values.SelectMany(u => u.Traits.WithInterface<SupportPowerInfo>())
|
||||||
.Select(u => u.Image).Distinct()
|
.Select(u => u.Image).Distinct()
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
u => u,
|
u => u,
|
||||||
@@ -68,7 +70,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
public void RefreshIcons()
|
public void RefreshIcons()
|
||||||
{
|
{
|
||||||
Icons = new Dictionary<Rectangle, SupportPowerIcon>();
|
icons = new Dictionary<Rectangle, SupportPowerIcon>();
|
||||||
var powers = spm.Powers.Values.Where(p => !p.Disabled);
|
var powers = spm.Powers.Values.Where(p => !p.Disabled);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
@@ -83,26 +85,26 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
Sprite = iconSprites[p.Info.Image]
|
Sprite = iconSprites[p.Info.Image]
|
||||||
};
|
};
|
||||||
|
|
||||||
Icons.Add(rect, power);
|
icons.Add(rect, power);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBounds = (Icons.Count == 0) ? Rectangle.Empty : Icons.Keys.Aggregate(Rectangle.Union);
|
eventBounds = (icons.Count == 0) ? Rectangle.Empty : icons.Keys.Aggregate(Rectangle.Union);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
overlayFont = Game.Renderer.Fonts["TinyBold"];
|
overlayFont = Game.Renderer.Fonts["TinyBold"];
|
||||||
holdOffset = new float2(32,24) - overlayFont.Measure(HoldText) / 2;
|
holdOffset = new float2(32, 24) - overlayFont.Measure(HoldText) / 2;
|
||||||
readyOffset = new float2(32,24) - overlayFont.Measure(ReadyText) / 2;
|
readyOffset = new float2(32, 24) - overlayFont.Measure(ReadyText) / 2;
|
||||||
timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
|
timeOffset = new float2(32, 24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
foreach (var rect in Icons.Keys)
|
foreach (var rect in icons.Keys)
|
||||||
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1,1,1,1));
|
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1));
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
foreach (var p in Icons.Values)
|
foreach (var p in icons.Values)
|
||||||
{
|
{
|
||||||
WidgetUtils.DrawSHP(p.Sprite, p.Pos, worldRenderer);
|
WidgetUtils.DrawSHP(p.Sprite, p.Pos, worldRenderer);
|
||||||
|
|
||||||
@@ -115,7 +117,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Overlay
|
// Overlay
|
||||||
foreach (var p in Icons.Values)
|
foreach (var p in icons.Values)
|
||||||
{
|
{
|
||||||
if (p.Power.Ready)
|
if (p.Power.Ready)
|
||||||
overlayFont.DrawTextWithContrast(ReadyText,
|
overlayFont.DrawTextWithContrast(ReadyText,
|
||||||
@@ -142,7 +144,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
if (TooltipContainer == null) return;
|
if (TooltipContainer == null) return;
|
||||||
tooltipContainer.Value.SetTooltip(TooltipTemplate,
|
tooltipContainer.Value.SetTooltip(TooltipTemplate,
|
||||||
new WidgetArgs() {{ "palette", this }});
|
new WidgetArgs() { { "palette", this } });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void MouseExited()
|
public override void MouseExited()
|
||||||
@@ -155,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
if (mi.Event == MouseInputEvent.Move)
|
if (mi.Event == MouseInputEvent.Move)
|
||||||
{
|
{
|
||||||
var icon = Icons.Where(i => i.Key.Contains(mi.Location))
|
var icon = icons.Where(i => i.Key.Contains(mi.Location))
|
||||||
.Select(i => i.Value).FirstOrDefault();
|
.Select(i => i.Value).FirstOrDefault();
|
||||||
TooltipPower = (icon != null) ? icon.Power : null;
|
TooltipPower = (icon != null) ? icon.Power : null;
|
||||||
return false;
|
return false;
|
||||||
@@ -164,7 +166,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
if (mi.Event != MouseInputEvent.Down)
|
if (mi.Event != MouseInputEvent.Down)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var clicked = Icons.Where(i => i.Key.Contains(mi.Location))
|
var clicked = icons.Where(i => i.Key.Contains(mi.Location))
|
||||||
.Select(i => i.Value).FirstOrDefault();
|
.Select(i => i.Value).FirstOrDefault();
|
||||||
|
|
||||||
if (clicked != null)
|
if (clicked != null)
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
public class WithCargoInfo : ITraitInfo, Requires<CargoInfo>, Requires<IBodyOrientationInfo>
|
public class WithCargoInfo : ITraitInfo, Requires<CargoInfo>, Requires<IBodyOrientationInfo>
|
||||||
{
|
{
|
||||||
[Desc("Cargo position relative to turret or body. (forward, right, up) triples")]
|
[Desc("Cargo position relative to turret or body. (forward, right, up) triples")]
|
||||||
public readonly WRange[] LocalOffset = {};
|
public readonly WRange[] LocalOffset = { };
|
||||||
public readonly string[] DisplayTypes = {};
|
public readonly string[] DisplayTypes = { };
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithCargo(init.self, this); }
|
public object Create(ActorInitializer init) { return new WithCargo(init.self, this); }
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
Cargo cargo;
|
Cargo cargo;
|
||||||
IFacing facing;
|
IFacing facing;
|
||||||
WithCargoInfo Info;
|
WithCargoInfo cargoInfo;
|
||||||
WVec[] positions;
|
WVec[] positions;
|
||||||
IBodyOrientation body;
|
IBodyOrientation body;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
cargo = self.Trait<Cargo>();
|
cargo = self.Trait<Cargo>();
|
||||||
facing = self.TraitOrDefault<IFacing>();
|
facing = self.TraitOrDefault<IFacing>();
|
||||||
Info = info;
|
cargoInfo = info;
|
||||||
|
|
||||||
body = self.Trait<IBodyOrientation>();
|
body = self.Trait<IBodyOrientation>();
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
positions = new WVec[info.LocalOffset.Length / 3];
|
positions = new WVec[info.LocalOffset.Length / 3];
|
||||||
for (var i = 0; i < info.LocalOffset.Length / 3; i++)
|
for (var i = 0; i < info.LocalOffset.Length / 3; i++)
|
||||||
positions[i] = new WVec(info.LocalOffset[3*i], info.LocalOffset[3*i + 1], info.LocalOffset[3*i + 2]);
|
positions[i] = new WVec(info.LocalOffset[3 * i], info.LocalOffset[3 * i + 1], info.LocalOffset[3 * i + 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
cargoFacing.Facing = facing.Facing;
|
cargoFacing.Facing = facing.Facing;
|
||||||
|
|
||||||
var cargoPassenger = c.Trait<Passenger>();
|
var cargoPassenger = c.Trait<Passenger>();
|
||||||
if (Info.DisplayTypes.Contains(cargoPassenger.info.CargoType))
|
if (cargoInfo.DisplayTypes.Contains(cargoPassenger.info.CargoType))
|
||||||
{
|
{
|
||||||
var offset = pos - c.CenterPosition + body.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation));
|
var offset = pos - c.CenterPosition + body.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation));
|
||||||
foreach (var cr in c.Render(wr))
|
foreach (var cr in c.Render(wr))
|
||||||
|
|||||||
Reference in New Issue
Block a user