Add an order button for beacon placement.

This commit is contained in:
Paul Chote
2014-03-21 11:26:02 +13:00
parent ccbe4f3768
commit 9541686de3
13 changed files with 151 additions and 36 deletions

View File

@@ -488,6 +488,7 @@
<Compile Include="Attack\AttackGarrisoned.cs" />
<Compile Include="Widgets\Logic\LobbyMapPreviewLogic.cs" />
<Compile Include="Widgets\Logic\ButtonTooltipLogic.cs" />
<Compile Include="Orders\BeaconOrderGenerator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -0,0 +1,35 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using OpenRA.Graphics;
namespace OpenRA.Mods.RA.Orders
{
public class BeaconOrderGenerator : IOrderGenerator
{
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{
if (mi.Button != MouseButton.Left)
world.CancelInputMode();
if (world.Map.IsInMap(xy))
{
world.CancelInputMode();
yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = xy };
}
}
public virtual void Tick(World world) { }
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
public void RenderAfterWorld(WorldRenderer wr, World world) { }
public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.IsInMap(xy) ? "ability" : "generic-blocked"; }
}
}

View File

@@ -32,6 +32,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
BindOrderButton<RepairOrderGenerator>(world, repair, "repair");
}
var beacon = widget.GetOrNull<ButtonWidget>("BEACON_BUTTON");
if (beacon != null)
{
beacon.GetKey = _ => Game.Settings.Keys.PlaceBeaconKey;
BindOrderButton<BeaconOrderGenerator>(world, beacon, "beacon");
}
var power = widget.GetOrNull<ButtonWidget>("POWER_BUTTON");
if (power != null)
{

View File

@@ -65,9 +65,6 @@ namespace OpenRA.Mods.RA.Widgets
if (key == ks.ToggleStatusBarsKey)
return ToggleStatusBars();
if (key == ks.PlaceBeaconKey)
return PerformPlaceBeacon();
// Put all functions that aren't unit-specific before this line!
if (!world.Selection.Actors.Any())
return false;
@@ -189,15 +186,6 @@ namespace OpenRA.Mods.RA.Widgets
return true;
}
bool PerformPlaceBeacon()
{
if (world.LocalPlayer == null)
return true;
world.OrderGenerator = new GenericSelectTarget(world.LocalPlayer.PlayerActor, "PlaceBeacon", "ability");
return true;
}
bool CycleBases()
{
var bases = world.ActorsWithTrait<BaseBuilding>()

View File

@@ -13,9 +13,9 @@
height="512"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
inkscape:version="0.48.2 r9819"
sodipodi:docname="chrome.svg"
inkscape:export-filename="/home/matthias/Projekte/OpenRA/mods/cnc/uibits/chrome.png"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/chrome.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
enable-background="new">
@@ -99,17 +99,17 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.6568539"
inkscape:cx="424.27411"
inkscape:cy="420.32669"
inkscape:zoom="11.313708"
inkscape:cx="399.83211"
inkscape:cy="452.59159"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1060"
inkscape:window-x="1364"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:window-width="1151"
inkscape:window-height="1004"
inkscape:window-x="540"
inkscape:window-y="22"
inkscape:window-maximized="0"
showguides="true"
inkscape:guide-bbox="true">
<sodipodi:guide
@@ -201,7 +201,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -870,14 +870,14 @@
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path3948"
d="m 400,588.3622 4,4 0,0 -4,4 z"
d="m 416,588.3622 4,4 0,0 -4,4 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none"
id="rect3950"
width="10"
height="2"
x="403"
x="419"
y="591.36224" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none"
@@ -1344,7 +1344,7 @@
sodipodi:nodetypes="ccccc" />
<rect
y="599.36224"
x="403"
x="419"
height="2"
width="10"
id="rect3206"
@@ -1353,10 +1353,10 @@
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path3208"
d="m 416,596.3622 -4,4 0,0 4,4 z"
d="m 432,596.3622 -4,4 0,0 4,4 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
<g
transform="matrix(0.94409778,0,0,0.94409778,123.40976,207.65261)"
transform="matrix(0.94409778,0,0,0.94409778,139.40976,207.65261)"
id="g4025">
<path
sodipodi:nodetypes="ccccccccccccc"
@@ -1367,9 +1367,42 @@
</g>
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="m 401.0505,632.91722 1.89097,0 0,-1.83277 1.86185,0.0291 0,1.7455 1.80369,-0.0291 0.0291,-0.84366 0.93092,0 0.0291,0.84366 1.74549,0 0.0291,-1.7746 2.7928,0.0291 0,1.7746 1.92005,0.0291 -0.0291,-0.84366 -1.0182,0 0,-2.88008 1.83278,0 0,-0.87276 0.98911,-0.0291 -0.0401,-1.79618 -2.79765,-0.0205 0,0.91541 -1.82052,0.0205 0.0205,-1.86167 -1.86168,0.0107 0,-0.9154 -1.84109,0 0.0107,-0.93598 -2.82851,0 0.0205,0.9257 -1.82052,0.0108 0.0107,0.94627 -0.92569,0 -0.0107,0.90511 -0.9257,0 -0.0107,2.77706 -0.89484,0 0,0.88456 1.79995,0.0107 0.0107,1.86168 -0.89483,-0.0205 z"
d="m 417.0505,632.91722 1.89097,0 0,-1.83277 1.86185,0.0291 0,1.7455 1.80369,-0.0291 0.0291,-0.84366 0.93092,0 0.0291,0.84366 1.74549,0 0.0291,-1.7746 2.7928,0.0291 0,1.7746 1.92005,0.0291 -0.0291,-0.84366 -1.0182,0 0,-2.88008 1.83278,0 0,-0.87276 0.98911,-0.0291 -0.0401,-1.79618 -2.79765,-0.0205 0,0.91541 -1.82052,0.0205 0.0205,-1.86167 -1.86168,0.0107 0,-0.9154 -1.84109,0 0.0107,-0.93598 -2.82851,0 0.0205,0.9257 -1.82052,0.0108 0.0107,0.94627 -0.92569,0 -0.0107,0.90511 -0.9257,0 -0.0107,2.77706 -0.89484,0 0,0.88456 1.79995,0.0107 0.0107,1.86168 -0.89483,-0.0205 z"
id="path4064"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="M 407 48 L 407 54.09375 L 404 54.09375 L 408 60.09375 L 412 54.09375 L 409 54.09375 L 409 48 L 407 48 z "
transform="translate(0,540.3622)"
id="path3209" />
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="m 405,597.3201 c 0,0 -1.39049,0.46877 -2,0.94835 -0.74318,0.58475 -1.28125,1.38567 -1.28125,2.3125 0,1.20635 0.85848,2.18714 2,2.8125 1.14152,0.62536 2.64345,0.96875 4.28125,0.96875 1.63779,0 3.13974,-0.34339 4.28125,-0.96875 1.14151,-0.62536 2,-1.60615 2,-2.8125 0,-0.92683 -0.53807,-1.72775 -1.28125,-2.3125 -0.62484,-0.49164 -2,-0.9485 -2,-0.9485 l -0.8,1.189 c 0,0 1.35963,0.55133 1.8625,0.947 0.50287,0.39567 0.71875,0.76662 0.71875,1.125 0,0.46647 -0.35919,0.99786 -1.21875,1.46875 -0.85956,0.47089 -2.14677,0.8125 -3.5625,0.8125 -1.41574,0 -2.70294,-0.34161 -3.5625,-0.8125 -0.85956,-0.47089 -1.21875,-1.00228 -1.21875,-1.46875 0,-0.35838 0.21588,-0.72933 0.71875,-1.125 0.50287,-0.39567 1.8625,-0.94665 1.8625,-0.94665 z"
id="path4043"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csssssssccssssssscc" />
<path
id="path4050"
d="m 407,604.3622 0,6.09375 -3,0 4,6 4,-6 -3,0 0,-6.09375 -2,0 z"
style="fill:#808080;fill-opacity:1;stroke:none"
inkscape:connector-curvature="0" />
<path
sodipodi:nodetypes="csssssssccssssssscc"
inkscape:connector-curvature="0"
id="path4052"
d="m 405,613.3201 c 0,0 -1.39049,0.46877 -2,0.94835 -0.74318,0.58475 -1.28125,1.38567 -1.28125,2.3125 0,1.20635 0.85848,2.18714 2,2.8125 1.14152,0.62536 2.64345,0.96875 4.28125,0.96875 1.63779,0 3.13974,-0.34339 4.28125,-0.96875 1.14151,-0.62536 2,-1.60615 2,-2.8125 0,-0.92683 -0.53807,-1.72775 -1.28125,-2.3125 -0.62484,-0.49164 -2,-0.9485 -2,-0.9485 l -0.8,1.189 c 0,0 1.35963,0.55133 1.8625,0.947 0.50287,0.39567 0.71875,0.76662 0.71875,1.125 0,0.46647 -0.35919,0.99786 -1.21875,1.46875 -0.85956,0.47089 -2.14677,0.8125 -3.5625,0.8125 -1.41574,0 -2.70294,-0.34161 -3.5625,-0.8125 -0.85956,-0.47089 -1.21875,-1.00228 -1.21875,-1.46875 0,-0.35838 0.21588,-0.72933 0.71875,-1.125 0.50287,-0.39567 1.8625,-0.94665 1.8625,-0.94665 z"
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#808080;fill-opacity:1;stroke:none;stroke-width:1.50000000000000000;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" />
<path
inkscape:connector-curvature="0"
style="fill:#ffc000;fill-opacity:1;stroke:none"
d="m 407,620.3622 0,6.09375 -3,0 4,6 4,-6 -3,0 0,-6.09375 -2,0 z"
id="path4054" />
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#ffc000;fill-opacity:1;stroke:none;stroke-width:1.50000000000000000;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="m 405,629.3201 c 0,0 -1.39049,0.46877 -2,0.94835 -0.74318,0.58475 -1.28125,1.38567 -1.28125,2.3125 0,1.20635 0.85848,2.18714 2,2.8125 1.14152,0.62536 2.64345,0.96875 4.28125,0.96875 1.63779,0 3.13974,-0.34339 4.28125,-0.96875 1.14151,-0.62536 2,-1.60615 2,-2.8125 0,-0.92683 -0.53807,-1.72775 -1.28125,-2.3125 -0.62484,-0.49164 -2,-0.9485 -2,-0.9485 l -0.8,1.189 c 0,0 1.35963,0.55133 1.8625,0.947 0.50287,0.39567 0.71875,0.76662 0.71875,1.125 0,0.46647 -0.35919,0.99786 -1.21875,1.46875 -0.85956,0.47089 -2.14677,0.8125 -3.5625,0.8125 -1.41574,0 -2.70294,-0.34161 -3.5625,-0.8125 -0.85956,-0.47089 -1.21875,-1.00228 -1.21875,-1.46875 0,-0.35838 0.21588,-0.72933 0.71875,-1.125 0.50287,-0.39567 1.8625,-0.94665 1.8625,-0.94665 z"
id="path4056"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csssssssccssssssscc" />
</g>
<g
inkscape:groupmode="layer"

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

@@ -388,8 +388,8 @@ music: chrome.png
play: 288,0,16,16
next: 256,16,16,16
prev: 272,16,16,16
fastforward: 400,64,16,16
slowmo: 400,80,16,16
fastforward: 416,64,16,16
slowmo: 416,80,16,16
lobby-bits: chrome.png
spawn-claimed: 256,32,16,16
@@ -427,8 +427,8 @@ strategic: strategic.png
player_owned: 96,0,32,32
sidebar-bits: chrome.png
indicator-left: 400,48,16,8
indicator-right: 400,56,16,8
indicator-left: 416,48,16,8
indicator-right: 416,56,16,8
production-icons: chrome.png
building: 384,0,16,16
@@ -460,3 +460,6 @@ order-icons: chrome.png
repair: 384,48,16,16
repair-disabled: 384,64,16,16
repair-active: 384,80,16,16
beacon: 400,48,16,16
beacon-disabled: 400,64,16,16
beacon-active: 400,80,16,16

View File

@@ -181,7 +181,7 @@ Container@PLAYER_WIDGETS:
Children:
Button@OPTIONS_BUTTON:
Key:escape
X:42
X:22
Y:0-24
Width:30
Height:25
@@ -194,8 +194,21 @@ Container@PLAYER_WIDGETS:
Y:5
ImageCollection:order-icons
ImageName:options
Button@BEACON_BUTTON:
X:62
Y:0-24
Width:30
Height:25
Font:Bold
TooltipText: Place Beacon
TooltipContainer:TOOLTIP_CONTAINER
Children:
Image@ICON:
X:7
Y:5
ImageCollection:order-icons
Button@SELL_BUTTON:
X:82
X:102
Y:0-24
Width:30
Height:25
@@ -208,7 +221,7 @@ Container@PLAYER_WIDGETS:
Y:5
ImageCollection:order-icons
Button@REPAIR_BUTTON:
X:122
X:142
Y:0-24
Width:30
Height:25

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

@@ -247,6 +247,9 @@ order-icons: buttons.png
power: 0,56,34,28
power-disabled: 68,56,34,28
power-active: 34,56,34,28
beacon: 0,56,34,28
beacon-disabled: 68,56,34,28
beacon-active: 34,56,34,28
music: musicplayer.png
pause: 0,0,25,25

View File

@@ -86,6 +86,19 @@ Container@PLAYER_WIDGETS:
Children:
Image@ICON:
ImageCollection:order-icons
Button@BEACON_BUTTON:
X:75
# Hidden offscreen so that the shortcut still works
# while we wait for new button art to be created
Y:0-100
Width:34
Height:28
TooltipText: Place Beacon
TooltipContainer:TOOLTIP_CONTAINER
VisualHeight:0
Children:
Image@ICON:
ImageCollection:order-icons
SupportPowerBin@INGAME_POWERS_BIN:
X:0
Y:25

View File

@@ -191,6 +191,9 @@ order-icons: buttons.png
power: 0,56,34,28
power-disabled: 68,56,34,28
power-active: 34,56,34,28
beacon: 0,56,34,28
beacon-disabled: 68,56,34,28
beacon-active: 34,56,34,28
flags: buttons.png
allies: 30,84,30,15

View File

@@ -86,6 +86,19 @@ Container@PLAYER_WIDGETS:
Children:
Image@ICON:
ImageCollection:order-icons
Button@BEACON_BUTTON:
X:75
# Hidden offscreen so that the shortcut still works
# while we wait for new button art to be created
Y:0-100
Width:34
Height:28
TooltipText: Place Beacon
TooltipContainer:TOOLTIP_CONTAINER
VisualHeight:0
Children:
Image@ICON:
ImageCollection:order-icons
SupportPowerBin@INGAME_POWERS_BIN:
X:0
Y:25

View File

@@ -185,6 +185,9 @@ order-icons: buttons.png
power: 0,56,34,28
power-disabled: 68,56,34,28
power-active: 34,56,34,28
beacon: 0,56,34,28
beacon-disabled: 68,56,34,28
beacon-active: 34,56,34,28
flags: buttons.png
gdi: 30,84,30,15