✨ Load and list UOA designs
This commit is contained in:
+61
-1
@@ -37,7 +37,7 @@ uses
|
||||
LCLIntf, UOverlayUI, UStatics, UEnhancedMemoryStream, ActnList,
|
||||
XMLPropStorage, ImagingClasses, dateutils, UPlatformTypes, UMap, UPacket,
|
||||
UGLFont, DOM, XMLRead, XMLWrite, strutils, ULightManager, fgl, UTiledata,
|
||||
UActions;
|
||||
UActions, UUoaDesigns;
|
||||
|
||||
type
|
||||
TAccessChangedListener = procedure(AAccessLevel: TAccessLevel) of object;
|
||||
@@ -97,6 +97,7 @@ type
|
||||
edSearchID: TEdit;
|
||||
gbRandom: TGroupBox;
|
||||
ImageList1: TImageList;
|
||||
vstUoaDesigns: TLazVirtualStringTree;
|
||||
lblChatHeaderCaption: TLabel;
|
||||
lblFilter: TLabel;
|
||||
lblTipC: TLabel;
|
||||
@@ -162,6 +163,7 @@ type
|
||||
pmViewTerrainSettings: TPopupMenu;
|
||||
spChat: TSplitter;
|
||||
spTileList: TSplitter;
|
||||
tsUoaDesigns: TTabSheet;
|
||||
tbFilter: TToolButton;
|
||||
tbFlat: TToolButton;
|
||||
tbNoDraw: TToolButton;
|
||||
@@ -320,6 +322,9 @@ type
|
||||
Column: TColumnIndex; const NewText: String);
|
||||
procedure vstLocationsSaveNode(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Stream: TStream);
|
||||
procedure vstUoaDesignsGetText(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||
var CellText: String);
|
||||
procedure XMLPropStorage1RestoreProperties(Sender: TObject);
|
||||
protected
|
||||
{ Members }
|
||||
@@ -357,6 +362,7 @@ type
|
||||
FTileHint: TTileHintInfo;
|
||||
FLightManager: TLightManager;
|
||||
FTileFilter: TTileDataFlags;
|
||||
FUoaDesigns: TUoaDesigns;
|
||||
{ Methods }
|
||||
procedure BuildTileList;
|
||||
function ConfirmAction: Boolean;
|
||||
@@ -369,6 +375,7 @@ type
|
||||
procedure InitSize;
|
||||
procedure LoadLocations;
|
||||
procedure LoadRandomPresets;
|
||||
procedure LoadUoaDesigns;
|
||||
procedure MoveBy(AOffsetX, AOffsetY: Integer); inline;
|
||||
procedure PrepareMapCell(AMapCell: TMapCell);
|
||||
procedure PrepareScreenBlock(ABlockInfo: PBlockInfo);
|
||||
@@ -1023,6 +1030,8 @@ begin
|
||||
FRandomPresetsFile := FConfigDir + 'RandomPresets.xml';
|
||||
LoadRandomPresets;
|
||||
|
||||
LoadUoaDesigns;
|
||||
|
||||
DoubleBuffered := True;
|
||||
pnlBottom.DoubleBuffered := True;
|
||||
|
||||
@@ -1030,6 +1039,8 @@ begin
|
||||
FSelectionListeners := TSelectionListeners.Create;
|
||||
|
||||
FLastDraw := Now;
|
||||
|
||||
pcLeft.ActivePage := tsTiles;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.btnGoToClick(Sender: TObject);
|
||||
@@ -1396,6 +1407,7 @@ begin
|
||||
FreeAndNil(FRandomPresetsDoc);
|
||||
FreeAndNil(FAccessChangedListeners);
|
||||
FreeAndNil(FSelectionListeners);
|
||||
FreeAndNil(FUoaDesigns);
|
||||
|
||||
RegisterPacketHandler($0C, nil);
|
||||
end;
|
||||
@@ -1974,6 +1986,34 @@ begin
|
||||
Stream.Write(locationInfo^.Name[1], stringLength);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.vstUoaDesignsGetText(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||
var CellText: String);
|
||||
var
|
||||
header: TUoaDesignHeader;
|
||||
|
||||
function BuildCategoryName: String;
|
||||
begin
|
||||
if header.Category <> EmptyStr then
|
||||
Result := header.Category;
|
||||
|
||||
if header.Subcategory <> EmptyStr then
|
||||
begin
|
||||
if Result <> EmptyStr then
|
||||
Result := Result + '/';
|
||||
Result := Result + header.Subcategory;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
header := FUoaDesigns.Headers[Node^.Index];
|
||||
|
||||
case Column of
|
||||
0: CellText := header.Name;
|
||||
1: CellText := BuildCategoryName;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.XMLPropStorage1RestoreProperties(Sender: TObject);
|
||||
begin
|
||||
FTextureManager.UseAnims := mnuShowAnimations.Checked;
|
||||
@@ -2206,6 +2246,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.LoadUoaDesigns;
|
||||
var
|
||||
idxFile, binFile: String;
|
||||
i: Integer;
|
||||
begin
|
||||
idxFile := FAppDir + 'Designs.idx';
|
||||
binFile := FAppDir + 'Designs.bin';
|
||||
|
||||
if (not FileExists(idxFile)) or (not FileExists(binFile)) then
|
||||
begin
|
||||
tsUoaDesigns.TabVisible := False;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
FUoaDesigns := TUoaDesigns.Create(idxFile, binFile);
|
||||
tsUoaDesigns.TabVisible := True;
|
||||
for i := 1 to FUoaDesigns.Headers.Count do
|
||||
vstUoaDesigns.AddChild(nil);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.MoveBy(AOffsetX, AOffsetY: Integer); inline;
|
||||
begin
|
||||
SetPos(EnsureRange(FX + AOffsetX, 0, FLandscape.CellWidth - 1),
|
||||
|
||||
Reference in New Issue
Block a user