Added: FS#11 - Multiselect for Add map dialog
Added: double-clicking on a map adds it to the list
This commit is contained in:
parent
6bf321999d
commit
2452ce7108
@ -949,6 +949,7 @@ end;
|
|||||||
procedure TMainForm.actMapAddExecute(Sender: TObject);
|
procedure TMainForm.actMapAddExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
gameMapList: IGameMapList;
|
gameMapList: IGameMapList;
|
||||||
|
maps: TList<TGameMap>;
|
||||||
map: TGameMap;
|
map: TGameMap;
|
||||||
node: PVirtualNode;
|
node: PVirtualNode;
|
||||||
|
|
||||||
@ -956,19 +957,29 @@ begin
|
|||||||
if not Supports(ActiveGame, IGameMapList, gameMapList) then
|
if not Supports(ActiveGame, IGameMapList, gameMapList) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if TMapForm.Insert(Self, gameMapList, map) then
|
maps := TList<TGameMap>.Create;
|
||||||
|
try
|
||||||
|
if TMapForm.Insert(Self, gameMapList, maps) then
|
||||||
begin
|
begin
|
||||||
|
for map in maps do
|
||||||
gameMapList.AddMap(map);
|
gameMapList.AddMap(map);
|
||||||
UpdateMapList;
|
|
||||||
|
|
||||||
|
UpdateMapList;
|
||||||
|
vstMapList.ClearSelection;
|
||||||
|
|
||||||
|
for map in maps do
|
||||||
|
begin
|
||||||
node := FindMapNode(map);
|
node := FindMapNode(map);
|
||||||
if Assigned(node) then
|
if Assigned(node) then
|
||||||
begin
|
begin
|
||||||
vstMapList.ClearSelection;
|
|
||||||
vstMapList.FocusedNode := node;
|
vstMapList.FocusedNode := node;
|
||||||
vstMapList.Selected[node] := True;
|
vstMapList.Selected[node] := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FreeAndNil(maps);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,13 +80,14 @@ object MapForm: TMapForm
|
|||||||
Header.MainColumn = -1
|
Header.MainColumn = -1
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
TreeOptions.PaintOptions = [toHideFocusRect, toShowDropmark, toShowTreeLines, toThemeAware, toUseBlendedImages]
|
TreeOptions.PaintOptions = [toHideFocusRect, toShowDropmark, toShowTreeLines, toThemeAware, toUseBlendedImages]
|
||||||
TreeOptions.SelectionOptions = [toFullRowSelect]
|
TreeOptions.SelectionOptions = [toFullRowSelect, toMultiSelect]
|
||||||
OnCollapsing = vstMapCollapsing
|
OnCollapsing = vstMapCollapsing
|
||||||
OnCompareNodes = vstMapCompareNodes
|
OnCompareNodes = vstMapCompareNodes
|
||||||
OnFocusChanged = vstMapFocusChanged
|
OnFocusChanged = vstMapFocusChanged
|
||||||
OnFocusChanging = vstMapFocusChanging
|
OnFocusChanging = vstMapFocusChanging
|
||||||
OnGetText = vstMapGetText
|
OnGetText = vstMapGetText
|
||||||
OnPaintText = vstMapPaintText
|
OnPaintText = vstMapPaintText
|
||||||
|
OnNodeDblClick = vstMapNodeDblClick
|
||||||
Columns = <>
|
Columns = <>
|
||||||
end
|
end
|
||||||
object pnlMapName: TPanel
|
object pnlMapName: TPanel
|
||||||
|
@ -3,6 +3,7 @@ unit Forms.Map;
|
|||||||
interface
|
interface
|
||||||
uses
|
uses
|
||||||
System.Classes,
|
System.Classes,
|
||||||
|
System.Generics.Collections,
|
||||||
Vcl.Controls,
|
Vcl.Controls,
|
||||||
Vcl.ExtCtrls,
|
Vcl.ExtCtrls,
|
||||||
Vcl.Forms,
|
Vcl.Forms,
|
||||||
@ -33,6 +34,7 @@ type
|
|||||||
|
|
||||||
procedure btnOKClick(Sender: TObject);
|
procedure btnOKClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure vstMapNodeDblClick(Sender: TBaseVirtualTree; const HitInfo: THitInfo);
|
||||||
procedure vstMapGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
|
procedure vstMapGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
|
||||||
procedure vstMapPaintText(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType);
|
procedure vstMapPaintText(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType);
|
||||||
procedure vstMapFocusChanging(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex; var Allowed: Boolean);
|
procedure vstMapFocusChanging(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex; var Allowed: Boolean);
|
||||||
@ -48,19 +50,18 @@ type
|
|||||||
procedure SetMapName(const Value: string);
|
procedure SetMapName(const Value: string);
|
||||||
protected
|
protected
|
||||||
procedure LoadPredefinedMapList(AGame: IGameMapList);
|
procedure LoadPredefinedMapList(AGame: IGameMapList);
|
||||||
function CreateMap: TGameMap;
|
procedure CreateMaps(AMaps: TList<TGameMap>);
|
||||||
|
|
||||||
function FindMapNode(const AMapName: string): PVirtualNode;
|
function FindMapNode(const AMapName: string): PVirtualNode;
|
||||||
|
|
||||||
property MapName: string read GetMapName write SetMapName;
|
property MapName: string read GetMapName write SetMapName;
|
||||||
public
|
public
|
||||||
class function Insert(AOwner: TComponent; AGame: IGameMapList; out AMap: TGameMap): Boolean;
|
class function Insert(AOwner: TComponent; AGame: IGameMapList; AMaps: TList<TGameMap>): Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
System.Generics.Collections,
|
|
||||||
System.StrUtils,
|
System.StrUtils,
|
||||||
System.SysUtils,
|
System.SysUtils,
|
||||||
Winapi.Windows;
|
Winapi.Windows;
|
||||||
@ -78,7 +79,7 @@ const
|
|||||||
|
|
||||||
|
|
||||||
{ TMapForm }
|
{ TMapForm }
|
||||||
class function TMapForm.Insert(AOwner: TComponent; AGame: IGameMapList; out AMap: TGameMap): Boolean;
|
class function TMapForm.Insert(AOwner: TComponent; AGame: IGameMapList; AMaps: TList<TGameMap>): Boolean;
|
||||||
begin
|
begin
|
||||||
with Self.Create(AOwner) do
|
with Self.Create(AOwner) do
|
||||||
try
|
try
|
||||||
@ -86,7 +87,7 @@ begin
|
|||||||
|
|
||||||
Result := (ShowModal = mrOk);
|
Result := (ShowModal = mrOk);
|
||||||
if Result then
|
if Result then
|
||||||
AMap := CreateMap;
|
CreateMaps(AMaps);
|
||||||
finally
|
finally
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
@ -142,19 +143,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TMapForm.CreateMap: TGameMap;
|
procedure TMapForm.CreateMaps(AMaps: TList<TGameMap>);
|
||||||
var
|
var
|
||||||
node: PVirtualNode;
|
node: PVirtualNode;
|
||||||
nodeData: PGameMap;
|
nodeData: PGameMap;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
if vstMap.SelectedCount > 1 then
|
||||||
|
begin
|
||||||
|
for node in vstMap.SelectedNodes do
|
||||||
|
begin
|
||||||
|
if vstMap.GetNodeLevel(node) = 1 then
|
||||||
|
begin
|
||||||
|
nodeData := vstMap.GetNodeData(node);
|
||||||
|
AMaps.Add(TGameMap.Create(nodeData^));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
node := FindMapNode(MapName);
|
node := FindMapNode(MapName);
|
||||||
if Assigned(node) then
|
if Assigned(node) then
|
||||||
begin
|
begin
|
||||||
nodeData := vstMap.GetNodeData(node);
|
nodeData := vstMap.GetNodeData(node);
|
||||||
Result := TGameMap.Create(nodeData^);
|
AMaps.Add(TGameMap.Create(nodeData^));
|
||||||
end else
|
end else
|
||||||
Result := TGameMap.Create(MapName, '', '');
|
AMaps.Add(TGameMap.Create(MapName, '', ''));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -187,7 +201,7 @@ end;
|
|||||||
|
|
||||||
procedure TMapForm.btnOKClick(Sender: TObject);
|
procedure TMapForm.btnOKClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if Length(MapName) = 0 then
|
if (vstMap.SelectedCount <= 1) and (Length(MapName) = 0) then
|
||||||
begin
|
begin
|
||||||
MessageBox(Self.Handle, 'Please enter a map name', 'Error', MB_OK or MB_ICONERROR);
|
MessageBox(Self.Handle, 'Please enter a map name', 'Error', MB_OK or MB_ICONERROR);
|
||||||
ActiveControl := edtMapName;
|
ActiveControl := edtMapName;
|
||||||
@ -198,6 +212,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMapForm.vstMapNodeDblClick(Sender: TBaseVirtualTree; const HitInfo: THitInfo);
|
||||||
|
begin
|
||||||
|
btnOK.Click;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMapForm.vstMapGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
|
procedure TMapForm.vstMapGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
|
||||||
var
|
var
|
||||||
nodeData: PGameMap;
|
nodeData: PGameMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user