1 { This file is part of WineLauncher.
3 WineLauncher is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
8 WineLauncher is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with WineLauncher. If not, see <http://www.gnu.org/licenses/>.
17 {Made with Lazarus 0.9.26.3 fixes branch.}
18 {Free Pascal Compiler version 2.2.5.}
27 Classes
, SysUtils
, LResources
, Forms
, Controls
, Graphics
, Dialogs
, StdCtrls
,
28 DbCtrls
, BaseUnix
, Process
, CheckLst
, ExtCtrls
, ComCtrls
, UnitCreatePrefix
, UnitAbout
, Errors
;
36 Btn_DebugChannelsConfig
: TButton
;
37 Btn_Settings
: TButton
;
38 Btn_StopScan
: TButton
;
39 Button_Regedit
: TButton
;
40 Button_Winecfg
: TButton
;
41 CheckBox_UseSoundWrapper
: TCheckBox
;
42 CheckBox_DebugChannelUse
: TCheckBox
;
43 CheckListBox_Flags
: TCheckListBox
;
44 Check_Terminal
: TCheckBox
;
45 ComboBox_WineVersion
: TComboBox
;
46 ComboBox_ProgramsList
: TComboBox
;
47 ComboBox_PreFix
: TComboBox
;
48 ComboBox_SoundWrapper
: TComboBox
;
49 ComboBox_TerminalName
: TComboBox
;
50 EditBox_ProgramPath
: TEdit
;
51 Label_WineVersion
: TLabel
;
53 Label_ProgramPath
: TLabel
;
54 Label_ProgramsList
: TLabel
;
55 Label_WinePreFix
: TLabel
;
56 Memo_LogOutPut
: TMemo
;
57 PageControl1
: TPageControl
;
59 TogBtn_Listdrive
: TToggleBox
;
61 procedure Btn_DebugChannelsConfigClick(Sender
: TObject
);
62 procedure Btn_RunClick(Sender
: TObject
);
63 procedure Btn_SettingsClick(Sender
: TObject
);
64 procedure Btn_StopScanClick(Sender
: TObject
);
65 procedure Button_RegeditClick(Sender
: TObject
);
66 procedure Button_WinecfgClick(Sender
: TObject
);
67 procedure ComboBox_PreFixChange(Sender
: TObject
);
68 procedure ComboBox_ProgramsListChange(Sender
: TObject
);
69 procedure ComboBox_WineVersionEditingDone(Sender
: TObject
);
70 procedure ComboBox_WineVersionEnter(Sender
: TObject
);
71 procedure EditBox_ProgramPathChange(Sender
: TObject
);
72 procedure FormClose(Sender
: TObject
; var CloseAction
: TCloseAction
);
73 procedure FormCreate(Sender
: TObject
);
74 procedure FormDestroy(Sender
: TObject
);
75 procedure TogBtn_ListdriveChange(Sender
: TObject
);
76 procedure TimerOnTimer(Sender
: TObject
);
78 private { private declarations }
80 public { public declarations }
86 start_S1
:string; { Script to write to the file. }
87 RunIn
:string; { terminal or shell set here }
88 NoError
:Boolean; { Tbh this should not be here but im not sure need to check. }
89 Sh_Path
:string; { Path for the shell }
91 Channel
:string; { Debug channel name }
92 UnixDirPath
:string; { Needed for setting the working dir at 'Run'. }
94 Timer
:TTimer
; {The timer is a workaround.}
96 FrameCreatePrefix
:TFrameCreatePrefix
;
97 FrameAbout
:TFrameAbout
;
108 procedure TForm1
.FormCreate(Sender
: TObject
);
110 {The timer is a workaround.}
111 Timer
:= TTimer
.Create(nil) ;
112 Timer
.OnTimer
:= @TimerOnTimer
;
113 Timer
.Enabled
:= false;
114 Timer
.Interval
:= 100;
117 ComboBox_WineVersionEnter(Self
);
120 if ComboBox_SoundWrapper
.items
.Count
<> 0 then ComboBox_SoundWrapper
.Text := ComboBox_SoundWrapper
.Items
[0];
121 if ComboBox_TerminalName
.items
.Count
<> 0 then ComboBox_TerminalName
.Text := ComboBox_TerminalName
.Items
[0];
122 if ComboBox_WineVersion
.Items
.Count
<> 0 then ComboBox_WineVersion
.Text := ComboBox_WineVersion
.Items
[0];
124 {Frame Create prefix.}
125 AddTabToPageControl(PageControl1
, 'Create prefix');
126 FrameCreatePrefix
:= TFrameCreatePrefix
.Create(Self
);
127 EmbedFrame(FrameCreatePrefix
, PageControl1
.PageCount
-1);
129 AddTabToPageControl(PageControl1
, 'About');
130 FrameAbout
:= TFrameAbout
.Create(Self
);
131 EmbedFrame(FrameAbout
, PageControl1
.PageCount
-1);
133 FrameAbout
.Memo_About
.Lines
.Add('');
134 {When the is a new release update the version number in the file called 'VERSION.inc'.}
135 FrameAbout
.Memo_About
.Lines
.Add('WineLauncher Version: ' + WineLauncherVersion
);
136 FrameAbout
.Memo_About
.Lines
.Add(BuiltWithFpcVersion
);
138 {Load LastUsedConfig.}
139 LoadLastUsedConfig();
142 Btn_StopScan
.Visible
:= true;
146 procedure TForm1
.FormDestroy(Sender
: TObject
);
149 XmlLastUsedConfig
.Destroy
;
150 SetLength(TabSheets
, 0);
153 FreeAndNil(CdDataName
);
155 {stuff configed in UnitInitialization.}
157 CreatePrefixProcess
.Destroy
;
158 AsyncProcessScan
.Destroy
;
161 procedure TForm1
.TimerOnTimer(Sender
: TObject
);
165 {We should not use a timer to check this. The is a bug in lazarus, 'OnTerminate' of AsyncProcess never runs.}
166 if AsyncProcessScan
.Active
= true then
168 Timer
.Enabled
:= true;
169 Btn_StopScan
.Visible
:= true;
173 Btn_StopScan
.Visible
:= false;
174 TempList
:= TStringlist
.Create
;
175 Timer
.Enabled
:= false;
176 TempList
.LoadFromStream(AsyncProcessScan
.OutPut
);
178 if TempList
.Count
= 0 then
180 DiscErrorText
:= 'Drive' + wrap('D' + ':') + 'has no executable files.';
181 LastReadLinkPath
:= '';
188 while TempList
.Count
<> 0 do
190 CdData
.Add(UnixToWinPath(TempList
.Strings
[0],'d'));
194 ComboBox_PreFixChange(self
);
197 CheckListBox_Flags
.Clear
;
201 procedure TForm1
.TogBtn_ListdriveChange(Sender
: TObject
);
206 AsyncProcessScan
.Active
:= false;
207 Btn_StopScan
.Visible
:= false;
208 CheckListBox_Flags
.Enabled
:= true;
209 EditBox_ProgramPath
.Clear
;
212 FreeAndNil(CdDataName
);
214 ComboBox_PreFixChange(self
);
215 ComboBox_ProgramsListChange(self
);
220 CdData
:= TStringlist
.Create
;
221 CdDataName
:= TStringlist
.Create
;
223 log(0,'', LastReadLinkPath
);
224 ComboBox_PreFixChange(self
);
225 CheckListBox_Flags
.Clear
;
226 EditBox_ProgramPath
.Clear
;
233 procedure TForm1
.Btn_RunClick(Sender
: TObject
);
235 RunWineCheck( '', '' );
238 procedure TForm1
.Btn_SettingsClick(Sender
: TObject
);
240 UnitSettings
.Form4
.Show
;
243 procedure TForm1
.Btn_StopScanClick(Sender
: TObject
);
245 AsyncProcessScan
.Active
:= false;
248 procedure TForm1
.Button_RegeditClick(Sender
: TObject
);
250 RunWineCheck( 'Regedit', '' );
253 procedure TForm1
.Button_WinecfgClick(Sender
: TObject
);
255 RunWineCheck( 'winecfg', '' );
259 procedure TForm1
.ComboBox_PreFixChange(Sender
: TObject
);
263 ComboBox_ProgramsList
.Items
.Clear
;
265 EditBox_ProgramPath
.Enabled
:= true;
266 ComboBox_ProgramsList
.Enabled
:= true;
270 for myloop
:= 1 to (Data
[ComboBox_PreFix
.ItemIndex
].Grid
.RowCount
-1) do
272 if Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
] <> '' then
274 ComboBox_ProgramsList
.Items
.Add(Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
]);
282 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
284 ComboBox_ProgramsList
.ItemIndex
:= 0;
285 EditBox_ProgramPath
.Enabled
:= true;
286 ComboBox_ProgramsList
.Enabled
:= true;
287 ComboBox_ProgramsListChange(Self
);
291 ComboBox_ProgramsList
.Text := '';
292 EditBox_ProgramPath
.Text := '';
293 EditBox_ProgramPath
.Enabled
:= false;
294 ComboBox_ProgramsList
.Enabled
:= false;
300 ListProgramsOnDisc(CdData
, 'D');
301 if CdData
.Text <> '' then
304 CdDataName
.AddStrings(CdData
);
306 {Write some code to clean up the names, keep then usefull and unique.}
308 ComboBox_ProgramsList
.Items
:= CdDataName
;
309 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
311 ComboBox_ProgramsList
.Text := ComboBox_ProgramsList
.Items
[0];
312 EditBox_ProgramPath
.Enabled
:= true;
313 ComboBox_ProgramsList
.Enabled
:= true;
314 ComboBox_ProgramsListChange(self
);
320 ComboBox_ProgramsList
.Items
.Add(DiscErrorText
);
321 ComboBox_ProgramsList
.ItemIndex
:= 0;
322 EditBox_ProgramPath
.Text := '';
323 EditBox_ProgramPath
.Enabled
:= false;
324 ComboBox_ProgramsList
.Enabled
:= false;
325 CheckListBox_Flags
.Clear
;
331 procedure TForm1
.ComboBox_ProgramsListChange(Sender
: TObject
);
333 ProgramsListSelectedItem
:integer;
338 PrefixInt
:= FindPrefixInt(ComboBox_PreFix
.Items
.Strings
[ComboBox_PreFix
.ItemIndex
]);
339 EditBox_ProgramPath
.Enabled
:= true;
340 {Plus one to line it up with the grid}
341 ProgramsListSelectedItem
:= (Data
[PrefixInt
].Grid
.cols
[DataNameCol
].IndexOf(Data
[PrefixInt
].Grid
.cols
[DataNameCol
].Strings
[ComboBox_ProgramsList
.ItemIndex
]) +1);
343 EditBox_ProgramPath
.Text := Data
[PrefixInt
].Grid
.Cells
[DataPathCol
, ProgramsListSelectedItem
] ;
344 CutUpFlags(Data
[PrefixInt
].Grid
.Cells
[DataFlagsCol
, ProgramsListSelectedItem
]);
348 if CdData
.Text <> '' then
350 EditBox_ProgramPath
.Text := CdData
.Strings
[CdDataName
.IndexOf(ComboBox_ProgramsList
.Text)] ;
355 procedure TForm1
.ComboBox_WineVersionEditingDone(Sender
: TObject
);
357 OnWineVersionChange();
360 procedure TForm1
.ComboBox_WineVersionEnter(Sender
: TObject
);
363 SystemSidePath
:string;
365 {Note FpSymLink does not have a string version with fpc 2.2.5.}
366 {This is not best way adding the system side wine but it works.}
367 SystemSidePath
:= PathToWine
+ '/System Side Wine';
369 a
:= SearchForBin('wine');
370 if SearchForBin(a
) <> '' then
372 if DirExistsIfNotMakeIt(SystemSidePath
) = true then
374 if DirExistsIfNotMakeIt(SystemSidePath
+ '/bin') = true then
376 SystemSidePath
:= (SystemSidePath
+ '/bin');
377 FpUnlink(SystemSidePath
+ '/wine');
378 if FpSymLink(PChar(a
), PChar(SystemSidePath
+ '/wine') ) <> 0 then
380 log(1,'','Can not create symlink: ' + StrError(fpgeterrno
));
382 {link wineprefixcreate.}
383 a
:= SearchForBin('wineprefixcreate');
384 if SearchForBin(a
) <> '' then
386 FpUnlink(SystemSidePath
+ '/wineprefixcreate');
387 if FpSymLink(PChar(a
), PChar(SystemSidePath
+ '/wineprefixcreate') ) <> 0 then
389 log(1,'','Can not create symlink: ' + StrError(fpgeterrno
));
396 FolderScan(ComboBox_WineVersion
, PathToWine
);
397 OnWineVersionChange();
400 procedure TForm1
.EditBox_ProgramPathChange(Sender
: TObject
);
402 ColourCheck(EditBox_ProgramPath
);
405 procedure TForm1
.FormClose(Sender
: TObject
; var CloseAction
: TCloseAction
);
407 SaveLastUsedConfig();
411 procedure TForm1
.Btn_DebugChannelsConfigClick(Sender
: TObject
);
413 UnitDebugConfig
.Form2
.Show
;