-
Notifications
You must be signed in to change notification settings - Fork 5
/
UFrmMain.pas
148 lines (123 loc) · 3.47 KB
/
UFrmMain.pas
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
unit UFrmMain;
interface
uses Vcl.Forms, DamUnit, Vcl.Buttons, Vcl.Controls, Vcl.StdCtrls,
System.Classes, Vcl.ExtCtrls;
type
TFrmMain = class(TForm)
Dam: TDam;
BoxTitle: TPanel;
LbVersion: TLabel;
_QuestionCloseApp: TDamMsg;
BoxTitleSide: TPanel;
BtnSettings: TSpeedButton;
LbLink: TLabel;
LbSpace1: TLabel;
LbSpace2: TLabel;
LbSpace3: TLabel;
BoxConInfo: TPanel;
LbLbMode: TLabel;
LbMode: TLabel;
LbSpace4: TLabel;
LbLbPlayer: TLabel;
LbPlayer: TLabel;
LbSpace5: TLabel;
LbLbRules: TLabel;
LbRules: TLabel;
_QuestionKillPlayer: TDamMsg;
_QuestionStopGame: TDamMsg;
BtnRestart: TSpeedButton;
_QuestionRestartGame: TDamMsg;
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure BtnSettingsClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure LbLinkClick(Sender: TObject);
procedure BtnRestartClick(Sender: TObject);
private
procedure InitStartPage;
procedure InitGamePage;
public
procedure ConfigLanguage(Save: Boolean);
procedure InitTranslation;
end;
var
FrmMain: TFrmMain;
implementation
{$R *.dfm}
uses UVars, UDams, ULanguage,
UFrmStart, UFrmGame, UFrmLog, UFrmSettings, UDMClient, UDMServer, UFrmDrop,
System.SysUtils, System.IniFiles, Winapi.ShellAPI;
procedure TFrmMain.FormCreate(Sender: TObject);
begin
ReportMemoryLeaksOnShutdown := True;
ConfigLanguage(False); //load config language
Lang.LoadLanguage;
InitTranslation;
TSettings.Load;
Randomize;
InitLogArea;
InitStartPage;
InitGamePage;
FrmStart.Show;
end;
procedure TFrmMain.ConfigLanguage(Save: Boolean);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create(GetIniFilePath);
try
if Save then
Ini.WriteString('Language', 'ID', pubLanguageID)
else
pubLanguageID := Ini.ReadString('Language', 'ID', 'EN');
finally
Ini.Free;
end;
end;
procedure TFrmMain.InitTranslation;
begin
LbVersion.Caption := Format(Lang.Get('TITLE_VERSION'), [STR_VERSION]);
LbLbMode.Caption := Lang.Get('TITLE_MODE')+' ';
LbLbPlayer.Caption := Lang.Get('TITLE_PLAYER')+' ';
LbLbRules.Caption := Lang.Get('TITLE_RULES')+' ';
BtnRestart.Caption := Lang.Get('TITLE_RESTART');
_QuestionCloseApp.Message := Lang.Get('MSG_CLOSE_APP');
_QuestionKillPlayer.Message := Lang.Get('MSG_KILL_PLAYER');
_QuestionStopGame.Message := Lang.Get('MSG_STOP_GAME');
_QuestionRestartGame.Message := Lang.Get('MSG_RESTART_GAME');
end;
procedure TFrmMain.InitStartPage;
begin
FrmStart := TFrmStart.Create(Application);
FrmStart.Parent := Self;
end;
procedure TFrmMain.InitGamePage;
begin
FrmGame := TFrmGame.Create(Application);
FrmGame.Parent := Self;
end;
procedure TFrmMain.FormResize(Sender: TObject);
begin
FrmStart.Left := (ClientWidth - FrmStart.Width) div 2;
FrmStart.Top := BoxTitle.Height + ((ClientHeight-FrmStart.Height-BoxTitle.Height-FrmLog.Height) div 2);
end;
procedure TFrmMain.LbLinkClick(Sender: TObject);
begin
ShellExecute(0, '', 'http://digaodalpiaz.com/', '', '', 0);
end;
procedure TFrmMain.BtnRestartClick(Sender: TObject);
begin
if Assigned(FrmDrop) then Exit;
if QuestionRestartGame then
DMServer.RestartGame;
end;
procedure TFrmMain.BtnSettingsClick(Sender: TObject);
begin
ShowSettings;
end;
procedure TFrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if DMClient.C.Connected then
if not QuestionCloseApp then CanClose := False;
end;
end.