forked from plutoscarab/Rails
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Images.cs
127 lines (104 loc) · 4.07 KB
/
Images.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Images.cs
/*
* This class contains global Bitmap variables containing images loaded from
* resource streams compiled into the executable. All of these images where
* generated by the Graphics.exe companion program, although the product icons
* are based on photographic images.
*
*/
using System;
using System.Drawing;
using System.Reflection;
using System.IO;
using System.Globalization;
namespace Rails
{
public sealed class Images
{
public static Bitmap BlackDot; // a clear milepost
public static Bitmap BlueDot; // a sea-lane milepost
public static Bitmap Hill; // a mountain milepost (black triangle)
public static Bitmap Alpine; // an alpine milepost (hollow black triangle)
public static Bitmap Capital; // a major city (red hexagon)
public static Bitmap City; // a minor city (red square)
public static Bitmap Town; // a town (red circle)
public static Bitmap Port; // a port (grey circle with "P")
public static Bitmap Glow; // blue glow around highlighted city
public static Icon HumanIcon; // user.ico
public static Icon ComputerIcon; // computer.ico
public static Bitmap LocoBitmap; // train gif by Chris Denbow
public static Bitmap[] TrainDot; // colored center of train indicators
public static Bitmap[] TrainPointer; // directional train indicators
public static Bitmap[,] TrackBitmap; // player-color tracks in three orientations
public static Bitmap[,] BridgeBitmap; // player-colored tracks over rivers
public static Bitmap[] Snowflake; // a variety of snowflakes for snow events
public static Bitmap PhantomCursor; // phantom cursor for networked play
public static Bitmap Plaque; // background for player comparison box
static Assembly assembly;
private Images()
{
}
static Images()
{
assembly = Assembly.GetExecutingAssembly();
BlackDot = GetBitmap("BlackDot");
BlueDot = GetBitmap("BlueDot");
Hill = GetBitmap("Hill");
Alpine = GetBitmap("Alpine");
Capital = GetBitmap("Capital");
City = GetBitmap("City");
Town = GetBitmap("Town");
Port = GetBitmap("Port");
Glow = GetBitmap("Glow");
HumanIcon = GetIcon("user");
ComputerIcon = GetIcon("machine");
LocoBitmap = (Bitmap) GetImage("Rails.Trains.Loco.gif");
TrainDot = new Bitmap[6];
TrainPointer = new Bitmap[6];
NumberFormatInfo format = CultureInfo.InvariantCulture.NumberFormat;
for (int i=0; i<6; i++)
{
TrainDot[i] = GetBitmap("PlayerDot" + i.ToString(format));
TrainPointer[i] = GetBitmap("Train" + i.ToString(format));
}
TrackBitmap = new Bitmap[7,3];
BridgeBitmap = new Bitmap[7,3];
for (int i=0; i<7; i++)
for (int j=0; j<3; j++)
{
TrackBitmap[i, j] = GetBitmap("Track" + i.ToString(format) + "-" + j.ToString(format));
BridgeBitmap[i, j] = GetBitmap("Bridge" + i.ToString(format) + "-" + j.ToString(format));
}
Snowflake = new Bitmap[10];
for (int i=0; i<10; i++)
Snowflake[i] = GetBitmap("Snowflake" + i.ToString(format));
PhantomCursor = GetPNG("PhantomCursor");
Plaque = GetPNG("Trains.plaque");
}
static Bitmap GetBitmap(string name)
{
string resourceName = String.Format(System.Globalization.CultureInfo.InvariantCulture, "Rails.Graphics.bin.Debug.{0}.bmp", name);
return (Bitmap) GetImage(resourceName);
}
static Bitmap GetPNG(string name)
{
string resourceName = String.Format(System.Globalization.CultureInfo.InvariantCulture, "Rails.{0}.png", name);
return (Bitmap) GetImage(resourceName);
}
static Image GetImage(string resourceName)
{
Stream stream = assembly.GetManifestResourceStream(resourceName);
Image image = Image.FromStream(stream);
stream.Close();
return image;
}
static Icon GetIcon(string name)
{
string resourceName = String.Format(System.Globalization.CultureInfo.InvariantCulture, "Rails.{0}.ico", name);
Stream stream = assembly.GetManifestResourceStream(resourceName);
Icon icon = new Icon(stream);
stream.Close();
return icon;
}
}
}