Merge pull request #2801 from Mailaender/hotkey-cleanup

Remove inconsistencies that crash C&C mod
This commit is contained in:
Matthias Mailänder
2013-03-26 14:28:49 -07:00
12 changed files with 39 additions and 32 deletions

View File

@@ -46,7 +46,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
foreach (var p in world.Players.Where(a => !a.NonCombatant))
{
Player pp = p;
var c = world.LobbyInfo.ClientWithIndex(pp.ClientIndex);
var item = itemTemplate.Clone();
var nameLabel = item.Get<LabelWidget>("NAME");
nameLabel.GetText = () => pp.WinState == WinState.Lost ? pp.PlayerName + " (Dead)" : pp.PlayerName;
@@ -58,7 +57,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
item.Get<LabelWidget>("FACTION").GetText = () => pp.Country.Name;
var team = item.Get<LabelWidget>("TEAM");
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
team.GetText = () => (pp.PlayerReference.Team == 0) ? "-" : pp.PlayerReference.Team.ToString();
scrollpanel.AddChild(item);
item.Get<LabelWidget>("KILLS").GetText = () => pp.Kills.ToString();

View File

@@ -123,6 +123,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
BindOrderButton<SellOrderGenerator>(world, sidebarRoot, "SELL_BUTTON", "sell");
BindOrderButton<RepairOrderGenerator>(world, sidebarRoot, "REPAIR_BUTTON", "repair");
sidebarRoot.Get<ToggleButtonWidget>("SELL_BUTTON").Key = Game.Settings.Keys.SellKey;
sidebarRoot.Get<ToggleButtonWidget>("REPAIR_BUTTON").Key = Game.Settings.Keys.RepairKey;
var powerManager = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
sidebarRoot.Get<LabelWidget>("CASH").GetText = () =>

View File

@@ -53,6 +53,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
objectivesButton.IsVisible = () => world.LocalPlayer != null;
}
var moneybin = gameRoot.Get("INGAME_MONEY_BIN");
moneybin.Get<OrderButtonWidget>("SELL").Key = Game.Settings.Keys.SellKey;
moneybin.Get<OrderButtonWidget>("POWER_DOWN").Key = Game.Settings.Keys.PowerDownKey;
moneybin.Get<OrderButtonWidget>("REPAIR").Key = Game.Settings.Keys.RepairKey;
optionsBG.Get<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG, world);
optionsBG.Get<ButtonWidget>("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU");

View File

@@ -41,6 +41,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
w.Pressed = () => world.OrderGenerator is T;
w.OnMouseDown = mi => world.ToggleInputMode<T>();
w.OnKeyPress = ki => world.ToggleInputMode<T>();
}
}
}

View File

@@ -176,6 +176,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
SetupKeyBinding(repairKey, "Switch to Repair-Cursor:", () => keyConfig.RepairKey, k => keyConfig.RepairKey = k);
specialHotkeyList.AddChild(repairKey);
var tabCycleKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {});
SetupKeyBinding(tabCycleKey, "Cycle Tabs (+Shift to Reverse):", () => keyConfig.CycleTabsKey, k => keyConfig.CycleTabsKey = k);
specialHotkeyList.AddChild(tabCycleKey);
var unitCommandHotkeyList = keys.Get<ScrollPanelWidget>("UNITCOMMANDHOTKEY_LIST");
var unitCommandHotkeyTemplate = unitCommandHotkeyList.Get<ScrollItemWidget>("UNITCOMMANDHOTKEY_TEMPLATE");

View File

@@ -53,15 +53,6 @@ namespace OpenRA.Mods.RA.Widgets
if (e.KeyName == Game.Settings.Keys.ToSelectionKey)
return ToSelection();
if (e.KeyName == Game.Settings.Keys.SellKey)
return PerformSwitchToSellMode();
if (e.KeyName == Game.Settings.Keys.PowerDownKey)
return PerformSwitchToPowerDownMode();
if (e.KeyName == Game.Settings.Keys.RepairKey)
return PerformSwitchToRepairMode();
if (!World.Selection.Actors.Any()) // Put all functions, that are no unit-functions, before this line!
return false;
@@ -196,23 +187,5 @@ namespace OpenRA.Mods.RA.Widgets
Game.viewport.Center(World.Selection.Actors);
return true;
}
bool PerformSwitchToSellMode()
{
World.ToggleInputMode<SellOrderGenerator>();
return true;
}
bool PerformSwitchToPowerDownMode()
{
World.ToggleInputMode<PowerDownOrderGenerator>();
return true;
}
bool PerformSwitchToRepairMode()
{
World.ToggleInputMode<RepairOrderGenerator>();
return true;
}
}
}

BIN
mods/cnc/bits/nopower.shp Normal file

Binary file not shown.

BIN
mods/cnc/bits/poweroff.shp Normal file

Binary file not shown.

View File

@@ -112,7 +112,6 @@ Container@PLAYER_WIDGETS:
ImageCollection:order-icons
ImageName:options
ToggleButton@SELL_BUTTON:
Key: [
X:82
Y:0-24
Width:30
@@ -126,7 +125,6 @@ Container@PLAYER_WIDGETS:
Y:5
ImageCollection:order-icons
ToggleButton@REPAIR_BUTTON:
Key: ]
X:122
Y:0-24
Width:30

View File

@@ -272,4 +272,16 @@ Cursors:
start:213
length:1
x:12
y:12
y:12
nopower: cursor
powerdown-blocked:
start:0
length: 1
x: 12
y: 12
powerdown:
start:1
length: 3
x: 12
y: 12

View File

@@ -29,6 +29,8 @@ Sounds:
CashTickUp:
CashTickDown:
LevelUp: text2
DisablePower: bleep11
EnablePower: bleep12
ChatLine: scold1
TabClick: button
ClickSound: button

View File

@@ -269,3 +269,13 @@ overlay:
Start: 0
target-invalid:
Start: 1
powerdown:
disabled: speed
Start: 3
poweroff:
offline:
Start: 0
Length: *
Tick: 160