- Changed profile, preset, locations and radar cache path to the user directory (fixes #50)
This commit is contained in:
parent
1759e0763c
commit
3df7b446f5
|
@ -31,6 +31,7 @@ uses
|
||||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
cthreads,
|
cthreads,
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
|
SysUtils,
|
||||||
Interfaces, // this includes the LCL widgetset
|
Interfaces, // this includes the LCL widgetset
|
||||||
Forms, LResources, lnetvisual, LazOpenGLContext, UdmNetwork, UfrmMain,
|
Forms, LResources, lnetvisual, LazOpenGLContext, UdmNetwork, UfrmMain,
|
||||||
UfrmLogin, UfrmInitialize, UfrmAccountControl, virtualtreeview_package,
|
UfrmLogin, UfrmInitialize, UfrmAccountControl, virtualtreeview_package,
|
||||||
|
@ -45,8 +46,14 @@ uses
|
||||||
|
|
||||||
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}
|
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}
|
||||||
|
|
||||||
|
function GetApplicationName: String;
|
||||||
|
begin
|
||||||
|
Result := 'CentrED';
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$I CentrED.lrs}
|
{$I CentrED.lrs}
|
||||||
|
OnGetApplicationName := @GetApplicationName;
|
||||||
Application.Initialize;
|
Application.Initialize;
|
||||||
Application.CreateForm(TdmNetwork, dmNetwork);
|
Application.CreateForm(TdmNetwork, dmNetwork);
|
||||||
Application.Run;
|
Application.Run;
|
||||||
|
|
|
@ -22,8 +22,8 @@ object frmLogin: TfrmLogin
|
||||||
AnchorSideBottom.Control = Owner
|
AnchorSideBottom.Control = Owner
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 15
|
Height = 16
|
||||||
Top = 231
|
Top = 230
|
||||||
Width = 481
|
Width = 481
|
||||||
Alignment = taCenter
|
Alignment = taCenter
|
||||||
Anchors = [akLeft, akRight, akBottom]
|
Anchors = [akLeft, akRight, akBottom]
|
||||||
|
|
|
@ -172,8 +172,7 @@ begin
|
||||||
lblCopyright.Caption := Format('UO CentrED Client Version %s (c) %s',
|
lblCopyright.Caption := Format('UO CentrED Client Version %s (c) %s',
|
||||||
[ProductVersion, Copyright]);
|
[ProductVersion, Copyright]);
|
||||||
|
|
||||||
FProfilePath := IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName))
|
FProfilePath := GetAppConfigDir(False) + 'Profiles' + PathDelim;
|
||||||
+ 'Profiles' + PathDelim;
|
|
||||||
ForceDirectories(FProfilePath);
|
ForceDirectories(FProfilePath);
|
||||||
if FindFirst(FProfilePath + '*.ini', faAnyFile, searchRec) = 0 then
|
if FindFirst(FProfilePath + '*.ini', faAnyFile, searchRec) = 0 then
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -275,6 +275,7 @@ type
|
||||||
protected
|
protected
|
||||||
{ Members }
|
{ Members }
|
||||||
FAppDir: String;
|
FAppDir: String;
|
||||||
|
FConfigDir: String;
|
||||||
FX: Integer;
|
FX: Integer;
|
||||||
FY: Integer;
|
FY: Integer;
|
||||||
FDrawDistance: Integer;
|
FDrawDistance: Integer;
|
||||||
|
@ -821,6 +822,8 @@ var
|
||||||
searchRec: TSearchRec;
|
searchRec: TSearchRec;
|
||||||
begin
|
begin
|
||||||
FAppDir := IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName));
|
FAppDir := IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName));
|
||||||
|
FConfigDir := GetAppConfigDir(False);
|
||||||
|
ForceDirectories(FConfigDir);
|
||||||
|
|
||||||
FLandscape := ResMan.Landscape;
|
FLandscape := ResMan.Landscape;
|
||||||
FLandscape.OnChange := @OnLandscapeChanged;
|
FLandscape.OnChange := @OnLandscapeChanged;
|
||||||
|
@ -850,7 +853,7 @@ begin
|
||||||
vstChat.NodeDataSize := SizeOf(TChatInfo);
|
vstChat.NodeDataSize := SizeOf(TChatInfo);
|
||||||
pnlChatHeader.AnchorSide[akBottom].Control := pnlBottom;
|
pnlChatHeader.AnchorSide[akBottom].Control := pnlBottom;
|
||||||
|
|
||||||
FLocationsFile := FAppDir + 'Locations.dat';
|
FLocationsFile := FConfigDir + 'Locations.dat';
|
||||||
vstLocations.NodeDataSize := SizeOf(TLocationInfo);
|
vstLocations.NodeDataSize := SizeOf(TLocationInfo);
|
||||||
try
|
try
|
||||||
if FileExists(FLocationsFile) then
|
if FileExists(FLocationsFile) then
|
||||||
|
@ -879,7 +882,7 @@ begin
|
||||||
FVirtualTiles := TWorldItemList.Create(True);
|
FVirtualTiles := TWorldItemList.Create(True);
|
||||||
FUndoList := TPacketList.Create(True);
|
FUndoList := TPacketList.Create(True);
|
||||||
|
|
||||||
FRandomPresetLocation := FAppDir + 'RandomPresets' + PathDelim;
|
FRandomPresetLocation := FConfigDir + 'RandomPresets' + PathDelim;
|
||||||
if not DirectoryExists(FRandomPresetLocation) then
|
if not DirectoryExists(FRandomPresetLocation) then
|
||||||
CreateDir(FRandomPresetLocation);
|
CreateDir(FRandomPresetLocation);
|
||||||
|
|
||||||
|
|
|
@ -1,54 +1,60 @@
|
||||||
object frmRadarMap: TfrmRadarMap
|
object frmRadarMap: TfrmRadarMap
|
||||||
Left = 290
|
Left = 290
|
||||||
Height = 360
|
Height = 360
|
||||||
Top = 171
|
Top = 171
|
||||||
Width = 479
|
Width = 479
|
||||||
HorzScrollBar.Page = 478
|
HorzScrollBar.Page = 478
|
||||||
VertScrollBar.Page = 359
|
VertScrollBar.Page = 359
|
||||||
Caption = 'Radar Map (1:8)'
|
ActiveControl = sbMain
|
||||||
ClientHeight = 360
|
Caption = 'Radar Map (1:8)'
|
||||||
ClientWidth = 479
|
ClientHeight = 360
|
||||||
OnClose = FormClose
|
ClientWidth = 479
|
||||||
OnCreate = FormCreate
|
OnClose = FormClose
|
||||||
OnDestroy = FormDestroy
|
OnCreate = FormCreate
|
||||||
OnResize = FormResize
|
OnDestroy = FormDestroy
|
||||||
Position = poOwnerFormCenter
|
OnResize = FormResize
|
||||||
ShowInTaskBar = stAlways
|
Position = poOwnerFormCenter
|
||||||
object pnlBottom: TPanel
|
ShowInTaskBar = stAlways
|
||||||
Height = 21
|
LCLVersion = '0.9.29'
|
||||||
Top = 339
|
object pnlBottom: TPanel
|
||||||
Width = 479
|
Left = 0
|
||||||
Align = alBottom
|
Height = 21
|
||||||
BevelOuter = bvNone
|
Top = 339
|
||||||
ClientHeight = 21
|
Width = 479
|
||||||
ClientWidth = 479
|
Align = alBottom
|
||||||
TabOrder = 0
|
BevelOuter = bvNone
|
||||||
object lblPosition: TLabel
|
ClientHeight = 21
|
||||||
Left = 8
|
ClientWidth = 479
|
||||||
Height = 21
|
TabOrder = 0
|
||||||
Width = 38
|
object lblPosition: TLabel
|
||||||
Align = alLeft
|
Left = 8
|
||||||
BorderSpacing.Left = 8
|
Height = 21
|
||||||
Layout = tlCenter
|
Top = 0
|
||||||
ParentColor = False
|
Width = 39
|
||||||
end
|
Align = alLeft
|
||||||
end
|
BorderSpacing.Left = 8
|
||||||
object sbMain: TScrollBox
|
Layout = tlCenter
|
||||||
Height = 339
|
ParentColor = False
|
||||||
Width = 479
|
end
|
||||||
HorzScrollBar.Page = 474
|
end
|
||||||
HorzScrollBar.Range = 292
|
object sbMain: TScrollBox
|
||||||
VertScrollBar.Page = 334
|
Left = 0
|
||||||
VertScrollBar.Range = 202
|
Height = 339
|
||||||
Align = alClient
|
Top = 0
|
||||||
TabOrder = 1
|
Width = 479
|
||||||
object pbRadar: TPaintBox
|
Align = alClient
|
||||||
Height = 202
|
ClientHeight = 335
|
||||||
Width = 292
|
ClientWidth = 475
|
||||||
OnMouseDown = pbRadarMouseDown
|
TabOrder = 1
|
||||||
OnMouseMove = pbRadarMouseMove
|
object pbRadar: TPaintBox
|
||||||
OnMouseLeave = pbRadarMouseLeave
|
Left = 0
|
||||||
OnPaint = pbRadarPaint
|
Height = 202
|
||||||
end
|
Top = 0
|
||||||
end
|
Width = 292
|
||||||
end
|
OnMouseDown = pbRadarMouseDown
|
||||||
|
OnMouseMove = pbRadarMouseMove
|
||||||
|
OnMouseLeave = pbRadarMouseLeave
|
||||||
|
OnPaint = pbRadarPaint
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -1,246 +1,245 @@
|
||||||
(*
|
(*
|
||||||
* CDDL HEADER START
|
* CDDL HEADER START
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the terms of the
|
* The contents of this file are subject to the terms of the
|
||||||
* Common Development and Distribution License, Version 1.0 only
|
* Common Development and Distribution License, Version 1.0 only
|
||||||
* (the "License"). You may not use this file except in compliance
|
* (the "License"). You may not use this file except in compliance
|
||||||
* with the License.
|
* with the License.
|
||||||
*
|
*
|
||||||
* You can obtain a copy of the license at
|
* You can obtain a copy of the license at
|
||||||
* http://www.opensource.org/licenses/cddl1.php.
|
* http://www.opensource.org/licenses/cddl1.php.
|
||||||
* See the License for the specific language governing permissions
|
* See the License for the specific language governing permissions
|
||||||
* and limitations under the License.
|
* and limitations under the License.
|
||||||
*
|
*
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
* file and include the License file at
|
* file and include the License file at
|
||||||
* http://www.opensource.org/licenses/cddl1.php. If applicable,
|
* http://www.opensource.org/licenses/cddl1.php. If applicable,
|
||||||
* add the following below this CDDL HEADER, with the fields enclosed
|
* add the following below this CDDL HEADER, with the fields enclosed
|
||||||
* by brackets "[]" replaced with your own identifying * information:
|
* by brackets "[]" replaced with your own identifying * information:
|
||||||
* Portions Copyright [yyyy] [name of copyright owner]
|
* Portions Copyright [yyyy] [name of copyright owner]
|
||||||
*
|
*
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Portions Copyright 2007 Andreas Schneider
|
* Portions Copyright 2009 Andreas Schneider
|
||||||
*)
|
*)
|
||||||
unit UfrmRadar;
|
unit UfrmRadar;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||||
ImagingClasses, ImagingComponents, ImagingTypes, UEnhancedMemoryStream, crc,
|
ImagingClasses, ImagingComponents, ImagingTypes, UEnhancedMemoryStream, crc,
|
||||||
StdCtrls;
|
StdCtrls;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
TRadarColorMap = array of Word;
|
TRadarColorMap = array of Word;
|
||||||
|
|
||||||
{ TfrmRadarMap }
|
{ TfrmRadarMap }
|
||||||
|
|
||||||
TfrmRadarMap = class(TForm)
|
TfrmRadarMap = class(TForm)
|
||||||
lblPosition: TLabel;
|
lblPosition: TLabel;
|
||||||
pbRadar: TPaintBox;
|
pbRadar: TPaintBox;
|
||||||
pnlBottom: TPanel;
|
pnlBottom: TPanel;
|
||||||
sbMain: TScrollBox;
|
sbMain: TScrollBox;
|
||||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure FormResize(Sender: TObject);
|
procedure FormResize(Sender: TObject);
|
||||||
procedure pbRadarMouseDown(Sender: TObject; Button: TMouseButton;
|
procedure pbRadarMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
procedure pbRadarMouseLeave(Sender: TObject);
|
procedure pbRadarMouseLeave(Sender: TObject);
|
||||||
procedure pbRadarMouseMove(Sender: TObject; Shift: TShiftState; X,
|
procedure pbRadarMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
Y: Integer);
|
Y: Integer);
|
||||||
procedure pbRadarPaint(Sender: TObject);
|
procedure pbRadarPaint(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
FRadar: TSingleImage;
|
FRadar: TSingleImage;
|
||||||
FRadarDependencies: TList;
|
FRadarDependencies: TList;
|
||||||
procedure OnRadarHandlingPacket(ABuffer: TEnhancedMemoryStream);
|
procedure OnRadarHandlingPacket(ABuffer: TEnhancedMemoryStream);
|
||||||
procedure RefreshRadar(ARadarMap: TRadarColorMap);
|
procedure RefreshRadar(ARadarMap: TRadarColorMap);
|
||||||
procedure RepaintRadar;
|
procedure RepaintRadar;
|
||||||
public
|
public
|
||||||
property Radar: TSingleImage read FRadar;
|
property Radar: TSingleImage read FRadar;
|
||||||
property Dependencies: TList read FRadarDependencies;
|
property Dependencies: TList read FRadarDependencies;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
frmRadarMap: TfrmRadarMap;
|
frmRadarMap: TfrmRadarMap;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
UdmNetwork, UGameResources, UPacketHandlers, UPackets, UfrmInitialize,
|
UdmNetwork, UGameResources, UPacketHandlers, UPackets, UfrmInitialize,
|
||||||
UfrmMain, UGraphicHelper;
|
UfrmMain, UGraphicHelper;
|
||||||
|
|
||||||
{ TfrmRadarMap }
|
{ TfrmRadarMap }
|
||||||
|
|
||||||
procedure TfrmRadarMap.FormCreate(Sender: TObject);
|
procedure TfrmRadarMap.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FRadar := TSingleImage.CreateFromParams(ResMan.Landscape.Width,
|
FRadar := TSingleImage.CreateFromParams(ResMan.Landscape.Width,
|
||||||
ResMan.Landscape.Height, ifA8R8G8B8);
|
ResMan.Landscape.Height, ifA8R8G8B8);
|
||||||
pbRadar.Width := FRadar.Width;
|
pbRadar.Width := FRadar.Width;
|
||||||
pbRadar.Height := FRadar.Height;
|
pbRadar.Height := FRadar.Height;
|
||||||
sbMain.ClientWidth := FRadar.Width;
|
sbMain.ClientWidth := FRadar.Width;
|
||||||
sbMain.ClientHeight := FRadar.Height;
|
sbMain.ClientHeight := FRadar.Height;
|
||||||
ClientWidth := sbMain.Width + sbMain.VertScrollBar.Size;
|
ClientWidth := sbMain.Width + sbMain.VertScrollBar.Size;
|
||||||
ClientHeight := sbMain.Height + sbMain.HorzScrollBar.Size + pnlBottom.Height;
|
ClientHeight := sbMain.Height + sbMain.HorzScrollBar.Size + pnlBottom.Height;
|
||||||
Constraints.MaxWidth := Width;
|
Constraints.MaxWidth := Width;
|
||||||
Constraints.MaxHeight := Height;
|
Constraints.MaxHeight := Height;
|
||||||
|
|
||||||
FRadarDependencies := TList.Create;
|
FRadarDependencies := TList.Create;
|
||||||
|
|
||||||
RegisterPacketHandler($0D, TPacketHandler.Create(0, @OnRadarHandlingPacket));
|
RegisterPacketHandler($0D, TPacketHandler.Create(0, @OnRadarHandlingPacket));
|
||||||
|
|
||||||
dmNetwork.Send(TRequestRadarChecksumPacket.Create);
|
dmNetwork.Send(TRequestRadarChecksumPacket.Create);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
procedure TfrmRadarMap.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||||
begin
|
begin
|
||||||
CloseAction := caHide;
|
CloseAction := caHide;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.FormDestroy(Sender: TObject);
|
procedure TfrmRadarMap.FormDestroy(Sender: TObject);
|
||||||
var
|
var
|
||||||
radarMap: TRadarColorMap;
|
radarMap: TRadarColorMap;
|
||||||
x, y: Integer;
|
x, y: Integer;
|
||||||
radarMapFile: TFileStream;
|
radarMapFile: TFileStream;
|
||||||
begin
|
begin
|
||||||
RegisterPacketHandler($0D, nil);
|
RegisterPacketHandler($0D, nil);
|
||||||
|
|
||||||
SetLength(radarMap, FRadar.Width * FRadar.Height);
|
SetLength(radarMap, FRadar.Width * FRadar.Height);
|
||||||
for x := 0 to FRadar.Width - 1 do
|
for x := 0 to FRadar.Width - 1 do
|
||||||
for y := 0 to FRadar.Height - 1 do
|
for y := 0 to FRadar.Height - 1 do
|
||||||
radarMap[x * FRadar.Height + y] := EncodeUOColor(PInteger(FRadar.PixelPointers[x, y])^);
|
radarMap[x * FRadar.Height + y] := EncodeUOColor(PInteger(FRadar.PixelPointers[x, y])^);
|
||||||
|
|
||||||
radarMapFile := TFileStream.Create(IncludeTrailingPathDelimiter(
|
radarMapFile := TFileStream.Create(IncludeTrailingPathDelimiter(
|
||||||
ExtractFilePath(Application.ExeName)) + 'RadarMap.cache', fmCreate);
|
ExtractFilePath(Application.ExeName)) + 'RadarMap.cache', fmCreate);
|
||||||
radarMapFile.Write(radarMap[0], Length(radarMap) * SizeOf(Word));
|
radarMapFile.Write(radarMap[0], Length(radarMap) * SizeOf(Word));
|
||||||
radarMapFile.Free;
|
radarMapFile.Free;
|
||||||
|
|
||||||
if FRadarDependencies <> nil then FreeAndNil(FRadarDependencies);
|
if FRadarDependencies <> nil then FreeAndNil(FRadarDependencies);
|
||||||
if FRadar <> nil then FreeAndNil(FRadar);
|
if FRadar <> nil then FreeAndNil(FRadar);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.FormResize(Sender: TObject);
|
procedure TfrmRadarMap.FormResize(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
sbMain.AutoScroll := (Width < Constraints.MaxWidth) or (Height < Constraints.MaxHeight);
|
sbMain.AutoScroll := (Width < Constraints.MaxWidth) or (Height < Constraints.MaxHeight);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.pbRadarMouseDown(Sender: TObject; Button: TMouseButton;
|
procedure TfrmRadarMap.pbRadarMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
frmMain.SetPos(X * 8, Y * 8);
|
frmMain.SetPos(X * 8, Y * 8);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.pbRadarMouseLeave(Sender: TObject);
|
procedure TfrmRadarMap.pbRadarMouseLeave(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
lblPosition.Caption := '';
|
lblPosition.Caption := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.pbRadarMouseMove(Sender: TObject; Shift: TShiftState; X,
|
procedure TfrmRadarMap.pbRadarMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
Y: Integer);
|
Y: Integer);
|
||||||
begin
|
begin
|
||||||
lblPosition.Caption := Format('X: %d, Y: %d', [X * 8, Y * 8]);
|
lblPosition.Caption := Format('X: %d, Y: %d', [X * 8, Y * 8]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.pbRadarPaint(Sender: TObject);
|
procedure TfrmRadarMap.pbRadarPaint(Sender: TObject);
|
||||||
var
|
var
|
||||||
posX, posY: Word;
|
posX, posY: Word;
|
||||||
begin
|
begin
|
||||||
DisplayImage(pbRadar.Canvas, 0, 0, FRadar);
|
DisplayImage(pbRadar.Canvas, 0, 0, FRadar);
|
||||||
posX := frmMain.X div 8;
|
posX := frmMain.X div 8;
|
||||||
posY := frmMain.Y div 8;
|
posY := frmMain.Y div 8;
|
||||||
pbRadar.Canvas.Pen.Color := clBlack;
|
pbRadar.Canvas.Pen.Color := clBlack;
|
||||||
pbRadar.Canvas.Pen.Style := psSolid;
|
pbRadar.Canvas.Pen.Style := psSolid;
|
||||||
pbRadar.Canvas.Brush.Color := clRed;
|
pbRadar.Canvas.Brush.Color := clRed;
|
||||||
pbRadar.Canvas.Brush.Style := bsSolid;
|
pbRadar.Canvas.Brush.Style := bsSolid;
|
||||||
pbRadar.Canvas.Ellipse(posX - 3, posY - 3, posX + 3, posY + 3);
|
pbRadar.Canvas.Ellipse(posX - 3, posY - 3, posX + 3, posY + 3);
|
||||||
{pbRadar.Canvas.Pen.Color := clRed;
|
{pbRadar.Canvas.Pen.Color := clRed;
|
||||||
pbRadar.Canvas.Pen.Style := psDash;
|
pbRadar.Canvas.Pen.Style := psDash;
|
||||||
pbRadar.Canvas.Line(0, posY, pbRadar.Width, posY);
|
pbRadar.Canvas.Line(0, posY, pbRadar.Width, posY);
|
||||||
pbRadar.Canvas.Line(posX, 0, posX, pbRadar.Height);}
|
pbRadar.Canvas.Line(posX, 0, posX, pbRadar.Height);}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmRadarMap.OnRadarHandlingPacket(ABuffer: TEnhancedMemoryStream);
|
procedure TfrmRadarMap.OnRadarHandlingPacket(ABuffer: TEnhancedMemoryStream);
|
||||||
var
|
var
|
||||||
subID: Byte;
|
subID: Byte;
|
||||||
checksum, realChecksum: Cardinal;
|
checksum, realChecksum: Cardinal;
|
||||||
radarMapFile: TFileStream;
|
radarMapFile: TFileStream;
|
||||||
radarMapFileName: string;
|
radarMapFileName: string;
|
||||||
radarMap: TRadarColorMap;
|
radarMap: TRadarColorMap;
|
||||||
x, y: Integer;
|
x, y: Integer;
|
||||||
begin
|
begin
|
||||||
subID := ABuffer.ReadByte;
|
subID := ABuffer.ReadByte;
|
||||||
case subID of
|
case subID of
|
||||||
$01: //checksum
|
$01: //checksum
|
||||||
begin
|
begin
|
||||||
checksum := ABuffer.ReadCardinal;
|
checksum := ABuffer.ReadCardinal;
|
||||||
realChecksum := crc32(0, nil, 0);
|
realChecksum := crc32(0, nil, 0);
|
||||||
radarMapFileName := IncludeTrailingPathDelimiter(ExtractFilePath(
|
radarMapFileName := GetAppConfigDir(False) + 'RadarMap.cache';
|
||||||
Application.ExeName)) + 'RadarMap.cache';
|
if FileExists(radarMapFileName) then
|
||||||
if FileExists(radarMapFileName) then
|
begin
|
||||||
begin
|
radarMapFile := TFileStream.Create(radarMapFileName, fmOpenRead);
|
||||||
radarMapFile := TFileStream.Create(radarMapFileName, fmOpenRead);
|
SetLength(radarMap, radarMapFile.Size div SizeOf(Word));
|
||||||
SetLength(radarMap, radarMapFile.Size div SizeOf(Word));
|
radarMapFile.Read(radarMap[0], radarMapFile.Size);
|
||||||
radarMapFile.Read(radarMap[0], radarMapFile.Size);
|
radarMapFile.Free;
|
||||||
radarMapFile.Free;
|
|
||||||
|
realChecksum := crc32(realChecksum, @radarMap[0], Length(radarMap) * SizeOf(Word));
|
||||||
realChecksum := crc32(realChecksum, @radarMap[0], Length(radarMap) * SizeOf(Word));
|
end;
|
||||||
end;
|
|
||||||
|
if checksum <> realChecksum then
|
||||||
if checksum <> realChecksum then
|
begin
|
||||||
begin
|
frmInitialize.lblStatus.Caption := 'Updating Radar Map';
|
||||||
frmInitialize.lblStatus.Caption := 'Updating Radar Map';
|
frmInitialize.Show;
|
||||||
frmInitialize.Show;
|
frmInitialize.SetModal;
|
||||||
frmInitialize.SetModal;
|
//frmMain.Enabled := False;
|
||||||
//frmMain.Enabled := False;
|
dmNetwork.Send(TRequestRadarMapPacket.Create);
|
||||||
dmNetwork.Send(TRequestRadarMapPacket.Create);
|
end else
|
||||||
end else
|
RefreshRadar(radarMap);
|
||||||
RefreshRadar(radarMap);
|
end;
|
||||||
end;
|
$02: //radar map
|
||||||
$02: //radar map
|
begin
|
||||||
begin
|
SetLength(radarMap, (ABuffer.Size - ABuffer.Position) div SizeOf(Word));
|
||||||
SetLength(radarMap, (ABuffer.Size - ABuffer.Position) div SizeOf(Word));
|
ABuffer.Read(radarMap[0], Length(radarMap) * SizeOf(Word));
|
||||||
ABuffer.Read(radarMap[0], Length(radarMap) * SizeOf(Word));
|
RefreshRadar(radarMap);
|
||||||
RefreshRadar(radarMap);
|
//frmMain.Enabled := True;
|
||||||
//frmMain.Enabled := True;
|
frmInitialize.UnsetModal;
|
||||||
frmInitialize.UnsetModal;
|
frmInitialize.Hide;
|
||||||
frmInitialize.Hide;
|
end;
|
||||||
end;
|
$03: //update radar
|
||||||
$03: //update radar
|
begin
|
||||||
begin
|
x := ABuffer.ReadWord;
|
||||||
x := ABuffer.ReadWord;
|
y := ABuffer.ReadWord;
|
||||||
y := ABuffer.ReadWord;
|
PInteger(FRadar.PixelPointers[x, y])^ := DecodeUOColor(ABuffer.ReadWord);
|
||||||
PInteger(FRadar.PixelPointers[x, y])^ := DecodeUOColor(ABuffer.ReadWord);
|
RepaintRadar;
|
||||||
RepaintRadar;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
procedure TfrmRadarMap.RefreshRadar(ARadarMap: TRadarColorMap);
|
||||||
procedure TfrmRadarMap.RefreshRadar(ARadarMap: TRadarColorMap);
|
var
|
||||||
var
|
x, y: Integer;
|
||||||
x, y: Integer;
|
begin
|
||||||
begin
|
for x := 0 to FRadar.Width - 1 do
|
||||||
for x := 0 to FRadar.Width - 1 do
|
for y := 0 to FRadar.Height - 1 do
|
||||||
for y := 0 to FRadar.Height - 1 do
|
PInteger(FRadar.PixelPointers[x, y])^ := DecodeUOColor(ARadarMap[x * FRadar.Height + y]);
|
||||||
PInteger(FRadar.PixelPointers[x, y])^ := DecodeUOColor(ARadarMap[x * FRadar.Height + y]);
|
RepaintRadar;
|
||||||
RepaintRadar;
|
end;
|
||||||
end;
|
|
||||||
|
procedure TfrmRadarMap.RepaintRadar;
|
||||||
procedure TfrmRadarMap.RepaintRadar;
|
var
|
||||||
var
|
i: Integer;
|
||||||
i: Integer;
|
begin
|
||||||
begin
|
pbRadar.Repaint;
|
||||||
pbRadar.Repaint;
|
for i := 0 to FRadarDependencies.Count - 1 do
|
||||||
for i := 0 to FRadarDependencies.Count - 1 do
|
TWinControl(FRadarDependencies.Items[i]).Repaint;
|
||||||
TWinControl(FRadarDependencies.Items[i]).Repaint;
|
end;
|
||||||
end;
|
|
||||||
|
initialization
|
||||||
initialization
|
{$I UfrmRadar.lrs}
|
||||||
{$I UfrmRadar.lrs}
|
|
||||||
|
end.
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue