Repository navigation
Expand file tree
/
Copy pathMain.pas
More file actions
204 lines (184 loc) · 5.87 KB
/
Copy pathMain.pas
File metadata and controls
204 lines (184 loc) · 5.87 KB
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
unit MAIN;
interface
uses Winapi.Windows, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Forms,
Vcl.Controls, Vcl.Menus, Vcl.StdCtrls, Vcl.Dialogs, Vcl.Buttons, Winapi.Messages,
Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.StdActns, Vcl.ActnList, Vcl.ToolWin,
Vcl.ImgList, System.ImageList, System.Actions, UDMCore, Data.DB, Vcl.Grids,
Vcl.DBGrids, nxdb, Vcl.DBCtrls;
type
TMainForm = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
FileNewItem: TMenuItem;
FileOpenItem: TMenuItem;
FileCloseItem: TMenuItem;
Window1: TMenuItem;
Help1: TMenuItem;
N1: TMenuItem;
FileExitItem: TMenuItem;
WindowCascadeItem: TMenuItem;
WindowTileItem: TMenuItem;
WindowArrangeItem: TMenuItem;
HelpAboutItem: TMenuItem;
OpenDialog: TOpenDialog;
FileSaveItem: TMenuItem;
FileSaveAsItem: TMenuItem;
Edit1: TMenuItem;
CutItem: TMenuItem;
CopyItem: TMenuItem;
PasteItem: TMenuItem;
WindowMinimizeItem: TMenuItem;
StatusBar: TStatusBar;
ActionList1: TActionList;
EditCut1: TEditCut;
EditCopy1: TEditCopy;
EditPaste1: TEditPaste;
FileNew1: TAction;
FileSave1: TAction;
FileExit1: TAction;
FileOpen1: TAction;
FileSaveAs1: TAction;
WindowCascade1: TWindowCascade;
WindowTileHorizontal1: TWindowTileHorizontal;
WindowArrangeAll1: TWindowArrange;
WindowMinimizeAll1: TWindowMinimizeAll;
HelpAbout1: TAction;
FileClose1: TWindowClose;
WindowTileVertical1: TWindowTileVertical;
WindowTileItem2: TMenuItem;
ToolBar2: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton9: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ImageList1: TImageList;
Setup1: TMenuItem;
GameOverrideSwitches1: TMenuItem;
actSetupGameSwitches: TAction;
dsltServer: TDataSource;
ltServer: TnxTable;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
procedure FileNew1Execute(Sender: TObject);
procedure FileOpen1Execute(Sender: TObject);
procedure HelpAbout1Execute(Sender: TObject);
procedure FileExit1Execute(Sender: TObject);
procedure actSetupGameSwitchesExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DBGrid1DblClick(Sender: TObject);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure CreateMDIChild(const Name: string);
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
uses CHILDWIN, About, USetupGameSwitches;
procedure TMainForm.actSetupGameSwitchesExecute(Sender: TObject);
var
I: Integer;
FoundInstance: Boolean;
begin // Allow only 1 instance of the setup form to be opened at a time
FoundInstance := False;
for I := 0 to Pred(MDIChildCount) do
if (MDIChildren[I] is TfmSetupGameSwitches) then
begin
FoundInstance := True;
Break;
end;
if not FoundInstance then
TfmSetupGameSwitches.Create(Application)
else
begin
// MDIChildren[I].Show;
MDIChildren[I].BringToFront;
end;
end;
procedure TMainForm.CreateMDIChild(const Name: string);
var
Child: TMDIChild;
begin
{ create a new MDI child window }
Child := TMDIChild.Create(Application);
if Child.NewServer then // inserts a new record
begin
end;
end;
procedure TMainForm.DBGrid1DblClick(Sender: TObject);
var
Child: TMDIChild;
I: Integer;
begin
{ create a new MDI child window }
if not ltServer.IsEmpty then
begin
// TODO: Prevent opening of multiple of the same server
for I := 0 to Pred(MDIChildCount) do
begin
if (MDIChildren[I] is TMDIChild) then
//if (CompareText((MDIChildren[I] as TMDIChild).Caption, ltServer.FieldByName('SvrName').AsString) = 0) then
// Issue: GUID is NOT an Integer
//if ((MDIChildren[I] as TMDIChild).tblServer.FieldByName('SvrID').AsInteger = ltServer.FieldByName('SvrID').AsInteger) then
if CompareStr(GUIDToString((MDIChildren[I] as TMDIChild).tblServer.FieldByName('SvrID').AsGuid),
GUIDToString(ltServer.FieldByName('SvrID').AsGuid)) = 0 then
begin
// (MDIChildren[I] as TMDIChild).Show;
(MDIChildren[I] as TMDIChild).BringToFront;
Exit;
end;
end;
Child := TMDIChild.Create(Application);
if Child.ExistingGameServer(ltServer.FieldByName('SvrID').AsGuid) then
begin
Child.Caption := Child.tblServer.FieldByName('SvrName').AsString;
// Child.Show;
Child.BringToFront;
end;
end
else
CreateMDIChild('blah');
end;
procedure TMainForm.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
DBGrid1DblClick(Sender);
end;
procedure TMainForm.FileNew1Execute(Sender: TObject);
begin
CreateMDIChild('NONAME' + IntToStr(MDIChildCount + 1));
end;
procedure TMainForm.FileOpen1Execute(Sender: TObject);
begin
if OpenDialog.Execute then
CreateMDIChild(OpenDialog.FileName);
end;
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ltServer.Active := False; // Needs to be closed before the application closes
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
DBNavigator1.Left := DBGrid1.Width;
DBNavigator1.Top := Self.ClientHeight - DBNavigator1.Height - StatusBar.Height; //DBGrid1.Height - DBNavigator1.Height;
end;
procedure TMainForm.HelpAbout1Execute(Sender: TObject);
begin
AboutBox.ShowModal;
end;
procedure TMainForm.FileExit1Execute(Sender: TObject);
begin
Close;
end;
end.