Skip to content

Commit cc211bd

Browse files
committed
no message
1 parent 1e893da commit cc211bd

File tree

5 files changed

+66
-23
lines changed

5 files changed

+66
-23
lines changed

Minesweeper_proj.dpr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ uses
99
UBoardFrame in 'UBoardFrame.pas' {BoardFrame: TFrame},
1010
UDogFrame in 'UDogFrame.pas' {DogFrame: TFrame},
1111
UCustomBoardForm in 'UCustomBoardForm.pas' {CustomBoardForm},
12-
UHighScoresForm in 'UHighScoresForm.pas' {HighScoresForm};
12+
UHighScoresForm in 'UHighScoresForm.pas' {HighScoresForm},
13+
Vcl.Themes,
14+
Vcl.Styles;
1315

1416
{$R *.res}
1517

Minesweeper_proj.dproj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
7272
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
7373
<SanitizedProjectName>Minesweeper_proj</SanitizedProjectName>
74+
<VerInfo_Locale>1029</VerInfo_Locale>
75+
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
7476
</PropertyGroup>
7577
<PropertyGroup Condition="'$(Base_Win32)'!=''">
7678
<DCC_UsePackage>vclwinx;fmx;vclie;DbxCommonDriver;bindengine;IndyIPCommon;VCLRESTComponents;FireDACCommonODBC;FireDACCommonDriver;appanalytics;IndyProtocols;vclx;Skia.Package.RTL;IndyIPClient;dbxcds;vcledge;bindcompvclwinx;bindcompfmx;inetdb;FireDACSqliteDriver;DbxClientDriver;soapmidas;vclactnband;fmxFireDAC;dbexpress;DBXMySQLDriver;VclSmp;inet;vcltouch;fmxase;dbrtl;Skia.Package.FMX;fmxdae;FireDACMSAccDriver;CustomIPTransport;vcldsnap;DBXInterBaseDriver;IndySystem;Skia.Package.VCL;vcldb;vclFireDAC;bindcomp;FireDACCommon;IndyCore;RESTBackendComponents;bindcompdbx;rtl;FireDACMySQLDriver;FireDACADSDriver;RESTComponents;DBXSqliteDriver;vcl;IndyIPServer;dsnapxml;dsnapcon;adortl;vclimg;FireDACPgDriver;FireDAC;inetdbxpress;xmlrtl;tethering;bindcompvcl;dsnap;CloudService;fmxobj;bindcompvclsmp;soaprtl;soapserver;FireDACIBDriver;$(DCC_UsePackage)</DCC_UsePackage>
@@ -86,9 +88,10 @@
8688
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
8789
<BT_BuildType>Debug</BT_BuildType>
8890
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
89-
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
9091
<VerInfo_Locale>1033</VerInfo_Locale>
92+
<Icon_MainIcon>Minesweeper_proj_Icon.ico</Icon_MainIcon>
9193
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
94+
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
9295
</PropertyGroup>
9396
<PropertyGroup Condition="'$(Cfg_1)'!=''">
9497
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
@@ -118,6 +121,9 @@
118121
</PropertyGroup>
119122
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
120123
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
124+
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
125+
<VerInfo_Locale>1033</VerInfo_Locale>
126+
<Icon_MainIcon>Minesweeper_proj_Icon.ico</Icon_MainIcon>
121127
</PropertyGroup>
122128
<ItemGroup>
123129
<DelphiCompile Include="$(MainSource)">
@@ -172,6 +178,10 @@
172178
<Source>
173179
<Source Name="MainSource">Minesweeper_proj.dpr</Source>
174180
</Source>
181+
<Excluded_Packages>
182+
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k290.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
183+
<Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
184+
</Excluded_Packages>
175185
</Delphi.Personality>
176186
<Deployment Version="4">
177187
<DeployFile LocalName="Win32\Debug\Minesweeper_proj.exe" Configuration="Debug" Class="ProjectOutput">

Minesweeper_proj_Icon.ico

6.62 KB
Binary file not shown.

UHighScoresForm.dfm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ object HighScoresForm: THighScoresForm
4242
object Label3: TLabel
4343
Left = 8
4444
Top = 29
45-
Width = 33
45+
Width = 36
4646
Height = 15
47-
Caption = 'Mines'
47+
Caption = 'Mines:'
4848
Font.Charset = DEFAULT_CHARSET
4949
Font.Color = clCream
5050
Font.Height = -12

UHighScoresForm.pas

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,59 @@ procedure THighScoresForm.LoadForConfig(aWidth, aHeight, aMines: Integer);
8888
end;
8989

9090
procedure THighScoresForm.NewScore(aScore: TDateTime);
91-
procedure _overwrite(aPlace: Integer);
91+
function _getUserName(): String;
9292
begin
93-
var userName: String;
94-
InputQuery('New high score!', 'What is your name?', userName);
95-
96-
var ini := TInifile.Create('./highscores.ini');
97-
try
98-
ini.WriteDateTime(GetSectionKey(), 'Place' + IntToStr(aPlace) + 'Time', aScore);
99-
ini.WriteString(GetSectionKey(), 'Place' + IntToStr(aPlace) + 'Name', userName);
100-
finally
101-
FreeAndNil(ini);
102-
end;
103-
104-
LoadForConfig(fWidth, fHeight, fMines);
93+
InputQuery('New high score!', 'What is your name?', result);
10594
end;
10695
begin
107-
if fPlace1Time > aScore then
108-
_overwrite(1)
109-
else if fPlace2Time > aScore then
110-
_overwrite(2)
111-
else if fPlace3Time > aScore then
112-
_overwrite(3);
96+
97+
// Is score worse than 3rd place? -> exit
98+
if aScore >= fPlace3Time then
99+
Exit();
100+
101+
var userName := _getUserName();
102+
103+
fPlace3Time := aScore;
104+
lblPlace3Name.Caption := userName;
105+
106+
// Promote to 2nd
107+
if aScore < fPlace2Time then
108+
begin
109+
fPlace3Time := fPlace2Time;
110+
lblPlace3Name.Caption := lblPlace2Name.Caption;
111+
112+
fPlace2Time := aScore;
113+
lblPlace2Name.Caption := userName;
114+
end;
115+
116+
// Promote to 1st
117+
if aScore < fPlace1Time then
118+
begin
119+
fPlace2Time := fPlace1Time;
120+
lblPlace2Name.Caption := lblPlace1Name.Caption;
121+
122+
fPlace1Time := aScore;
123+
lblPlace1Name.Caption := userName;
124+
end;
125+
126+
// Write
127+
var key := GetSectionKey();
128+
129+
var ini := TIniFile.Create('./highscores.ini');
130+
try
131+
ini.WriteString(key, 'Place1Name', lblPlace1Name.Caption);
132+
ini.WriteString(key, 'Place2Name', lblPlace2Name.Caption);
133+
ini.WriteString(key, 'Place3Name', lblPlace3Name.Caption);
134+
135+
ini.WriteDateTime(key, 'Place1Time', fPlace1Time);
136+
ini.WriteDateTime(key, 'Place2Time', fPlace2Time);
137+
ini.WriteDateTime(key, 'Place3Time', fPlace3Time);
138+
finally
139+
FreeAndNil(ini);
140+
end;
141+
142+
// Reload
143+
LoadForConfig(fWidth, fHeight, fMines);
113144
end;
114145

115146
end.

0 commit comments

Comments
 (0)