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);
|
||||
var
|
||||
gameMapList: IGameMapList;
|
||||
maps: TList<TGameMap>;
|
||||
map: TGameMap;
|
||||
node: PVirtualNode;
|
||||
|
||||
@ -956,20 +957,30 @@ begin
|
||||
if not Supports(ActiveGame, IGameMapList, gameMapList) then
|
||||
exit;
|
||||
|
||||
if TMapForm.Insert(Self, gameMapList, map) then
|
||||
maps := TList<TGameMap>.Create;
|
||||
try
|
||||
if TMapForm.Insert(Self, gameMapList, maps) then
|
||||
begin
|
||||
for map in maps do
|
||||
gameMapList.AddMap(map);
|
||||
UpdateMapList;
|
||||
|
||||
UpdateMapList;
|
||||
vstMapList.ClearSelection;
|
||||
|
||||
for map in maps do
|
||||
begin
|
||||
node := FindMapNode(map);
|
||||
if Assigned(node) then
|
||||
begin
|
||||
vstMapList.ClearSelection;
|
||||
vstMapList.FocusedNode := node;
|
||||
vstMapList.Selected[node] := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
FreeAndNil(maps);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.actMapRemoveExecute(Sender: TObject);
|
||||
|
@ -80,13 +80,14 @@ object MapForm: TMapForm
|
||||
Header.MainColumn = -1
|
||||
TabOrder = 1
|
||||
TreeOptions.PaintOptions = [toHideFocusRect, toShowDropmark, toShowTreeLines, toThemeAware, toUseBlendedImages]
|
||||
TreeOptions.SelectionOptions = [toFullRowSelect]
|
||||
TreeOptions.SelectionOptions = [toFullRowSelect, toMultiSelect]
|
||||
OnCollapsing = vstMapCollapsing
|
||||
OnCompareNodes = vstMapCompareNodes
|
||||
OnFocusChanged = vstMapFocusChanged
|
||||
OnFocusChanging = vstMapFocusChanging
|
||||
OnGetText = vstMapGetText
|
||||
OnPaintText = vstMapPaintText
|
||||
OnNodeDblClick = vstMapNodeDblClick
|
||||
Columns = <>
|
||||
end
|
||||
object pnlMapName: TPanel
|
||||
|
@ -3,6 +3,7 @@ unit Forms.Map;
|
||||
interface
|
||||
uses
|
||||
System.Classes,
|
||||
System.Generics.Collections,
|
||||
Vcl.Controls,
|
||||
Vcl.ExtCtrls,
|
||||
Vcl.Forms,
|
||||
@ -33,6 +34,7 @@ type
|
||||
|
||||
procedure btnOKClick(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 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);
|
||||
@ -48,19 +50,18 @@ type
|
||||
procedure SetMapName(const Value: string);
|
||||
protected
|
||||
procedure LoadPredefinedMapList(AGame: IGameMapList);
|
||||
function CreateMap: TGameMap;
|
||||
procedure CreateMaps(AMaps: TList<TGameMap>);
|
||||
|
||||
function FindMapNode(const AMapName: string): PVirtualNode;
|
||||
|
||||
property MapName: string read GetMapName write SetMapName;
|
||||
public
|
||||
class function Insert(AOwner: TComponent; AGame: IGameMapList; out AMap: TGameMap): Boolean;
|
||||
class function Insert(AOwner: TComponent; AGame: IGameMapList; AMaps: TList<TGameMap>): Boolean;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
System.Generics.Collections,
|
||||
System.StrUtils,
|
||||
System.SysUtils,
|
||||
Winapi.Windows;
|
||||
@ -78,7 +79,7 @@ const
|
||||
|
||||
|
||||
{ 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
|
||||
with Self.Create(AOwner) do
|
||||
try
|
||||
@ -86,7 +87,7 @@ begin
|
||||
|
||||
Result := (ShowModal = mrOk);
|
||||
if Result then
|
||||
AMap := CreateMap;
|
||||
CreateMaps(AMaps);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
@ -142,19 +143,32 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMapForm.CreateMap: TGameMap;
|
||||
procedure TMapForm.CreateMaps(AMaps: TList<TGameMap>);
|
||||
var
|
||||
node: PVirtualNode;
|
||||
nodeData: PGameMap;
|
||||
|
||||
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);
|
||||
if Assigned(node) then
|
||||
begin
|
||||
nodeData := vstMap.GetNodeData(node);
|
||||
Result := TGameMap.Create(nodeData^);
|
||||
AMaps.Add(TGameMap.Create(nodeData^));
|
||||
end else
|
||||
Result := TGameMap.Create(MapName, '', '');
|
||||
AMaps.Add(TGameMap.Create(MapName, '', ''));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -187,7 +201,7 @@ end;
|
||||
|
||||
procedure TMapForm.btnOKClick(Sender: TObject);
|
||||
begin
|
||||
if Length(MapName) = 0 then
|
||||
if (vstMap.SelectedCount <= 1) and (Length(MapName) = 0) then
|
||||
begin
|
||||
MessageBox(Self.Handle, 'Please enter a map name', 'Error', MB_OK or MB_ICONERROR);
|
||||
ActiveControl := edtMapName;
|
||||
@ -198,6 +212,12 @@ begin
|
||||
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);
|
||||
var
|
||||
nodeData: PGameMap;
|
||||
|
Loading…
Reference in New Issue
Block a user