Merge branch 'master' of git://github.com/chrisforbes/OpenRA
This commit is contained in:
@@ -30,8 +30,16 @@ namespace OpenRa.Game
|
|||||||
readonly Sprite[] shimSprites;
|
readonly Sprite[] shimSprites;
|
||||||
readonly Sprite blank;
|
readonly Sprite blank;
|
||||||
|
|
||||||
|
readonly int paletteColumns;
|
||||||
|
readonly int2 paletteOrigin;
|
||||||
|
|
||||||
public Chrome(Renderer r)
|
public Chrome(Renderer r)
|
||||||
{
|
{
|
||||||
|
// Positioning of chrome elements
|
||||||
|
// Build palette
|
||||||
|
paletteColumns = 4;
|
||||||
|
paletteOrigin = new int2(Game.viewport.Width - paletteColumns * 64 - 9, 240 - 9);
|
||||||
|
|
||||||
this.renderer = r;
|
this.renderer = r;
|
||||||
specialBin = new Sheet(renderer, "specialbin.png");
|
specialBin = new Sheet(renderer, "specialbin.png");
|
||||||
chromeRenderer = new SpriteRenderer(renderer, true, renderer.RgbaSpriteShader);
|
chromeRenderer = new SpriteRenderer(renderer, true, renderer.RgbaSpriteShader);
|
||||||
@@ -105,8 +113,19 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
DrawMoney();
|
DrawMoney();
|
||||||
|
|
||||||
var x = Game.viewport.Width - 36 - 3 * 64;
|
chromeRenderer.Flush();
|
||||||
var y = 40;
|
|
||||||
|
int paletteHeight = DrawBuildPalette(currentTab);
|
||||||
|
DrawBuildTabs(paletteHeight);
|
||||||
|
DrawChat();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawBuildTabs(int paletteHeight)
|
||||||
|
{
|
||||||
|
const int tabWidth = 24;
|
||||||
|
const int tabHeight = 40;
|
||||||
|
var x = paletteOrigin.X - tabWidth;
|
||||||
|
var y = paletteOrigin.Y + 9;
|
||||||
|
|
||||||
if (currentTab == null || !Rules.TechTree.BuildableItems(Game.LocalPlayer, currentTab).Any())
|
if (currentTab == null || !Rules.TechTree.BuildableItems(Game.LocalPlayer, currentTab).Any())
|
||||||
ChooseAvailableTab();
|
ChooseAvailableTab();
|
||||||
@@ -124,17 +143,28 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
var producing = queue.Producing(groupName);
|
var producing = queue.Producing(groupName);
|
||||||
var index = q.Key == currentTab ? 2 : (producing != null && producing.Done) ? 1 : 0;
|
var index = q.Key == currentTab ? 2 : (producing != null && producing.Done) ? 1 : 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Don't let tabs overlap the bevel
|
||||||
|
if (y > paletteOrigin.Y + paletteHeight - tabHeight - 9 && y < paletteOrigin.Y + paletteHeight)
|
||||||
|
{
|
||||||
|
y += tabHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stick tabs to the edge of the screen
|
||||||
|
if (y > paletteOrigin.Y + paletteHeight)
|
||||||
|
{
|
||||||
|
x = Game.viewport.Width - tabWidth;
|
||||||
|
}
|
||||||
|
|
||||||
chromeRenderer.DrawSprite(q.Value[index], new float2(x, y), 0);
|
chromeRenderer.DrawSprite(q.Value[index], new float2(x, y), 0);
|
||||||
|
|
||||||
buttons.Add(Pair.New(new Rectangle(x, y, 27, 40),
|
buttons.Add(Pair.New(new Rectangle(x, y, tabWidth, tabHeight),
|
||||||
(Action<bool>)(isLmb => currentTab = groupName)));
|
(Action<bool>)(isLmb => currentTab = groupName)));
|
||||||
y += 40;
|
y += tabHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
chromeRenderer.Flush();
|
chromeRenderer.Flush();
|
||||||
DrawBuildPalette(currentTab);
|
|
||||||
|
|
||||||
DrawChat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckDeadTab( string groupName )
|
void CheckDeadTab( string groupName )
|
||||||
@@ -199,9 +229,14 @@ namespace OpenRa.Game
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBuildPalette(string queueName)
|
// Return an int telling us the y coordinate at the bottom of the palette
|
||||||
|
int DrawBuildPalette(string queueName)
|
||||||
{
|
{
|
||||||
if (queueName == null) return;
|
// Hack
|
||||||
|
int columns = paletteColumns;
|
||||||
|
int2 origin = new int2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
|
||||||
|
|
||||||
|
if (queueName == null) return 0;
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
@@ -218,11 +253,11 @@ namespace OpenRa.Game
|
|||||||
var overlayBits = new List<Pair<Sprite, float2>>();
|
var overlayBits = new List<Pair<Sprite, float2>>();
|
||||||
|
|
||||||
string tooltipItem = null;
|
string tooltipItem = null;
|
||||||
int2 tooltipPos = int2.Zero;
|
//int2 tooltipPos = int2.Zero;
|
||||||
|
|
||||||
foreach (var item in allItems)
|
foreach (var item in allItems)
|
||||||
{
|
{
|
||||||
var rect = new Rectangle(Game.viewport.Width - (3 - x) * 64, 40 + 48 * y, 64, 48);
|
var rect = new Rectangle(origin.X + x * 64, origin.Y + 48 * y, 64, 48);
|
||||||
var drawPos = Game.viewport.Location + new float2(rect.Location);
|
var drawPos = Game.viewport.Location + new float2(rect.Location);
|
||||||
var isBuildingThis = currentItem != null && currentItem.Item == item;
|
var isBuildingThis = currentItem != null && currentItem.Item == item;
|
||||||
var isBuildingSomethingElse = currentItem != null && currentItem.Item != item;
|
var isBuildingSomethingElse = currentItem != null && currentItem.Item != item;
|
||||||
@@ -232,7 +267,7 @@ namespace OpenRa.Game
|
|||||||
if (rect.Contains(lastMousePos.ToPoint()))
|
if (rect.Contains(lastMousePos.ToPoint()))
|
||||||
{
|
{
|
||||||
tooltipItem = item;
|
tooltipItem = item;
|
||||||
tooltipPos = new int2(rect.Location);
|
//tooltipPos = new int2(rect.Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buildableItems.Contains(item) || isBuildingSomethingElse)
|
if (!buildableItems.Contains(item) || isBuildingSomethingElse)
|
||||||
@@ -261,16 +296,16 @@ namespace OpenRa.Game
|
|||||||
var closureItem = item;
|
var closureItem = item;
|
||||||
buttons.Add(Pair.New(rect,
|
buttons.Add(Pair.New(rect,
|
||||||
(Action<bool>)(isLmb => HandleBuildPalette(closureItem, isLmb))));
|
(Action<bool>)(isLmb => HandleBuildPalette(closureItem, isLmb))));
|
||||||
if (++x == 3) { x = 0; y++; }
|
if (++x == columns) { x = 0; y++; }
|
||||||
}
|
}
|
||||||
|
|
||||||
while (x != 0)
|
while (x != 0)
|
||||||
{
|
{
|
||||||
var rect = new Rectangle(Game.viewport.Width - (3 - x) * 64, 40 + 48 * y, 64, 48);
|
var rect = new Rectangle(origin.X + x * 64, origin.Y + 48 * y, 64, 48);
|
||||||
var drawPos = Game.viewport.Location + new float2(rect.Location);
|
var drawPos = Game.viewport.Location + new float2(rect.Location);
|
||||||
buildPaletteRenderer.DrawSprite(blank, drawPos, 0);
|
buildPaletteRenderer.DrawSprite(blank, drawPos, 0);
|
||||||
buttons.Add(Pair.New(rect, (Action<bool>)(_ => { })));
|
buttons.Add(Pair.New(rect, (Action<bool>)(_ => { })));
|
||||||
if (++x == 3) { x = 0; y++; }
|
if (++x == columns) { x = 0; y++; }
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var ob in overlayBits)
|
foreach (var ob in overlayBits)
|
||||||
@@ -279,13 +314,15 @@ namespace OpenRa.Game
|
|||||||
buildPaletteRenderer.Flush();
|
buildPaletteRenderer.Flush();
|
||||||
|
|
||||||
for (var j = 0; j < y; j++)
|
for (var j = 0; j < y; j++)
|
||||||
chromeRenderer.DrawSprite(shimSprites[2], new float2(Game.viewport.Width - 192 - 9, 40 + 48 * j), 0);
|
chromeRenderer.DrawSprite(shimSprites[2], new float2(origin.X - 9, origin.Y + 48 * j), 0);
|
||||||
chromeRenderer.DrawSprite(shimSprites[0], new float2(Game.viewport.Width - 192 - 9, 40 - 9), 0);
|
chromeRenderer.DrawSprite(shimSprites[0], new float2(origin.X - 9, origin.Y - 9), 0);
|
||||||
chromeRenderer.DrawSprite(shimSprites[1], new float2(Game.viewport.Width - 192 - 9, 40 - 1 + 48 * y), 0);
|
chromeRenderer.DrawSprite(shimSprites[1], new float2(origin.X - 9, origin.Y - 1 + 48 * y), 0);
|
||||||
chromeRenderer.Flush();
|
chromeRenderer.Flush();
|
||||||
|
|
||||||
if (tooltipItem != null)
|
if (tooltipItem != null)
|
||||||
DrawProductionTooltip(tooltipItem, tooltipPos);
|
DrawProductionTooltip(tooltipItem, new int2(Game.viewport.Width, origin.Y + y * 48 + 9)/*tooltipPos*/);
|
||||||
|
|
||||||
|
return y*48+9;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleBuildPalette(string item, bool isLmb)
|
void HandleBuildPalette(string item, bool isLmb)
|
||||||
|
|||||||
Reference in New Issue
Block a user