- Fixed filter window to invalidate the current filters on delete/clear
This commit is contained in:
parent
5f76073b39
commit
6edee941ee
|
@ -11,7 +11,6 @@
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
<TargetFileExt Value=".exe"/>
|
<TargetFileExt Value=".exe"/>
|
||||||
<Title Value="CentrED"/>
|
<Title Value="CentrED"/>
|
||||||
<LFMResourceType Value="res"/>
|
|
||||||
<Icon Value="0"/>
|
<Icon Value="0"/>
|
||||||
</General>
|
</General>
|
||||||
<LazDoc Paths="../doc"/>
|
<LazDoc Paths="../doc"/>
|
||||||
|
|
|
@ -1,353 +1,355 @@
|
||||||
(*
|
(*
|
||||||
* 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 2009 Andreas Schneider
|
* Portions Copyright 2009 Andreas Schneider
|
||||||
*)
|
*)
|
||||||
unit UfrmFilter;
|
unit UfrmFilter;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||||
ExtCtrls, VirtualTrees, LCLIntf, LMessages, Buttons, UPlatformTypes, UStatics,
|
ExtCtrls, VirtualTrees, LCLIntf, LMessages, Buttons, UPlatformTypes, UStatics,
|
||||||
Menus;
|
Menus;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TfrmFilter }
|
{ TfrmFilter }
|
||||||
|
|
||||||
TfrmFilter = class(TForm)
|
TfrmFilter = class(TForm)
|
||||||
btnClear: TSpeedButton;
|
btnClear: TSpeedButton;
|
||||||
btnDelete: TSpeedButton;
|
btnDelete: TSpeedButton;
|
||||||
btnRandomPresetDelete: TSpeedButton;
|
btnRandomPresetDelete: TSpeedButton;
|
||||||
btnRandomPresetSave: TSpeedButton;
|
btnRandomPresetSave: TSpeedButton;
|
||||||
cbRandomPreset: TComboBox;
|
cbRandomPreset: TComboBox;
|
||||||
cbTileFilter: TCheckBox;
|
cbTileFilter: TCheckBox;
|
||||||
cbHueFilter: TCheckBox;
|
cbHueFilter: TCheckBox;
|
||||||
GroupBox1: TGroupBox;
|
GroupBox1: TGroupBox;
|
||||||
GroupBox2: TGroupBox;
|
GroupBox2: TGroupBox;
|
||||||
Label1: TLabel;
|
Label1: TLabel;
|
||||||
mnuUncheckHues: TMenuItem;
|
mnuUncheckHues: TMenuItem;
|
||||||
mnuCheckHues: TMenuItem;
|
mnuCheckHues: TMenuItem;
|
||||||
pnlRandomPreset: TPanel;
|
pnlRandomPreset: TPanel;
|
||||||
pmHues: TPopupMenu;
|
pmHues: TPopupMenu;
|
||||||
rgFilterType: TRadioGroup;
|
rgFilterType: TRadioGroup;
|
||||||
Splitter1: TSplitter;
|
Splitter1: TSplitter;
|
||||||
vdtFilter: TVirtualDrawTree;
|
vdtFilter: TVirtualDrawTree;
|
||||||
vdtHues: TVirtualDrawTree;
|
vdtHues: TVirtualDrawTree;
|
||||||
procedure btnClearClick(Sender: TObject);
|
procedure btnClearClick(Sender: TObject);
|
||||||
procedure btnDeleteClick(Sender: TObject);
|
procedure btnDeleteClick(Sender: TObject);
|
||||||
procedure cbHueFilterChange(Sender: TObject);
|
procedure cbHueFilterChange(Sender: TObject);
|
||||||
procedure cbTileFilterChange(Sender: TObject);
|
procedure cbTileFilterChange(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure mnuUncheckHuesClick(Sender: TObject);
|
procedure mnuUncheckHuesClick(Sender: TObject);
|
||||||
procedure mnuCheckHuesClick(Sender: TObject);
|
procedure mnuCheckHuesClick(Sender: TObject);
|
||||||
procedure rgFilterTypeClick(Sender: TObject);
|
procedure rgFilterTypeClick(Sender: TObject);
|
||||||
procedure vdtFilterDragDrop(Sender: TBaseVirtualTree; Source: TObject;
|
procedure vdtFilterDragDrop(Sender: TBaseVirtualTree; Source: TObject;
|
||||||
DataObject: IDataObject; Formats: TFormatArray; Shift: TShiftState;
|
DataObject: IDataObject; Formats: TFormatArray; Shift: TShiftState;
|
||||||
Pt: TPoint; var Effect: Integer; Mode: TDropMode);
|
Pt: TPoint; var Effect: Integer; Mode: TDropMode);
|
||||||
procedure vdtFilterDragOver(Sender: TBaseVirtualTree; Source: TObject;
|
procedure vdtFilterDragOver(Sender: TBaseVirtualTree; Source: TObject;
|
||||||
Shift: TShiftState; State: TDragState; Pt: TPoint; Mode: TDropMode;
|
Shift: TShiftState; State: TDragState; Pt: TPoint; Mode: TDropMode;
|
||||||
var Effect: Integer; var Accept: Boolean);
|
var Effect: Integer; var Accept: Boolean);
|
||||||
procedure vdtFilterDrawNode(Sender: TBaseVirtualTree;
|
procedure vdtFilterDrawNode(Sender: TBaseVirtualTree;
|
||||||
const PaintInfo: TVTPaintInfo);
|
const PaintInfo: TVTPaintInfo);
|
||||||
procedure vdtHuesChecked(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
procedure vdtHuesChecked(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||||||
procedure vdtHuesDrawNode(Sender: TBaseVirtualTree;
|
procedure vdtHuesDrawNode(Sender: TBaseVirtualTree;
|
||||||
const PaintInfo: TVTPaintInfo);
|
const PaintInfo: TVTPaintInfo);
|
||||||
protected
|
protected
|
||||||
FLocked: Boolean;
|
FLocked: Boolean;
|
||||||
FCheckedHues: TBits;
|
FCheckedHues: TBits;
|
||||||
procedure MouseLeave(var msg: TLMessage); message CM_MouseLeave;
|
procedure MouseLeave(var msg: TLMessage); message CM_MouseLeave;
|
||||||
public
|
public
|
||||||
property Locked: Boolean read FLocked write FLocked;
|
property Locked: Boolean read FLocked write FLocked;
|
||||||
function Filter(AStatic: TStaticItem): Boolean;
|
function Filter(AStatic: TStaticItem): Boolean;
|
||||||
procedure JumpToHue(AHueID: Word);
|
procedure JumpToHue(AHueID: Word);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
frmFilter: TfrmFilter;
|
frmFilter: TfrmFilter;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
UfrmMain, UGameResources, UHue, UGraphicHelper, UGUIPlatformUtils;
|
UfrmMain, UGameResources, UHue, UGraphicHelper, UGUIPlatformUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
PTileInfo = ^TTileInfo;
|
PTileInfo = ^TTileInfo;
|
||||||
TTileInfo = record
|
TTileInfo = record
|
||||||
ID: Word;
|
ID: Word;
|
||||||
end;
|
end;
|
||||||
PHueInfo = ^THueInfo;
|
PHueInfo = ^THueInfo;
|
||||||
THueInfo = record
|
THueInfo = record
|
||||||
ID: Word;
|
ID: Word;
|
||||||
Hue: THue;
|
Hue: THue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TfrmFilter }
|
{ TfrmFilter }
|
||||||
|
|
||||||
procedure TfrmFilter.FormShow(Sender: TObject);
|
procedure TfrmFilter.FormShow(Sender: TObject);
|
||||||
var
|
var
|
||||||
upperLeft, lowerLeft: TPoint;
|
upperLeft, lowerLeft: TPoint;
|
||||||
begin
|
begin
|
||||||
upperLeft := frmMain.pcLeft.ClientToScreen(Point(frmMain.pcLeft.Width, 0));
|
upperLeft := frmMain.pcLeft.ClientToScreen(Point(frmMain.pcLeft.Width, 0));
|
||||||
lowerLeft := frmMain.pcLeft.ClientToScreen(Point(frmMain.pcLeft.Width,
|
lowerLeft := frmMain.pcLeft.ClientToScreen(Point(frmMain.pcLeft.Width,
|
||||||
frmMain.pcLeft.Height));
|
frmMain.pcLeft.Height));
|
||||||
Left := upperLeft.x - 8;
|
Left := upperLeft.x - 8;
|
||||||
Top := upperLeft.y - 8;
|
Top := upperLeft.y - 8;
|
||||||
Height := lowerLeft.y - upperLeft.y;
|
Height := lowerLeft.y - upperLeft.y;
|
||||||
|
|
||||||
SetWindowParent(Handle, frmMain.Handle);
|
SetWindowParent(Handle, frmMain.Handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.mnuUncheckHuesClick(Sender: TObject);
|
procedure TfrmFilter.mnuUncheckHuesClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
vdtHues.ClearChecked;
|
vdtHues.ClearChecked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.mnuCheckHuesClick(Sender: TObject);
|
procedure TfrmFilter.mnuCheckHuesClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
node: PVirtualNode;
|
node: PVirtualNode;
|
||||||
begin
|
begin
|
||||||
node := vdtHues.GetFirst;
|
node := vdtHues.GetFirst;
|
||||||
while node <> nil do
|
while node <> nil do
|
||||||
begin
|
begin
|
||||||
vdtHues.CheckState[node] := csCheckedNormal;
|
vdtHues.CheckState[node] := csCheckedNormal;
|
||||||
node := vdtHues.GetNext(node);
|
node := vdtHues.GetNext(node);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.rgFilterTypeClick(Sender: TObject);
|
procedure TfrmFilter.rgFilterTypeClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
frmMain.InvalidateFilter;
|
frmMain.InvalidateFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.vdtFilterDragDrop(Sender: TBaseVirtualTree;
|
procedure TfrmFilter.vdtFilterDragDrop(Sender: TBaseVirtualTree;
|
||||||
Source: TObject; DataObject: IDataObject; Formats: TFormatArray;
|
Source: TObject; DataObject: IDataObject; Formats: TFormatArray;
|
||||||
Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
|
Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
|
||||||
var
|
var
|
||||||
sourceTree: TVirtualDrawTree;
|
sourceTree: TVirtualDrawTree;
|
||||||
selected, node: PVirtualNode;
|
selected, node: PVirtualNode;
|
||||||
sourceTileInfo, targetTileInfo: PTileInfo;
|
sourceTileInfo, targetTileInfo: PTileInfo;
|
||||||
begin
|
begin
|
||||||
sourceTree := Source as TVirtualDrawTree;
|
sourceTree := Source as TVirtualDrawTree;
|
||||||
if (sourceTree <> Sender) and (sourceTree <> nil) and
|
if (sourceTree <> Sender) and (sourceTree <> nil) and
|
||||||
(sourceTree.Tag = 1) then
|
(sourceTree.Tag = 1) then
|
||||||
begin
|
begin
|
||||||
Sender.BeginUpdate;
|
Sender.BeginUpdate;
|
||||||
selected := sourceTree.GetFirstSelected;
|
selected := sourceTree.GetFirstSelected;
|
||||||
while selected <> nil do
|
while selected <> nil do
|
||||||
begin
|
begin
|
||||||
sourceTileInfo := sourceTree.GetNodeData(selected);
|
sourceTileInfo := sourceTree.GetNodeData(selected);
|
||||||
if sourceTileInfo^.ID > $3FFF then
|
if sourceTileInfo^.ID > $3FFF then
|
||||||
begin
|
begin
|
||||||
node := Sender.AddChild(nil);
|
node := Sender.AddChild(nil);
|
||||||
targetTileInfo := Sender.GetNodeData(node);
|
targetTileInfo := Sender.GetNodeData(node);
|
||||||
targetTileInfo^.ID := sourceTileInfo^.ID;
|
targetTileInfo^.ID := sourceTileInfo^.ID;
|
||||||
cbTileFilter.Checked := True;
|
cbTileFilter.Checked := True;
|
||||||
frmMain.InvalidateFilter;
|
frmMain.InvalidateFilter;
|
||||||
end;
|
end;
|
||||||
selected := sourceTree.GetNextSelected(selected);
|
selected := sourceTree.GetNextSelected(selected);
|
||||||
end;
|
end;
|
||||||
Sender.EndUpdate;
|
Sender.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.vdtFilterDragOver(Sender: TBaseVirtualTree;
|
procedure TfrmFilter.vdtFilterDragOver(Sender: TBaseVirtualTree;
|
||||||
Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint;
|
Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint;
|
||||||
Mode: TDropMode; var Effect: Integer; var Accept: Boolean);
|
Mode: TDropMode; var Effect: Integer; var Accept: Boolean);
|
||||||
begin
|
begin
|
||||||
if (Source <> Sender) and (Source is TVirtualDrawTree) and
|
if (Source <> Sender) and (Source is TVirtualDrawTree) and
|
||||||
(TVirtualDrawTree(Source).Tag = 1) then
|
(TVirtualDrawTree(Source).Tag = 1) then
|
||||||
begin
|
begin
|
||||||
Accept := True;
|
Accept := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.vdtFilterDrawNode(Sender: TBaseVirtualTree;
|
procedure TfrmFilter.vdtFilterDrawNode(Sender: TBaseVirtualTree;
|
||||||
const PaintInfo: TVTPaintInfo);
|
const PaintInfo: TVTPaintInfo);
|
||||||
begin
|
begin
|
||||||
frmMain.vdtTilesDrawNode(Sender, PaintInfo);
|
frmMain.vdtTilesDrawNode(Sender, PaintInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.vdtHuesChecked(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
procedure TfrmFilter.vdtHuesChecked(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||||||
var
|
var
|
||||||
hueInfo: PHueInfo;
|
hueInfo: PHueInfo;
|
||||||
begin
|
begin
|
||||||
hueInfo := Sender.GetNodeData(Node);
|
hueInfo := Sender.GetNodeData(Node);
|
||||||
FCheckedHues.Bits[hueInfo^.ID] := (Sender.CheckState[node] = csCheckedNormal);
|
FCheckedHues.Bits[hueInfo^.ID] := (Sender.CheckState[node] = csCheckedNormal);
|
||||||
cbHueFilter.Checked := True;
|
cbHueFilter.Checked := True;
|
||||||
frmMain.InvalidateFilter;
|
frmMain.InvalidateFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.vdtHuesDrawNode(Sender: TBaseVirtualTree;
|
procedure TfrmFilter.vdtHuesDrawNode(Sender: TBaseVirtualTree;
|
||||||
const PaintInfo: TVTPaintInfo);
|
const PaintInfo: TVTPaintInfo);
|
||||||
var
|
var
|
||||||
hueInfo: PHueInfo;
|
hueInfo: PHueInfo;
|
||||||
hueColor: TColor;
|
hueColor: TColor;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
textStyle: TTextStyle;
|
textStyle: TTextStyle;
|
||||||
begin
|
begin
|
||||||
hueInfo := Sender.GetNodeData(PaintInfo.Node);
|
hueInfo := Sender.GetNodeData(PaintInfo.Node);
|
||||||
textStyle := PaintInfo.Canvas.TextStyle;
|
textStyle := PaintInfo.Canvas.TextStyle;
|
||||||
textStyle.Alignment := taLeftJustify;
|
textStyle.Alignment := taLeftJustify;
|
||||||
textStyle.Layout := tlCenter;
|
textStyle.Layout := tlCenter;
|
||||||
textStyle.Wordbreak := True;
|
textStyle.Wordbreak := True;
|
||||||
case PaintInfo.Column of
|
case PaintInfo.Column of
|
||||||
1:
|
1:
|
||||||
begin
|
begin
|
||||||
for i := 0 to 31 do
|
for i := 0 to 31 do
|
||||||
begin
|
begin
|
||||||
hueColor := ARGB2RGB(hueInfo^.Hue.ColorTable[i]);
|
hueColor := ARGB2RGB(hueInfo^.Hue.ColorTable[i]);
|
||||||
PaintInfo.Canvas.Pen.Color := hueColor;
|
PaintInfo.Canvas.Pen.Color := hueColor;
|
||||||
PaintInfo.Canvas.MoveTo(PaintInfo.CellRect.Left + 2 + i, PaintInfo.CellRect.Top + 1);
|
PaintInfo.Canvas.MoveTo(PaintInfo.CellRect.Left + 2 + i, PaintInfo.CellRect.Top + 1);
|
||||||
PaintInfo.Canvas.LineTo(PaintInfo.CellRect.Left + 2 + i, PaintInfo.CellRect.Bottom - 1);
|
PaintInfo.Canvas.LineTo(PaintInfo.CellRect.Left + 2 + i, PaintInfo.CellRect.Bottom - 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
2:
|
2:
|
||||||
begin
|
begin
|
||||||
PaintInfo.Canvas.TextRect(PaintInfo.CellRect, PaintInfo.CellRect.Left, PaintInfo.CellRect.Top, Format('$%x (%s)', [hueInfo^.ID, hueInfo^.Hue.Name]), textStyle);
|
PaintInfo.Canvas.TextRect(PaintInfo.CellRect, PaintInfo.CellRect.Left, PaintInfo.CellRect.Top, Format('$%x (%s)', [hueInfo^.ID, hueInfo^.Hue.Name]), textStyle);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.MouseLeave(var msg: TLMessage);
|
procedure TfrmFilter.MouseLeave(var msg: TLMessage);
|
||||||
begin
|
begin
|
||||||
{if Active and (not PtInRect(ClientRect, ScreenToClient(Mouse.CursorPos))) then
|
{if Active and (not PtInRect(ClientRect, ScreenToClient(Mouse.CursorPos))) then
|
||||||
Close;}
|
Close;}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TfrmFilter.Filter(AStatic: TStaticItem): Boolean;
|
function TfrmFilter.Filter(AStatic: TStaticItem): Boolean;
|
||||||
var
|
var
|
||||||
found: Boolean;
|
found: Boolean;
|
||||||
tileInfo: PTileInfo;
|
tileInfo: PTileInfo;
|
||||||
node: PVirtualNode;
|
node: PVirtualNode;
|
||||||
id: Word;
|
id: Word;
|
||||||
begin
|
begin
|
||||||
if cbTileFilter.Checked then
|
if cbTileFilter.Checked then
|
||||||
begin
|
begin
|
||||||
id := AStatic.TileID + $4000;
|
id := AStatic.TileID + $4000;
|
||||||
|
|
||||||
found := False;
|
found := False;
|
||||||
node := vdtFilter.GetFirst;
|
node := vdtFilter.GetFirst;
|
||||||
while (node <> nil) and (not found) do
|
while (node <> nil) and (not found) do
|
||||||
begin
|
begin
|
||||||
tileInfo := vdtFilter.GetNodeData(node);
|
tileInfo := vdtFilter.GetNodeData(node);
|
||||||
if tileInfo^.ID = id then
|
if tileInfo^.ID = id then
|
||||||
found := True
|
found := True
|
||||||
else
|
else
|
||||||
node := vdtFilter.GetNext(node);
|
node := vdtFilter.GetNext(node);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := ((rgFilterType.ItemIndex = 0) and (not found)) or
|
Result := ((rgFilterType.ItemIndex = 0) and (not found)) or
|
||||||
((rgFilterType.ItemIndex = 1) and found);
|
((rgFilterType.ItemIndex = 1) and found);
|
||||||
end else
|
end else
|
||||||
Result := True;
|
Result := True;
|
||||||
|
|
||||||
if cbHueFilter.Checked then
|
if cbHueFilter.Checked then
|
||||||
begin
|
begin
|
||||||
Result := Result and (
|
Result := Result and (
|
||||||
((rgFilterType.ItemIndex = 0) and (not FCheckedHues.Bits[AStatic.Hue])) or
|
((rgFilterType.ItemIndex = 0) and (not FCheckedHues.Bits[AStatic.Hue])) or
|
||||||
((rgFilterType.ItemIndex = 1) and (FCheckedHues.Bits[AStatic.Hue]))
|
((rgFilterType.ItemIndex = 1) and (FCheckedHues.Bits[AStatic.Hue]))
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.JumpToHue(AHueID: Word);
|
procedure TfrmFilter.JumpToHue(AHueID: Word);
|
||||||
var
|
var
|
||||||
hueInfo: PHueInfo;
|
hueInfo: PHueInfo;
|
||||||
node: PVirtualNode;
|
node: PVirtualNode;
|
||||||
begin
|
begin
|
||||||
node := vdtHues.GetFirst;
|
node := vdtHues.GetFirst;
|
||||||
while node <> nil do
|
while node <> nil do
|
||||||
begin
|
begin
|
||||||
hueInfo := vdtHues.GetNodeData(node);
|
hueInfo := vdtHues.GetNodeData(node);
|
||||||
if hueInfo^.ID = AHueID then
|
if hueInfo^.ID = AHueID then
|
||||||
begin
|
begin
|
||||||
vdtHues.ClearSelection;
|
vdtHues.ClearSelection;
|
||||||
vdtHues.Selected[node] := True;
|
vdtHues.Selected[node] := True;
|
||||||
vdtHues.FocusedNode := node;
|
vdtHues.FocusedNode := node;
|
||||||
node := nil;
|
node := nil;
|
||||||
end else
|
end else
|
||||||
node := vdtHues.GetNext(node);
|
node := vdtHues.GetNext(node);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.FormCreate(Sender: TObject);
|
procedure TfrmFilter.FormCreate(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
hueInfo: PHueInfo;
|
hueInfo: PHueInfo;
|
||||||
node: PVirtualNode;
|
node: PVirtualNode;
|
||||||
begin
|
begin
|
||||||
FLocked := False;
|
FLocked := False;
|
||||||
vdtFilter.NodeDataSize := SizeOf(TTileInfo);
|
vdtFilter.NodeDataSize := SizeOf(TTileInfo);
|
||||||
vdtHues.NodeDataSize := SizeOf(THueInfo);
|
vdtHues.NodeDataSize := SizeOf(THueInfo);
|
||||||
|
|
||||||
vdtHues.BeginUpdate;
|
vdtHues.BeginUpdate;
|
||||||
vdtHues.Clear;
|
vdtHues.Clear;
|
||||||
for i := 0 to ResMan.Hue.Count - 1 do
|
for i := 0 to ResMan.Hue.Count - 1 do
|
||||||
begin
|
begin
|
||||||
node := vdtHues.AddChild(nil);
|
node := vdtHues.AddChild(nil);
|
||||||
hueInfo := vdtHues.GetNodeData(node);
|
hueInfo := vdtHues.GetNodeData(node);
|
||||||
hueInfo^.ID := i + 1;
|
hueInfo^.ID := i + 1;
|
||||||
hueInfo^.Hue := ResMan.Hue.Hues[i];
|
hueInfo^.Hue := ResMan.Hue.Hues[i];
|
||||||
vdtHues.CheckType[node] := ctCheckBox;
|
vdtHues.CheckType[node] := ctCheckBox;
|
||||||
end;
|
end;
|
||||||
vdtHues.EndUpdate;
|
vdtHues.EndUpdate;
|
||||||
FCheckedHues := TBits.Create(ResMan.Hue.Count + 1);
|
FCheckedHues := TBits.Create(ResMan.Hue.Count + 1);
|
||||||
//FCheckedHues.Bits[0] := True;
|
//FCheckedHues.Bits[0] := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.FormDestroy(Sender: TObject);
|
procedure TfrmFilter.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if FCheckedHues <> nil then FreeAndNil(FCheckedHues);
|
if FCheckedHues <> nil then FreeAndNil(FCheckedHues);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmFilter.btnDeleteClick(Sender: TObject);
|
procedure TfrmFilter.btnDeleteClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
vdtFilter.DeleteSelectedNodes;
|
vdtFilter.DeleteSelectedNodes;
|
||||||
end;
|
frmMain.InvalidateFilter;
|
||||||
|
end;
|
||||||
procedure TfrmFilter.cbHueFilterChange(Sender: TObject);
|
|
||||||
begin
|
procedure TfrmFilter.cbHueFilterChange(Sender: TObject);
|
||||||
frmMain.InvalidateFilter;
|
begin
|
||||||
end;
|
frmMain.InvalidateFilter;
|
||||||
|
end;
|
||||||
procedure TfrmFilter.cbTileFilterChange(Sender: TObject);
|
|
||||||
begin
|
procedure TfrmFilter.cbTileFilterChange(Sender: TObject);
|
||||||
frmMain.InvalidateFilter;
|
begin
|
||||||
end;
|
frmMain.InvalidateFilter;
|
||||||
|
end;
|
||||||
procedure TfrmFilter.btnClearClick(Sender: TObject);
|
|
||||||
begin
|
procedure TfrmFilter.btnClearClick(Sender: TObject);
|
||||||
vdtFilter.Clear;
|
begin
|
||||||
end;
|
vdtFilter.Clear;
|
||||||
|
frmMain.InvalidateFilter;
|
||||||
initialization
|
end;
|
||||||
{$I UfrmFilter.lrs}
|
|
||||||
|
initialization
|
||||||
end.
|
{$I UfrmFilter.lrs}
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue