Added: restart option to in-game Addons menu
This commit is contained in:
parent
76565a9c5d
commit
dfc9255585
@ -34,6 +34,10 @@ object MainForm: TMainForm
|
|||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object tsButtons: TTabSheet
|
object tsButtons: TTabSheet
|
||||||
Caption = ' Button assignment '
|
Caption = ' Button assignment '
|
||||||
|
ExplicitLeft = 0
|
||||||
|
ExplicitTop = 0
|
||||||
|
ExplicitWidth = 0
|
||||||
|
ExplicitHeight = 0
|
||||||
DesignSize = (
|
DesignSize = (
|
||||||
442
|
442
|
||||||
452)
|
452)
|
||||||
@ -528,6 +532,10 @@ object MainForm: TMainForm
|
|||||||
object tsAbout: TTabSheet
|
object tsAbout: TTabSheet
|
||||||
Caption = 'About'
|
Caption = 'About'
|
||||||
ImageIndex = 1
|
ImageIndex = 1
|
||||||
|
ExplicitLeft = 0
|
||||||
|
ExplicitTop = 0
|
||||||
|
ExplicitWidth = 0
|
||||||
|
ExplicitHeight = 0
|
||||||
object lblVersionCaption: TLabel
|
object lblVersionCaption: TLabel
|
||||||
Left = 16
|
Left = 16
|
||||||
Top = 67
|
Top = 67
|
||||||
|
@ -22,6 +22,7 @@ uses
|
|||||||
X2Log.Intf,
|
X2Log.Intf,
|
||||||
X2UtPersistIntf,
|
X2UtPersistIntf,
|
||||||
|
|
||||||
|
ControlIntf,
|
||||||
FSXSimConnectIntf,
|
FSXSimConnectIntf,
|
||||||
LEDStateConsumer,
|
LEDStateConsumer,
|
||||||
Profile,
|
Profile,
|
||||||
@ -32,6 +33,7 @@ uses
|
|||||||
const
|
const
|
||||||
CM_ASKAUTOUPDATE = WM_APP + 1;
|
CM_ASKAUTOUPDATE = WM_APP + 1;
|
||||||
CM_PROFILECHANGED = WM_APP + 2;
|
CM_PROFILECHANGED = WM_APP + 2;
|
||||||
|
CM_RESTART = WM_APP + 3;
|
||||||
|
|
||||||
TM_UPDATE = 1;
|
TM_UPDATE = 1;
|
||||||
TM_NOUPDATE = 2;
|
TM_NOUPDATE = 2;
|
||||||
@ -53,7 +55,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
TMainForm = class(TForm, IProfileObserver)
|
TMainForm = class(TForm, IProfileObserver, IControlHandler)
|
||||||
imgStateNotFound: TImage;
|
imgStateNotFound: TImage;
|
||||||
lblG940Throttle: TLabel;
|
lblG940Throttle: TLabel;
|
||||||
imgStateFound: TImage;
|
imgStateFound: TImage;
|
||||||
@ -169,8 +171,12 @@ type
|
|||||||
procedure ObserveRemove(AProfile: TProfile);
|
procedure ObserveRemove(AProfile: TProfile);
|
||||||
procedure ObserveActiveChanged(AProfile: TProfile);
|
procedure ObserveActiveChanged(AProfile: TProfile);
|
||||||
|
|
||||||
|
{ IControlHandler }
|
||||||
|
procedure Restart;
|
||||||
|
|
||||||
procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
|
procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
|
||||||
procedure CMProfileChanged(var Msg: TMessage); message CM_PROFILECHANGED;
|
procedure CMProfileChanged(var Msg: TMessage); message CM_PROFILECHANGED;
|
||||||
|
procedure CMRestart(var Msg: TMessage); message CM_RESTART;
|
||||||
protected
|
protected
|
||||||
procedure FindLEDControls;
|
procedure FindLEDControls;
|
||||||
procedure LoadProfiles;
|
procedure LoadProfiles;
|
||||||
@ -338,11 +344,13 @@ begin
|
|||||||
Application.ShowMainForm := False;
|
Application.ShowMainForm := False;
|
||||||
|
|
||||||
RegisterDeviceArrival;
|
RegisterDeviceArrival;
|
||||||
|
SetControlHandler(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.FormDestroy(Sender: TObject);
|
procedure TMainForm.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
SetControlHandler(nil);
|
||||||
FinalizeProfileMenu;
|
FinalizeProfileMenu;
|
||||||
|
|
||||||
UnregisterDeviceArrival;
|
UnregisterDeviceArrival;
|
||||||
@ -811,6 +819,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMainForm.Restart;
|
||||||
|
begin
|
||||||
|
PostMessage(Self.Handle, CM_RESTART, 0, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMainForm.CMRestart(var Msg: TMessage);
|
||||||
|
begin
|
||||||
|
ShellExecute(0, 'open', PChar(App.FileName), '/restart', PChar(App.Path), SW_SHOWMINNOACTIVE);
|
||||||
|
Close;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.SetDeviceState(const AMessage: string; AFound: Boolean);
|
procedure TMainForm.SetDeviceState(const AMessage: string; AFound: Boolean);
|
||||||
begin
|
begin
|
||||||
Log.Verbose(Format('G940 Throttle state changed (found = %s, status = %s)', [BoolToStr(AFound, True), AMessage]));
|
Log.Verbose(Format('G940 Throttle state changed (found = %s, status = %s)', [BoolToStr(AFound, True), AMessage]));
|
||||||
|
@ -36,17 +36,28 @@ uses
|
|||||||
ProfileManager in 'Units\ProfileManager.pas',
|
ProfileManager in 'Units\ProfileManager.pas',
|
||||||
FSXLEDFunctionProviderIntf in 'Units\FSXLEDFunctionProviderIntf.pas',
|
FSXLEDFunctionProviderIntf in 'Units\FSXLEDFunctionProviderIntf.pas',
|
||||||
SimBaseDocumentXMLBinding in 'Units\SimBaseDocumentXMLBinding.pas',
|
SimBaseDocumentXMLBinding in 'Units\SimBaseDocumentXMLBinding.pas',
|
||||||
FSXAutoLaunch in 'Units\FSXAutoLaunch.pas';
|
FSXAutoLaunch in 'Units\FSXAutoLaunch.pas',
|
||||||
|
ControlIntf in 'Units\ControlIntf.pas';
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
MainForm: TMainForm;
|
MainForm: TMainForm;
|
||||||
|
isRestarting: Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not SingleInstance('{67D1802F-2AB8-40B9-ADD7-14C9D36903C8}', False, False) then
|
isRestarting := FindCmdLineSwitch('restart');
|
||||||
exit;
|
|
||||||
|
while not SingleInstance('{67D1802F-2AB8-40B9-ADD7-14C9D36903C8}', False, False) do
|
||||||
|
begin
|
||||||
|
Instance.Close;
|
||||||
|
|
||||||
|
if not isRestarting then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
Sleep(1000);
|
||||||
|
end;
|
||||||
|
|
||||||
Application.Initialize;
|
Application.Initialize;
|
||||||
Application.MainFormOnTaskbar := True;
|
Application.MainFormOnTaskbar := True;
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
<Base>true</Base>
|
<Base>true</Base>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Base)'!=''">
|
<PropertyGroup Condition="'$(Base)'!=''">
|
||||||
|
<VerInfo_Release>1</VerInfo_Release>
|
||||||
<VerInfo_MinorVer>1</VerInfo_MinorVer>
|
<VerInfo_MinorVer>1</VerInfo_MinorVer>
|
||||||
<DCC_UsePackage>rtl;dbrtl;$(DCC_UsePackage)</DCC_UsePackage>
|
<DCC_UsePackage>rtl;dbrtl;$(DCC_UsePackage)</DCC_UsePackage>
|
||||||
<DCC_DcuOutput>Lib</DCC_DcuOutput>
|
<DCC_DcuOutput>Lib</DCC_DcuOutput>
|
||||||
@ -58,7 +59,7 @@
|
|||||||
<Manifest_File>None</Manifest_File>
|
<Manifest_File>None</Manifest_File>
|
||||||
<Icon_MainIcon>G940LEDControl_Icon.ico</Icon_MainIcon>
|
<Icon_MainIcon>G940LEDControl_Icon.ico</Icon_MainIcon>
|
||||||
<DCC_Namespace>Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace)</DCC_Namespace>
|
<DCC_Namespace>Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace)</DCC_Namespace>
|
||||||
<VerInfo_Keys>CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.1.0.0;InternalName=;LegalCopyright=© 2011 - 2015 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.1;Comments=</VerInfo_Keys>
|
<VerInfo_Keys>CompanyName=X²Software;FileDescription=G940 LED Control;FileVersion=1.1.1.0;InternalName=;LegalCopyright=© 2011 - 2015 X²Software;LegalTrademarks=;OriginalFilename=G940LEDControl.exe;ProductName=G940 LED Control;ProductVersion=1.1;Comments=</VerInfo_Keys>
|
||||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Base_Win64)'!=''">
|
<PropertyGroup Condition="'$(Base_Win64)'!=''">
|
||||||
@ -94,6 +95,7 @@
|
|||||||
<DCC_UNIT_PLATFORM>False</DCC_UNIT_PLATFORM>
|
<DCC_UNIT_PLATFORM>False</DCC_UNIT_PLATFORM>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||||
|
<Debugger_RunParams>/restart</Debugger_RunParams>
|
||||||
<VerInfo_IncludeVerInfo>false</VerInfo_IncludeVerInfo>
|
<VerInfo_IncludeVerInfo>false</VerInfo_IncludeVerInfo>
|
||||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=0.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=0.2;Comments=</VerInfo_Keys>
|
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=0.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=0.2;Comments=</VerInfo_Keys>
|
||||||
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
|
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
|
||||||
@ -139,6 +141,7 @@
|
|||||||
<DCCReference Include="Units\FSXLEDFunctionProviderIntf.pas"/>
|
<DCCReference Include="Units\FSXLEDFunctionProviderIntf.pas"/>
|
||||||
<DCCReference Include="Units\SimBaseDocumentXMLBinding.pas"/>
|
<DCCReference Include="Units\SimBaseDocumentXMLBinding.pas"/>
|
||||||
<DCCReference Include="Units\FSXAutoLaunch.pas"/>
|
<DCCReference Include="Units\FSXAutoLaunch.pas"/>
|
||||||
|
<DCCReference Include="Units\ControlIntf.pas"/>
|
||||||
<BuildConfiguration Include="Debug">
|
<BuildConfiguration Include="Debug">
|
||||||
<Key>Cfg_2</Key>
|
<Key>Cfg_2</Key>
|
||||||
<CfgParent>Base</CfgParent>
|
<CfgParent>Base</CfgParent>
|
||||||
|
Binary file not shown.
48
G940LEDControl/Units/ControlIntf.pas
Normal file
48
G940LEDControl/Units/ControlIntf.pas
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
unit ControlIntf;
|
||||||
|
|
||||||
|
interface
|
||||||
|
type
|
||||||
|
IControlHandler = interface
|
||||||
|
['{209A2DC9-D79C-4DC5-B515-AD4D14C44E37}']
|
||||||
|
procedure Restart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure SetControlHandler(AControlHandler: IControlHandler);
|
||||||
|
function GetControlHandler: IControlHandler;
|
||||||
|
|
||||||
|
|
||||||
|
implementation
|
||||||
|
var
|
||||||
|
ControlHandler: IControlHandler;
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
TNullControlHandler = class(TInterfacedObject, IControlHandler)
|
||||||
|
public
|
||||||
|
{ IControlHandler }
|
||||||
|
procedure Restart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure SetControlHandler(AControlHandler: IControlHandler);
|
||||||
|
begin
|
||||||
|
ControlHandler := AControlHandler;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetControlHandler: IControlHandler;
|
||||||
|
begin
|
||||||
|
if Assigned(ControlHandler) then
|
||||||
|
Result := ControlHandler
|
||||||
|
else
|
||||||
|
Result := TNullControlHandler.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TNullControlHandler }
|
||||||
|
procedure TNullControlHandler.Restart;
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
@ -282,6 +282,8 @@ const
|
|||||||
FSXMenuProfileFormat = 'G940: %s';
|
FSXMenuProfileFormat = 'G940: %s';
|
||||||
FSXMenuProfileFormatCascaded = '%s';
|
FSXMenuProfileFormatCascaded = '%s';
|
||||||
|
|
||||||
|
FSXMenuRestart = 'Restart G940LEDControl';
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ uses
|
|||||||
SimConnect,
|
SimConnect,
|
||||||
X2UtApp,
|
X2UtApp,
|
||||||
|
|
||||||
|
ControlIntf,
|
||||||
FSXResources,
|
FSXResources,
|
||||||
FSXSimConnectStateMonitor;
|
FSXSimConnectStateMonitor;
|
||||||
|
|
||||||
@ -81,6 +82,8 @@ const
|
|||||||
INTERVAL_PROCESSMESSAGES = 50;
|
INTERVAL_PROCESSMESSAGES = 50;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
MENU_RESTART = 65536;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TFSXSimConnectDefinitionRef = class(TObject)
|
TFSXSimConnectDefinitionRef = class(TObject)
|
||||||
@ -571,6 +574,13 @@ var
|
|||||||
profile: TProfile;
|
profile: TProfile;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
if AEventID = MENU_RESTART then
|
||||||
|
begin
|
||||||
|
GetControlHandler.Restart;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
if (AEventID <= 0) or (AEventID > FMenuProfiles.Count) then
|
if (AEventID <= 0) or (AEventID > FMenuProfiles.Count) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@ -697,10 +707,13 @@ begin
|
|||||||
SimConnect_MenuDeleteSubItem(SimConnectHandle, 1, Cardinal(FMenuProfiles.Objects[menuIndex]));
|
SimConnect_MenuDeleteSubItem(SimConnectHandle, 1, Cardinal(FMenuProfiles.Objects[menuIndex]));
|
||||||
|
|
||||||
SimConnect_MenuDeleteItem(SimConnectHandle, 1);
|
SimConnect_MenuDeleteItem(SimConnectHandle, 1);
|
||||||
|
SimConnect_MenuDeleteItem(SimConnectHandle, 2);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
for menuIndex := Pred(FMenuProfiles.Count) downto 0 do
|
for menuIndex := Pred(FMenuProfiles.Count) downto 0 do
|
||||||
SimConnect_MenuDeleteItem(SimConnectHandle, Cardinal(FMenuProfiles.Objects[menuIndex]));
|
SimConnect_MenuDeleteItem(SimConnectHandle, Cardinal(FMenuProfiles.Objects[menuIndex]));
|
||||||
|
|
||||||
|
SimConnect_MenuDeleteItem(SimConnectHandle, MENU_RESTART);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FMenuProfiles.Clear;
|
FMenuProfiles.Clear;
|
||||||
@ -725,6 +738,8 @@ begin
|
|||||||
SimConnect_MenuAddSubItem(SimConnectHandle, 1, PAnsiChar(AnsiString(profileName)), Succ(profileIndex), Succ(profileIndex));
|
SimConnect_MenuAddSubItem(SimConnectHandle, 1, PAnsiChar(AnsiString(profileName)), Succ(profileIndex), Succ(profileIndex));
|
||||||
FMenuProfiles.Objects[profileIndex] := TObject(Succ(profileIndex));
|
FMenuProfiles.Objects[profileIndex] := TObject(Succ(profileIndex));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
SimConnect_MenuAddItem(SimConnectHandle, FSXMenuRestart, MENU_RESTART, 0);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
for profileIndex := 0 to Pred(FMenuProfiles.Count) do
|
for profileIndex := 0 to Pred(FMenuProfiles.Count) do
|
||||||
@ -734,6 +749,8 @@ begin
|
|||||||
SimConnect_MenuAddItem(SimConnectHandle, PAnsiChar(AnsiString(profileName)), Succ(profileIndex), Succ(profileIndex));
|
SimConnect_MenuAddItem(SimConnectHandle, PAnsiChar(AnsiString(profileName)), Succ(profileIndex), Succ(profileIndex));
|
||||||
FMenuProfiles.Objects[profileIndex] := TObject(Succ(profileIndex));
|
FMenuProfiles.Objects[profileIndex] := TObject(Succ(profileIndex));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
SimConnect_MenuAddItem(SimConnectHandle, FSXMenuRestart, MENU_RESTART, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FMenuWasCascaded := ProfileMenuCascaded;
|
FMenuWasCascaded := ProfileMenuCascaded;
|
||||||
|
Loading…
Reference in New Issue
Block a user