-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnit1.pas
130 lines (110 loc) · 3.11 KB
/
Unit1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, shellapi, IOUtils,
Inifiles, Vcl.Imaging.pngimage, Vcl.ExtCtrls;
type
TMain = class(TForm)
btnMp: TButton;
btnMult: TButton;
btnCustomSongs: TButton;
Image1: TImage;
procedure btnMpClick(Sender: TObject);
procedure btnMultClick(Sender: TObject);
procedure btnCustomSongsClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure SetConfigFileAndLaunch(Multiplayer: Boolean);
{ Private declarations }
public
{ Public declarations }
end;
var
Main: TMain;
INPUTSWAP: String;
DRIVERNAME: String;
INIFILENAME: String;
ROCKSMITHEXE: String;
CUSTOMSONGSFOLDER: String;
implementation
{$R *.dfm}
procedure TMain.btnCustomSongsClick(Sender: TObject);
begin
ShellExecute(0, 'explore', 'dlc\Custom\', '', '', SW_SHOWMAXIMIZED);
end;
procedure TMain.btnMpClick(Sender: TObject);
begin
SetConfigFileAndLaunch(False)
end;
procedure TMain.btnMultClick(Sender: TObject);
begin
SetConfigFileAndLaunch(True);
end;
procedure TMain.FormCreate(Sender: TObject);
var
iniFile: TiniFIle;
iniName: String;
begin
iniName := TPath.GetFileNameWithoutExtension(Application.ExeName) + '.ini';
if FileExists(iniName) then
begin
iniFile := TiniFIle.Create(ExtractFilePath(Application.ExeName) + iniName);
try
INIFILENAME := iniFile.ReadString('CONFIG', 'RSINI', '');
INPUTSWAP := iniFile.ReadString('CONFIG', 'INPUTSWAP', '');
DRIVERNAME := iniFile.ReadString('CONFIG', 'DRIVERNAME', '');
ROCKSMITHEXE := iniFile.ReadString('CONFIG', 'ROCKSMITHEXE', '');
CUSTOMSONGSFOLDER := iniFile.ReadString('CONFIG',
'CUSTOMSONGSFOLDER', '');
btnCustomSongs.Visible := CUSTOMSONGSFOLDER <> '';
finally
FreeAndNil(iniFile);
end;
end
else
begin
ShowMessage(iniName + ' is missing' + #10#13 +
'Make sure you extract the exe and ini file to the same location');
Application.Terminate;
end;
end;
procedure TMain.SetConfigFileAndLaunch(Multiplayer: Boolean);
var
RS_ASIO: TStringList;
i: Integer;
ln: String;
begin
if FileExists(INIFILENAME) then
begin
RS_ASIO := TStringList.Create;
try
RS_ASIO.LoadFromFile(INIFILENAME);
for i := 0 to RS_ASIO.Count - 1 do
begin
ln := RS_ASIO.Strings[i];
if ln = INPUTSWAP then
if Multiplayer then
RS_ASIO.Strings[i + 1] := 'Driver=' + DRIVERNAME
else
RS_ASIO.Strings[i + 1] := 'Driver='
end;
finally
RS_ASIO.SaveToFile(INIFILENAME);
FreeAndNil(RS_ASIO)
end;
if FileExists(ROCKSMITHEXE) then
ShellExecute(0, 'open', PWideChar(ROCKSMITHEXE), '', '', SW_SHOWNORMAL)
else
ShowMessage(ROCKSMITHEXE + ' is missing' + #10#13 +
'Make sure you extract this app to RockSmith folder');
end
else
begin
ShowMessage(INIFILENAME + ' is missing' + #10#13 +
'Make sure you extract this app to RockSmith folder');
end;
Application.Terminate;
end;
end.