-
Notifications
You must be signed in to change notification settings - Fork 2
/
Options.cs
89 lines (80 loc) · 2.27 KB
/
Options.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
// Options.cs
/*
* This structure describes the game variation selections made in the new game dialog.
*
*/
using System;
using System.IO;
using System.Text;
namespace Rails
{
[Serializable]
public struct Options
{
public bool AutomaticTrackBuilding;
public bool FastStart;
public bool CityIncentives;
public bool LimitedCommodities;
public bool FirstToCityBonuses;
public bool GroupedContracts;
public int FundsGoal;
public Options(BinaryReader reader)
{
int version = reader.ReadInt32();
AutomaticTrackBuilding = reader.ReadBoolean();
FastStart = reader.ReadBoolean();
CityIncentives = reader.ReadBoolean();
LimitedCommodities = reader.ReadBoolean();
FirstToCityBonuses = reader.ReadBoolean();
if (version >= 1)
GroupedContracts = reader.ReadBoolean();
else
GroupedContracts = false;
if (version >= 2)
FundsGoal = reader.ReadInt32();
else
FundsGoal = GameState.DefaultFundsGoal;
}
public void Save(BinaryWriter writer)
{
writer.Write((int) 2); // version
writer.Write(AutomaticTrackBuilding);
writer.Write(FastStart);
writer.Write(CityIncentives);
writer.Write(LimitedCommodities);
writer.Write(FirstToCityBonuses);
writer.Write(GroupedContracts);
writer.Write(FundsGoal);
}
public override string ToString()
{
return AutomaticTrackBuilding.ToString() + ":" + FastStart.ToString() + ":"
+ CityIncentives.ToString() + ":" + LimitedCommodities.ToString() + ":"
+ FirstToCityBonuses.ToString() + (GroupedContracts ? ":" + GroupedContracts.ToString() : "")
+ (FundsGoal == GameState.DefaultFundsGoal ? "" : ":" + FundsGoal.ToString());
}
public string ToString(bool abbreviate)
{
if (!abbreviate)
return ToString();
StringBuilder b = new StringBuilder();
if (AutomaticTrackBuilding)
b.Append("At");
if (FastStart)
b.Append("Fs");
if (CityIncentives)
b.Append("Ci");
if (LimitedCommodities)
b.Append("Lc");
if (FirstToCityBonuses)
b.Append("Fc");
if (GroupedContracts)
b.Append("Gc");
if (FundsGoal != GameState.DefaultFundsGoal)
b.Append(FundsGoal.ToString());
if (b.Length == 0)
b.Append("None");
return b.ToString();
}
}
}