-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form_ViewShip.cs
311 lines (275 loc) · 10.6 KB
/
Form_ViewShip.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/*******************************************************************************
*
* Space Trader for Windows 1.00
*
* Copyright (C) 2016 Keith Banner, All Rights Reserved
*
* Port to Windows by David Pierron & Jay French
* Original coding by Pieter Spronck, Sam Anderson, Samuel Goldstein, Matt Lee
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* If you'd like a copy of the GNU General Public License, go to
* http://www.gnu.org/copyleft/gpl.html.
*
* You can contact the author at [email protected]
*
******************************************************************************/
using System;
using System.Collections;
namespace SpaceTrader
{
public class FormViewShip : System.Windows.Forms.Form
{
#region Control Declarations
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Label lblTypeLabel;
private System.Windows.Forms.Label lblType;
private System.Windows.Forms.GroupBox boxSpecialCargo;
private System.Windows.Forms.Label lblSpecialCargo;
private System.Windows.Forms.Label lblEquipLabel;
private System.Windows.Forms.Label lblEquip;
private System.ComponentModel.Container components = null;
#endregion
#region Member Declarations
private Game game = Game.CurrentGame;
private Ship ship = Game.CurrentGame.Commander.Ship;
#endregion
#region Methods
public FormViewShip()
{
InitializeComponent();
lblType.Text = ship.Name;
lblEquipLabel.Text = "";
lblEquip.Text = "";
DisplayEquipment();
DisplaySpecialCargo();
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
components.Dispose();
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblTypeLabel = new System.Windows.Forms.Label();
this.lblType = new System.Windows.Forms.Label();
this.btnClose = new System.Windows.Forms.Button();
this.lblEquipLabel = new System.Windows.Forms.Label();
this.lblEquip = new System.Windows.Forms.Label();
this.boxSpecialCargo = new System.Windows.Forms.GroupBox();
this.lblSpecialCargo = new System.Windows.Forms.Label();
this.boxSpecialCargo.SuspendLayout();
this.SuspendLayout();
//
// lblTypeLabel
//
this.lblTypeLabel.AutoSize = true;
this.lblTypeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblTypeLabel.Location = new System.Drawing.Point(8, 8);
this.lblTypeLabel.Name = "lblTypeLabel";
this.lblTypeLabel.Size = new System.Drawing.Size(34, 13);
this.lblTypeLabel.TabIndex = 2;
this.lblTypeLabel.Text = "Type:";
//
// lblType
//
this.lblType.Location = new System.Drawing.Point(80, 8);
this.lblType.Name = "lblType";
this.lblType.Size = new System.Drawing.Size(100, 13);
this.lblType.TabIndex = 4;
this.lblType.Text = "Grasshopper";
//
// btnClose
//
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(-32, -32);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(32, 32);
this.btnClose.TabIndex = 32;
this.btnClose.TabStop = false;
this.btnClose.Text = "X";
//
// lblEquipLabel
//
this.lblEquipLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblEquipLabel.Location = new System.Drawing.Point(8, 34);
this.lblEquipLabel.Name = "lblEquipLabel";
this.lblEquipLabel.Size = new System.Drawing.Size(64, 176);
this.lblEquipLabel.TabIndex = 43;
this.lblEquipLabel.Text = "Hull:\r\n\r\nEquipment:\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nUnfilled:";
//
// lblEquip
//
this.lblEquip.Location = new System.Drawing.Point(80, 34);
this.lblEquip.Name = "lblEquip";
this.lblEquip.Size = new System.Drawing.Size(120, 176);
this.lblEquip.TabIndex = 44;
this.lblEquip.Text = "Hardened\r\n\r\n1 Military Laser\r\n1 Morgan\'s Laser\r\n1 Energy Shield\r\n1 Reflective Shi" +
"eld\r\n1 Lightning Shield\r\nNavigating System\r\nAuto-Repair System\r\n10 Extra Cargo Bays\r\nAn Escape Pod\r\n" +
"\r\n1 weapon slot\r\n1 gadget slot";
//
// boxSpecialCargo
//
this.boxSpecialCargo.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblSpecialCargo});
this.boxSpecialCargo.Location = new System.Drawing.Point(192, 8);
this.boxSpecialCargo.Name = "boxSpecialCargo";
this.boxSpecialCargo.Size = new System.Drawing.Size(200, 204);
this.boxSpecialCargo.TabIndex = 64;
this.boxSpecialCargo.TabStop = false;
this.boxSpecialCargo.Text = "Special Cargo";
//
// lblSpecialCargo
//
this.lblSpecialCargo.Location = new System.Drawing.Point(8, 16);
this.lblSpecialCargo.Name = "lblSpecialCargo";
this.lblSpecialCargo.Size = new System.Drawing.Size(190, 176);
this.lblSpecialCargo.TabIndex = 0;
this.lblSpecialCargo.Text = "No special items.";
//
// FormViewShip
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.btnClose;
this.ClientSize = new System.Drawing.Size(402, 219);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.boxSpecialCargo,
this.lblEquip,
this.lblEquipLabel,
this.btnClose,
this.lblTypeLabel,
this.lblType});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormViewShip";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Current Ship";
this.boxSpecialCargo.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void DisplayEquipment()
{
if (game.QuestStatusScarab == SpecialEvent.StatusScarabDone)
{
lblEquipLabel.Text += "Hull:" + Environment.NewLine + Environment.NewLine;
lblEquip.Text += "Hardened" + Environment.NewLine + Environment.NewLine;
}
bool equipPrinted = false;
for (int i = 0; i < Consts.Weapons.Length; i++)
{
int count = 0;
for (int j = 0; j < ship.Weapons.Length; j++)
{
if (ship.Weapons[j] != null && ship.Weapons[j].Type == Consts.Weapons[i].Type)
count++;
}
if (count > 0)
{
lblEquipLabel.Text += equipPrinted ? Environment.NewLine : "Equipment:" + Environment.NewLine;
lblEquip.Text += Functions.Multiples(count, Consts.Weapons[i].Name) + Environment.NewLine;
equipPrinted = true;
}
}
for (int i = 0; i < Consts.Shields.Length; i++)
{
int count = 0;
for (int j = 0; j < ship.Shields.Length; j++)
{
if (ship.Shields[j] != null && ship.Shields[j].Type == Consts.Shields[i].Type)
count++;
}
if (count > 0)
{
lblEquipLabel.Text += equipPrinted ? Environment.NewLine : "Equipment:" + Environment.NewLine;
lblEquip.Text += Functions.Multiples(count, Consts.Shields[i].Name) + Environment.NewLine;
equipPrinted = true;
}
}
for (int i = 0; i < Consts.Gadgets.Length; i++)
{
int count = 0;
for (int j = 0; j < ship.Gadgets.Length; j++)
{
if (ship.Gadgets[j] != null && ship.Gadgets[j].Type == Consts.Gadgets[i].Type)
count++;
}
if (count > 0)
{
lblEquipLabel.Text += equipPrinted ? Environment.NewLine : "Equipment:" + Environment.NewLine;
if (i == (int)GadgetType.ExtraCargoBays || i == (int)GadgetType.HiddenCargoBays)
{
count *= 5;
lblEquip.Text += Functions.FormatNumber(count) + Consts.Gadgets[i].Name.Substring(1) + Environment.NewLine;
}
else
lblEquip.Text += Functions.Multiples(count, Consts.Gadgets[i].Name) + Environment.NewLine;
equipPrinted = true;
}
}
if (ship.EscapePod)
{
lblEquipLabel.Text += equipPrinted ? Environment.NewLine : "Equipment:" + Environment.NewLine;
lblEquip.Text += "1 " + Strings.ShipInfoEscapePod + Environment.NewLine;
equipPrinted = true;
}
if (ship.FreeSlots > 0)
{
lblEquipLabel.Text += (equipPrinted ? Environment.NewLine : "") + "Unfilled:";
lblEquip.Text += (equipPrinted ? Environment.NewLine : "");
if (ship.FreeSlotsWeapon > 0)
lblEquip.Text += Functions.Multiples(ship.FreeSlotsWeapon, "weapon slot") + Environment.NewLine;
if (ship.FreeSlotsShield > 0)
lblEquip.Text += Functions.Multiples(ship.FreeSlotsShield, "shield slot") + Environment.NewLine;
if (ship.FreeSlotsGadget > 0)
lblEquip.Text += Functions.Multiples(ship.FreeSlotsGadget, "gadget slot") + Environment.NewLine;
}
}
private void DisplaySpecialCargo()
{
ArrayList specialCargo = new ArrayList(12);
if (ship.Tribbles > 0)
{
if (ship.Tribbles == Consts.MaxTribbles)
specialCargo.Add(Strings.SpecialCargoTribblesInfest);
else
specialCargo.Add(Functions.Multiples(ship.Tribbles, Strings.SpecialCargoTribblesCute) + ".");
}
if (game.QuestStatusJapori == SpecialEvent.StatusJaporiInTransit)
specialCargo.Add(Strings.SpecialCargoJapori);
if (ship.ArtifactOnBoard)
specialCargo.Add(Strings.SpecialCargoArtifact);
if (game.QuestStatusJarek == SpecialEvent.StatusJarekDone)
specialCargo.Add(Strings.SpecialCargoJarek);
if (ship.ReactorOnBoard)
{
specialCargo.Add(Strings.SpecialCargoReactor);
specialCargo.Add(Functions.Multiples(10 - ((game.QuestStatusReactor - 1) / 2), "bay") +
Strings.SpecialCargoReactorBays);
}
if (ship.SculptureOnBoard)
specialCargo.Add(Strings.SpecialCargoSculpture);
if (game.CanSuperWarp)
specialCargo.Add(Strings.SpecialCargoExperiment);
lblSpecialCargo.Text = specialCargo.Count == 0 ? Strings.SpecialCargoNone :
String.Join(Environment.NewLine + Environment.NewLine, Functions.ArrayListToStringArray(specialCargo));
}
#endregion
}
}