An example mod. Chrome doesn't restrict the set of tabs any more, though i'm not sure what happens if you make a new tab :D
This commit is contained in:
@@ -47,7 +47,6 @@ namespace OpenRa.Game
|
|||||||
// Build Palette tabs
|
// Build Palette tabs
|
||||||
string currentTab = "Building";
|
string currentTab = "Building";
|
||||||
bool paletteOpen = false;
|
bool paletteOpen = false;
|
||||||
static string[] groups = new string[] { "Building", "Infantry", "Vehicle", "Plane", "Ship" };
|
|
||||||
readonly Dictionary<string, string[]> tabImageNames;
|
readonly Dictionary<string, string[]> tabImageNames;
|
||||||
readonly Dictionary<string, Sprite> tabSprites;
|
readonly Dictionary<string, Sprite> tabSprites;
|
||||||
|
|
||||||
@@ -111,7 +110,6 @@ namespace OpenRa.Game
|
|||||||
optionsBackground = SpriteSheetBuilder.LoadAllSprites("dd-bkgnd")[Game.CosmeticRandom.Next(4)];
|
optionsBackground = SpriteSheetBuilder.LoadAllSprites("dd-bkgnd")[Game.CosmeticRandom.Next(4)];
|
||||||
|
|
||||||
tabSprites = Rules.NewUnitInfo.Values
|
tabSprites = Rules.NewUnitInfo.Values
|
||||||
.Where(x => groups.Contains(x.Category))
|
|
||||||
.Where(u => u.Traits.Contains<BuildableInfo>())
|
.Where(u => u.Traits.Contains<BuildableInfo>())
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
u => u.Name,
|
u => u.Name,
|
||||||
@@ -121,6 +119,8 @@ namespace OpenRa.Game
|
|||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
u => u.Key,
|
u => u.Key,
|
||||||
u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]);
|
u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]);
|
||||||
|
|
||||||
|
var groups = Rules.NewUnitInfo.Values.Select( x => x.Category ).Distinct().ToList();
|
||||||
|
|
||||||
tabImageNames = groups.Select(
|
tabImageNames = groups.Select(
|
||||||
(g, i) => Pair.New(g,
|
(g, i) => Pair.New(g,
|
||||||
@@ -644,27 +644,27 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
void StartProduction( string item )
|
void StartProduction( string item )
|
||||||
{
|
{
|
||||||
var group = Rules.NewUnitInfo[item].Category;
|
var unit = Rules.NewUnitInfo[item];
|
||||||
Sound.Play((group == "Building") ? "abldgin1.aud" : "train1.aud");
|
Sound.Play(unit.Traits.Contains<BuildingInfo>() ? "abldgin1.aud" : "train1.aud");
|
||||||
Game.controller.AddOrder(Order.StartProduction(Game.LocalPlayer, item));
|
Game.controller.AddOrder(Order.StartProduction(Game.LocalPlayer, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleBuildPalette(string item, bool isLmb)
|
void HandleBuildPalette(string item, bool isLmb)
|
||||||
{
|
{
|
||||||
var player = Game.LocalPlayer;
|
var player = Game.LocalPlayer;
|
||||||
var group = Rules.NewUnitInfo[item].Category;
|
var unit = Rules.NewUnitInfo[item];
|
||||||
var queue = player.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
var queue = player.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||||
var producing = queue.AllItems(group).FirstOrDefault( a => a.Item == item );
|
var producing = queue.AllItems(unit.Category).FirstOrDefault( a => a.Item == item );
|
||||||
|
|
||||||
Sound.Play("ramenu1.aud");
|
Sound.Play("ramenu1.aud");
|
||||||
|
|
||||||
if (isLmb)
|
if (isLmb)
|
||||||
{
|
{
|
||||||
if (producing != null && producing == queue.CurrentItem(group))
|
if (producing != null && producing == queue.CurrentItem(unit.Category))
|
||||||
{
|
{
|
||||||
if (producing.Done)
|
if (producing.Done)
|
||||||
{
|
{
|
||||||
if (group == "Building")
|
if (unit.Traits.Contains<BuildingInfo>())
|
||||||
Game.controller.orderGenerator = new PlaceBuildingOrderGenerator(player.PlayerActor, item);
|
Game.controller.orderGenerator = new PlaceBuildingOrderGenerator(player.PlayerActor, item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ namespace OpenRa.Game
|
|||||||
if( useAftermath )
|
if( useAftermath )
|
||||||
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "aftermath.yaml" ), yamlRules );
|
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "aftermath.yaml" ), yamlRules );
|
||||||
|
|
||||||
|
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "[mod]Separate buildqueue for defense.yaml" ), yamlRules );
|
||||||
|
|
||||||
NewUnitInfo = new Dictionary<string, NewUnitInfo>();
|
NewUnitInfo = new Dictionary<string, NewUnitInfo>();
|
||||||
foreach( var kv in yamlRules )
|
foreach( var kv in yamlRules )
|
||||||
NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
|
NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
case "StartProduction":
|
case "StartProduction":
|
||||||
{
|
{
|
||||||
string group = Rules.NewUnitInfo[ order.TargetString ].Category;
|
var unit = Rules.NewUnitInfo[ order.TargetString ];
|
||||||
var ui = Rules.NewUnitInfo[ order.TargetString ].Traits.Get<BuildableInfo>();
|
var ui = unit.Traits.Get<BuildableInfo>();
|
||||||
var time = ui.Cost
|
var time = ui.Cost
|
||||||
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||||
* ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */
|
* ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||||
@@ -42,17 +42,17 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
time = .08f * time; /* temporary hax so we can build stuff fast for test */
|
time = .08f * time; /* temporary hax so we can build stuff fast for test */
|
||||||
|
|
||||||
if( !Rules.TechTree.BuildableItems( order.Player, group ).Contains( order.TargetString ) )
|
if( !Rules.TechTree.BuildableItems( order.Player, unit.Category ).Contains( order.TargetString ) )
|
||||||
return; /* you can't build that!! */
|
return; /* you can't build that!! */
|
||||||
|
|
||||||
bool hasPlayedSound = false;
|
bool hasPlayedSound = false;
|
||||||
|
|
||||||
BeginProduction( group,
|
BeginProduction( unit.Category,
|
||||||
new ProductionItem( order.TargetString, (int)time, ui.Cost,
|
new ProductionItem( order.TargetString, (int)time, ui.Cost,
|
||||||
() => Game.world.AddFrameEndTask(
|
() => Game.world.AddFrameEndTask(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
var isBuilding = group == "Building";
|
var isBuilding = unit.Traits.Contains<BuildingInfo>();
|
||||||
if( !hasPlayedSound && order.Player == Game.LocalPlayer )
|
if( !hasPlayedSound && order.Player == Game.LocalPlayer )
|
||||||
{
|
{
|
||||||
Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" );
|
Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" );
|
||||||
|
|||||||
23
[mod]Separate buildqueue for defense.yaml
Executable file
23
[mod]Separate buildqueue for defense.yaml
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
IRON:
|
||||||
|
Category: Defense
|
||||||
|
PDOX:
|
||||||
|
Category: Defense
|
||||||
|
PBOX:
|
||||||
|
Category: Defense
|
||||||
|
HBOX:
|
||||||
|
Category: Defense
|
||||||
|
TSLA:
|
||||||
|
Category: Defense
|
||||||
|
GUN:
|
||||||
|
Category: Defense
|
||||||
|
AGUN:
|
||||||
|
Category: Defense
|
||||||
|
FTUR:
|
||||||
|
Category: Defense
|
||||||
|
GAP:
|
||||||
|
Category: Defense
|
||||||
|
SAM:
|
||||||
|
Category: Defense
|
||||||
|
MSLO:
|
||||||
|
Category: Defense
|
||||||
|
|
||||||
Reference in New Issue
Block a user