Added: actual launching of the server

Fixed: map list not reverted visually
Fixed: disabled drag selection in map list / enabled full row drag
This commit is contained in:
Mark van Renswoude 2014-07-02 15:22:41 +00:00
parent 12eba2e832
commit dfcce839ea
4 changed files with 102 additions and 9 deletions

View File

@ -25,6 +25,10 @@ type
procedure Load; virtual; procedure Load; virtual;
procedure Save; virtual; procedure Save; virtual;
function GetExecutable: string; virtual; abstract;
function GetParameters: string; virtual;
function GetCommandLine: string; virtual;
property Loaded: Boolean read FLoaded; property Loaded: Boolean read FLoaded;
property Location: string read FLocation; property Location: string read FLocation;
property Modified: Boolean read FModified; property Modified: Boolean read FModified;
@ -85,6 +89,25 @@ begin
end; end;
function TCustomGame.GetParameters: string;
begin
Result := '';
end;
function TCustomGame.GetCommandLine: string;
var
parameters: string;
begin
Result := GetExecutable;
parameters := GetParameters;
if Length(parameters) > 0 then
Result := Result + ' ' + parameters;
end;
procedure TCustomGame.PropertyChanged(const APropertyName: string); procedure TCustomGame.PropertyChanged(const APropertyName: string);
begin begin
if not FModified then if not FModified then

View File

@ -31,6 +31,9 @@ type
constructor Create(const ALocation: string); override; constructor Create(const ALocation: string); override;
destructor Destroy; override; destructor Destroy; override;
function GetExecutable: string; override;
function GetParameters: string; override;
{ IGameNetwork } { IGameNetwork }
function GetServerPort: Integer; function GetServerPort: Integer;
function GetPeerPort: Integer; function GetPeerPort: Integer;
@ -80,6 +83,8 @@ uses
System.IniFiles, System.IniFiles,
System.SysUtils, System.SysUtils,
Winapi.Windows,
UDKIniFile; UDKIniFile;
@ -103,6 +108,7 @@ const
{ TChivalryGame } { TChivalryGame }
constructor TChivalryGame.Create(const ALocation: string); constructor TChivalryGame.Create(const ALocation: string);
begin begin
@ -124,6 +130,38 @@ begin
end; end;
function TChivalryGame.GetExecutable: string;
var
isWow64: BOOL;
bits: string;
begin
{$IFDEF WIN64}
bits := 'Win64';
{$ELSE}
if IsWow64Process(GetCurrentProcess, isWow64) and isWow64 then
bits := 'Win64'
else
bits := 'Win32';
{$ENDIF}
Result := Location + 'Binaries\' + bits + '\UDKLogging.exe';
end;
function TChivalryGame.GetParameters: string;
begin
// #ToDo1 -oMvR: 2-7-2014: check how changing the starting map influences the map list,
// that could make selecting the starting map possible.
// Otherwise, a starting map option would need to shuffle the
// map list a bit.
if MapCount = 0 then
raise Exception.Create('Please add at least one map to the map list');
Result := Map[0].Name + '?steamsockets -dedicated=true -seekfreeloadingserver';
end;
procedure TChivalryGame.DoLoad; procedure TChivalryGame.DoLoad;
var var
gameSettings: TUDKIniFile; gameSettings: TUDKIniFile;
@ -142,6 +180,7 @@ begin
SetMessageOfTheDay(gameSettings.ReadString(GameReplicationInfo, GameReplicationInfoMessageOfTheDay, '')); SetMessageOfTheDay(gameSettings.ReadString(GameReplicationInfo, GameReplicationInfoMessageOfTheDay, ''));
mapListChanged := (FMapList.Count > 0); mapListChanged := (FMapList.Count > 0);
FMapList.Clear;
{ Maplist is special; it occurs multiple times and order matters } { Maplist is special; it occurs multiple times and order matters }
mapListValues := TStringList.Create; mapListValues := TStringList.Create;

View File

@ -66,7 +66,7 @@ object MainForm: TMainForm
Top = 76 Top = 76
Width = 565 Width = 565
Height = 428 Height = 428
ActivePage = tsAbout ActivePage = tsMapList
Align = alClient Align = alClient
Style = tsButtons Style = tsButtons
TabOrder = 2 TabOrder = 2
@ -94,9 +94,9 @@ object MainForm: TMainForm
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible] Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
TabOrder = 0 TabOrder = 0
TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoSort, toAutoTristateTracking, toAutoChangeScale] TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoSort, toAutoTristateTracking, toAutoChangeScale]
TreeOptions.MiscOptions = [toAcceptOLEDrop, toFullRepaintOnResize, toInitOnSave, toWheelPanning, toEditOnClick] TreeOptions.MiscOptions = [toAcceptOLEDrop, toFullRepaintOnResize, toInitOnSave, toWheelPanning, toFullRowDrag, toEditOnClick]
TreeOptions.PaintOptions = [toHideFocusRect, toShowDropmark, toThemeAware, toUseBlendedImages] TreeOptions.PaintOptions = [toHideFocusRect, toShowDropmark, toThemeAware, toUseBlendedImages]
TreeOptions.SelectionOptions = [toFullRowSelect, toMiddleClickSelect, toMultiSelect, toRightClickSelect] TreeOptions.SelectionOptions = [toDisableDrawSelection, toFullRowSelect, toMiddleClickSelect, toMultiSelect, toRightClickSelect]
OnChange = vstMapListChange OnChange = vstMapListChange
OnDragOver = vstMapListDragOver OnDragOver = vstMapListDragOver
OnDragDrop = vstMapListDragDrop OnDragDrop = vstMapListDragDrop
@ -2502,9 +2502,11 @@ object MainForm: TMainForm
Top = 440 Top = 440
object actLaunch: TAction object actLaunch: TAction
Caption = '&Launch server' Caption = '&Launch server'
OnExecute = actLaunchExecute
end end
object actCopyCmdLine: TAction object actCopyCmdLine: TAction
Caption = '&Copy command line' Caption = '&Copy command line'
OnExecute = actCopyCmdLineExecute
end end
object actSave: TAction object actSave: TAction
Caption = '&Save changes' Caption = '&Save changes'

View File

@ -149,6 +149,10 @@ type
procedure SpinEditChange(Sender: TObject); procedure SpinEditChange(Sender: TObject);
procedure EditChange(Sender: TObject); procedure EditChange(Sender: TObject);
procedure actCloseExecute(Sender: TObject); procedure actCloseExecute(Sender: TObject);
procedure actSaveExecute(Sender: TObject);
procedure actRevertExecute(Sender: TObject);
procedure actLaunchExecute(Sender: TObject);
procedure actCopyCmdLineExecute(Sender: TObject);
procedure actGameAddExecute(Sender: TObject); procedure actGameAddExecute(Sender: TObject);
procedure actGameRemoveExecute(Sender: TObject); procedure actGameRemoveExecute(Sender: TObject);
procedure actGameActiveExecute(Sender: TObject); procedure actGameActiveExecute(Sender: TObject);
@ -165,8 +169,6 @@ type
procedure actMapRemoveExecute(Sender: TObject); procedure actMapRemoveExecute(Sender: TObject);
procedure actMapUpExecute(Sender: TObject); procedure actMapUpExecute(Sender: TObject);
procedure actMapDownExecute(Sender: TObject); procedure actMapDownExecute(Sender: TObject);
procedure actSaveExecute(Sender: TObject);
procedure actRevertExecute(Sender: TObject);
private type private type
TBindingExpressionList = TList<TBindingExpression>; TBindingExpressionList = TList<TBindingExpression>;
TPageMenuDictionary = TDictionary<TTabSheet, TX2MenuBarItem>; TPageMenuDictionary = TDictionary<TTabSheet, TX2MenuBarItem>;
@ -215,6 +217,7 @@ uses
System.Math, System.Math,
System.StrUtils, System.StrUtils,
System.SysUtils, System.SysUtils,
Vcl.Clipbrd,
Vcl.GraphUtil, Vcl.GraphUtil,
Vcl.Themes, Vcl.Themes,
Winapi.ShellAPI, Winapi.ShellAPI,
@ -478,10 +481,15 @@ var
gameMapList: IGameMapList; gameMapList: IGameMapList;
begin begin
if Supports(ActiveGame, IGameMapList, gameMapList) then vstMapList.BeginUpdate;
vstMapList.RootNodeCount := gameMapList.MapCount try
else if Supports(ActiveGame, IGameMapList, gameMapList) then
vstMapList.Clear; vstMapList.RootNodeCount := gameMapList.MapCount
else
vstMapList.Clear;
finally
vstMapList.EndUpdate;
end;
end; end;
@ -888,6 +896,27 @@ begin
end; end;
procedure TMainForm.actLaunchExecute(Sender: TObject);
begin
if not Assigned(ActiveGame) then
exit;
if ShellExecute(0, 'open', PChar(ActiveGame.GetExecutable), PChar(ActiveGame.GetParameters),
PChar(ActiveGame.Location), SW_SHOWNORMAL) <= 32 then
RaiseLastOSError;
end;
procedure TMainForm.actCopyCmdLineExecute(Sender: TObject);
begin
if not Assigned(ActiveGame) then
exit;
Clipboard.AsText := ActiveGame.GetCommandLine;
MessageBox(Self.Handle, 'Command line has been copied to the clipboard', 'Copy', MB_OK or MB_ICONINFORMATION);
end;
procedure TMainForm.actMapAddExecute(Sender: TObject); procedure TMainForm.actMapAddExecute(Sender: TObject);
var var
gameMapList: IGameMapList; gameMapList: IGameMapList;