Skip to content

Commit

Permalink
Item colors
Browse files Browse the repository at this point in the history
  • Loading branch information
EFLFE committed Aug 12, 2022
1 parent 69fba4c commit ba85584
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 51 deletions.
1 change: 1 addition & 0 deletions Artorio/Artorio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<Compile Include="GetJSONBP.xaml.cs">
<DependentUpon>GetJSONBP.xaml</DependentUpon>
</Compile>
<Compile Include="ItemColors.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down
3 changes: 1 addition & 2 deletions Artorio/ColorItemCast.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
</ComboBox>
<CheckBox x:Name="useRangeColor" HorizontalAlignment="Left" Margin="67,14,0,0" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="85,12,0,0" TextWrapping="Wrap" Text="range from" VerticalAlignment="Top"/>
<!--<Rectangle Panel.ZIndex="-1" Fill="#FFA0A6B9" HorizontalAlignment="Left" Margin="59,0,0,0" Width="136"/>-->
<Ellipse Panel.ZIndex="-1" Fill="#FFA0A6B9" HorizontalAlignment="Left" Margin="59,-20,0,0" Height="80" Width="136"/>
<Rectangle Panel.ZIndex="-1" Fill="#FFA0A6B9" HorizontalAlignment="Left" Margin="59,0,0,0" Width="136"/>
<Rectangle x:Name="itemColorRect" HorizontalAlignment="Left" Margin="536,10,0,10" Width="19" Fill="{x:Null}"/>
</Grid>
</UserControl>
56 changes: 7 additions & 49 deletions Artorio/ColorItemCast.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,57 +103,15 @@ public void Unload()
private void FindItemColor(string itemName)
{
itemName = itemName.ToLower();
/*
* chest 0, 93, 148
* belts 140, 138, 140
* solar? 25, 32, 33
* turret 25, 32, 33
* wall 189, 202, 189
* gate 123, 125, 123
* floor:
* stone 49, 49, 49
* concrete 99, 101, 99
* hazard 123, 125, 0
*/

switch (itemName)

if (ItemColors.FindItem(itemName, out ItemData data))
{
case "stone-path":
itemColorRect.Fill = new SolidColorBrush(Color.FromRgb(49, 49, 49));
break;

case "concrete":
case "refined-concrete":
itemColorRect.Fill = new SolidColorBrush(Color.FromRgb(99, 101, 99));
break;

case "hazard-concrete-left":
case "refined-hazard-concrete-left":
itemColorRect.Fill = new SolidColorBrush(Color.FromRgb(123, 125, 0));
break;

case "transport-belt":
itemColorRect.Fill = new SolidColorBrush(Color.FromRgb(140, 138, 140));
break;

case "wooden-chest":
itemColorRect.Fill = new SolidColorBrush(Color.FromRgb(0, 93, 148));
break;

case "stone-wall":
itemColorRect.Fill = new SolidColorBrush(Color.FromRgb(189, 202, 189));
break;

case "gate":
itemColorRect.Fill = new SolidColorBrush(Color.FromRgb(123, 125, 123));
break;

default:
itemColorRect.Fill = null;
break;
itemColorRect.Fill = new SolidColorBrush(data.MapColor);
}
else
{
itemColorRect.Fill = null;
}

}

private void UseRangeColor_Unchecked(object sender, RoutedEventArgs e)
Expand Down
94 changes: 94 additions & 0 deletions Artorio/ItemColors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Windows.Media;

namespace Artorio
{
internal static class ItemColors
{
private static readonly ItemData[] items;

static ItemColors()
{
items = new ItemData[]
{
// floors
new ItemData("stone-path", Color.FromRgb(80,82,72), ItemTypeEnum.Floor),
new ItemData("concrete", Color.FromRgb(56, 56, 56), ItemTypeEnum.Floor),
new ItemData("refined-concrete", Color.FromRgb(48, 48, 40), ItemTypeEnum.Floor),
new ItemData("hazard-concrete", Color.FromRgb(176, 138, 32), ItemTypeEnum.Floor),
new ItemData("refined-hazard-concrete", Color.FromRgb(112, 90, 24) , ItemTypeEnum.Floor),

// objects
new ItemData("wooden-chest", 0, 96, 144, ItemTypeEnum.Object),
new ItemData("iron-chest", 0, 96, 144, ItemTypeEnum.Object),
new ItemData("steel-chest", 0, 96, 144, ItemTypeEnum.Object),
new ItemData("transport-belt", 200, 160, 64, ItemTypeEnum.Object),
new ItemData("fast-transport-belt", 200, 160, 64, ItemTypeEnum.Object),
new ItemData("express-transport-belt", 200, 160, 64, ItemTypeEnum.Object),
new ItemData("underground-belt", 112, 88, 0, ItemTypeEnum.Object),
new ItemData("fast-underground-belt", 112, 88, 0, ItemTypeEnum.Object),
new ItemData("express-underground-belt", 112, 88, 0, ItemTypeEnum.Object),
new ItemData("pipe", 64, 130, 160, ItemTypeEnum.Object),
new ItemData("heat-pipe", 56, 130, 168, ItemTypeEnum.Object),
new ItemData("stone-wall", 200, 216, 200, ItemTypeEnum.Object),
new ItemData("gate", 128, 128, 128, ItemTypeEnum.Object),

// objects 2x2
new ItemData("accumulator", 120, 122, 120, ItemTypeEnum.Object_2x2),
new ItemData("gun-turret", 200, 162, 24, ItemTypeEnum.Object_2x2),
new ItemData("laser-turret", 216, 42, 40, ItemTypeEnum.Object_2x2),

// objects 3x3
new ItemData("storage-tank", 128, 162, 184, ItemTypeEnum.Object_3x3),
new ItemData("solar-panel", 24, 32, 32, ItemTypeEnum.Object_3x3),

// new ItemData("", , ItemTypeEnum.Object),
};
}

public static bool FindItem(string internalName, out ItemData data)
{
for (int i = 0; i < items.Length; i++)
{
if (items[i].InternalName.Equals(internalName, StringComparison.Ordinal))
{
data = items[i];
return true;
}
}
data = null;
return false;
}

}

internal sealed class ItemData
{
public readonly string InternalName;
public readonly Color MapColor;
public readonly ItemTypeEnum ItemType;

public ItemData(string internalName, Color mapColor, ItemTypeEnum itemType)
{
InternalName = internalName;
MapColor = mapColor;
ItemType = itemType;
}

public ItemData(string internalName, byte r, byte g, byte b, ItemTypeEnum itemType)
{
InternalName = internalName;
MapColor = Color.FromRgb(r, g, b);
ItemType = itemType;
}
}

internal enum ItemTypeEnum
{
Floor,
Object,
Object_2x2,
Object_3x3,
}
}

0 comments on commit ba85584

Please sign in to comment.