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, version 3 of the License.
7 WineLauncher is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with WineLauncher. If not, see <http://www.gnu.org/licenses/>.
16 {Made with Lazarus 0.9.26.3 fixes branch.}
17 {Free Pascal Compiler version 2.2.3.}
26 Classes
, SysUtils
, LResources
, Forms
, Controls
, Graphics
, Dialogs
, StdCtrls
,
27 DbCtrls
, strutils
, BaseUnix
, Process
, CheckLst
, Math
, ExtCtrls
;
35 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_ProgramsList
: TComboBox
;
46 ComboBox_Architecture
: TComboBox
;
47 ComboBox_DistributionVersion
: TComboBox
;
48 ComboBox_DistributionName
: TComboBox
;
49 ComboBox_PreFix
: TComboBox
;
50 ComboBox_SoundWrapper
: TComboBox
;
51 ComboBox_TerminalName
: TComboBox
;
52 ComboBox_WineVersion
: TComboBox
;
53 EditBox_ProgramPath
: TEdit
;
54 Label_WineVersion
: TLabel
;
56 Label_ProgramPath
: TLabel
;
57 Label_ProgramsList
: TLabel
;
58 Label_WinePreFix
: TLabel
;
59 Label_DistributionName
: TLabel
;
60 Label_DistributionVersion
: TLabel
;
61 Label_Architecture
: TLabel
;
62 Memo_LogOutPut
: TMemo
;
63 TogBtn_Listdrive
: TToggleBox
;
65 procedure Btn_AboutClick(Sender
: TObject
);
66 procedure Btn_DebugChannelsConfigClick(Sender
: TObject
);
67 procedure Btn_RunClick(Sender
: TObject
);
68 procedure Btn_SettingsClick(Sender
: TObject
);
69 procedure Btn_StopScanClick(Sender
: TObject
);
70 procedure Button_RegeditClick(Sender
: TObject
);
71 procedure Button_WinecfgClick(Sender
: TObject
);
72 procedure ComboBox_ArchitectureEditingDone(Sender
: TObject
);
73 procedure ComboBox_ArchitectureEnter(Sender
: TObject
);
74 procedure ComboBox_DistributionNameEditingDone(Sender
: TObject
);
75 procedure ComboBox_DistributionNameEnter(Sender
: TObject
);
76 procedure ComboBox_DistributionVersionEditingDone(Sender
: TObject
);
77 procedure ComboBox_DistributionVersionEnter(Sender
: TObject
);
78 procedure ComboBox_PreFixChange(Sender
: TObject
);
79 procedure ComboBox_ProgramsListChange(Sender
: TObject
);
80 procedure ComboBox_WineVersionEditingDone(Sender
: TObject
);
81 procedure ComboBox_WineVersionEnter(Sender
: TObject
);
82 procedure EditBox_ProgramPathChange(Sender
: TObject
);
83 procedure FormClose(Sender
: TObject
; var CloseAction
: TCloseAction
);
84 procedure FormCreate(Sender
: TObject
);
85 procedure FormResize(Sender
: TObject
);
86 procedure TogBtn_ListdriveChange(Sender
: TObject
);
87 procedure TimerOnTimer(Sender
: TObject
);
89 private { private declarations }
91 public { public declarations }
97 start_S1
:string; { Script to write to the file. }
98 wine_version_full
:string; { New code uses this to. }
99 RunIn
:string; { terminal or shell set here }
100 NoError
:Boolean; { Tbh this should not be here but im not sure need to check. }
101 Sh_Path
:string; { Path for the shell }
102 GetCurrentDir
:string;
103 Channel
:string; { Debug channel name }
104 UnixDirPath
:string; { Needed for setting the working dir at 'Run'. }
106 Timer
:TTimer
; {The timer is a workaround.}
118 procedure TForm1
.FormCreate(Sender
: TObject
);
120 {The timer is a workaround.}
121 Timer
:= TTimer
.Create(nil) ;
122 Timer
.OnTimer
:= @TimerOnTimer
;
123 Timer
.Enabled
:= false;
124 Timer
.Interval
:= 100;
127 if ComboBox_SoundWrapper
.items
.Count
<> 0 then ComboBox_SoundWrapper
.Text := ComboBox_SoundWrapper
.Items
[0];
128 if ComboBox_TerminalName
.items
.Count
<> 0 then ComboBox_TerminalName
.Text := ComboBox_TerminalName
.Items
[0];
131 ComboBox_DistributionNameEnter(Self
);
133 {Load LastUsedConfig.}
134 LoadLastUsedConfig();
137 Btn_StopScan
.Visible
:= true;
141 procedure TForm1
.FormResize(Sender
: TObject
);
143 if Btn_StopScan
.Visible
= true then Btn_StopScan
.Left
:= (floor(form1
.Width
/ 2) - floor(Btn_StopScan
.Width
/ 2));
146 procedure TForm1
.TimerOnTimer(Sender
: TObject
);
150 {We should not use a timer to check this. The is a bug in lazarus, 'OnTerminate' of AsyncProcess never runs.}
151 if AsyncProcessScan
.Active
= true then
153 Timer
.Enabled
:= true;
154 Btn_StopScan
.Visible
:= true;
159 Btn_StopScan
.Visible
:= false;
160 TempList
:= TStringlist
.Create
;
161 Timer
.Enabled
:= false;
162 TempList
.LoadFromStream(AsyncProcessScan
.OutPut
);
164 if TempList
.Count
= 0 then
166 DiscErrorText
:= 'Drive' + wrap('D' + ':') + 'has no executable files.';
167 LastReadLinkPath
:= '';
174 while TempList
.Count
<> 0 do
176 CdData
.Add(UnixToWinPath(TempList
.Strings
[0],'d'));
180 ComboBox_PreFixChange(self
);
183 CheckListBox_Flags
.Clear
;
187 procedure TForm1
.TogBtn_ListdriveChange(Sender
: TObject
);
192 AsyncProcessScan
.Active
:= false;
193 Btn_StopScan
.Visible
:= false;
194 CheckListBox_Flags
.Enabled
:= true;
195 EditBox_ProgramPath
.Clear
;
196 ComboBox_PreFixChange(self
);
197 ComboBox_ProgramsListChange(self
);
202 if CdData
= nil then CdData
:= TStringlist
.Create
;
203 if CdDataName
= nil then CdDataName
:= TStringlist
.Create
;
205 log(0,'', LastReadLinkPath
);
206 ComboBox_PreFixChange(self
);
207 CheckListBox_Flags
.Clear
;
208 EditBox_ProgramPath
.Clear
;
215 procedure TForm1
.Btn_RunClick(Sender
: TObject
);
217 RunWineCheck( '', '' );
220 procedure TForm1
.Btn_SettingsClick(Sender
: TObject
);
222 UnitSettings
.Form4
.Show
;
225 procedure TForm1
.Btn_StopScanClick(Sender
: TObject
);
227 AsyncProcessScan
.Active
:= false;
230 procedure TForm1
.Button_RegeditClick(Sender
: TObject
);
232 RunWineCheck( 'Regedit', '' );
235 procedure TForm1
.Button_WinecfgClick(Sender
: TObject
);
237 RunWineCheck( 'winecfg', '' );
240 procedure TForm1
.ComboBox_ArchitectureEditingDone(Sender
: TObject
);
242 WineVersionEditingDone();
243 OnWineVersionChange();
246 procedure TForm1
.ComboBox_ArchitectureEnter(Sender
: TObject
);
249 ItemTextVersion
:string;
251 //Log(0, '', 'Running Architecture');
252 if ComboBox_DistributionName
.ItemIndex
<> -1 then
254 ItemTextName
:= ComboBox_DistributionName
.Items
.Strings
[ComboBox_DistributionName
.ItemIndex
];
255 if ComboBox_DistributionVersion
.ItemIndex
<> -1 then
257 ItemTextVersion
:= ComboBox_DistributionVersion
.Items
.Strings
[ComboBox_DistributionVersion
.ItemIndex
];
258 FolderScan(ComboBox_Architecture
, (PathToWine
+ ItemTextName
+ '/' + ItemTextVersion
+ '/'));
259 ComboBox_WineVersionEnter(self
);
262 OnWineVersionChange();
265 procedure TForm1
.ComboBox_DistributionNameEditingDone(Sender
: TObject
);
267 WineVersionEditingDone();
268 OnWineVersionChange();
272 procedure TForm1
.ComboBox_DistributionNameEnter(Sender
: TObject
);
274 //Log(0, '', 'Running DistributionName');
275 if DoesFolderExists(PathToWine
) = true then
277 FolderScan(ComboBox_DistributionName
, PathToWine
);
279 ComboBox_DistributionVersionEnter(self
);
282 procedure TForm1
.ComboBox_DistributionVersionEditingDone(Sender
: TObject
);
284 WineVersionEditingDone();
285 OnWineVersionChange();
288 procedure TForm1
.ComboBox_DistributionVersionEnter(Sender
: TObject
);
293 //Log(0, '', 'Running DistributionVersion');
294 if ComboBox_DistributionName
.ItemIndex
<> -1 then
296 ItemText
:= ComboBox_DistributionName
.Items
.Strings
[ComboBox_DistributionName
.ItemIndex
];
297 FolderScan(ComboBox_DistributionVersion
, (PathToWine
+ ComboBox_DistributionName
.Text + '/'));
299 ComboBox_ArchitectureEnter(self
);
302 procedure TForm1
.ComboBox_PreFixChange(Sender
: TObject
);
310 ComboBox_ProgramsList
.Items
.Clear
;
314 EditBox_ProgramPath
.Enabled
:= true;
315 ComboBox_ProgramsList
.Enabled
:= true;
321 if Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
] <> '' then
323 ComboBox_ProgramsList
.Items
.Add(Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
]);
332 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
334 ComboBox_ProgramsList
.ItemIndex
:= 0;
335 EditBox_ProgramPath
.Enabled
:= true;
336 ComboBox_ProgramsList
.Enabled
:= true;
337 ComboBox_ProgramsListChange(Self
);
341 ComboBox_ProgramsList
.Text := '';
342 EditBox_ProgramPath
.Text := '';
343 EditBox_ProgramPath
.Enabled
:= false;
344 ComboBox_ProgramsList
.Enabled
:= false;
350 ListProgramsOnDisc(CdData
, 'D');
351 if CdData
.Text <> '' then
354 CdDataName
.AddStrings(CdData
);
356 for myloop
:= 0 to CdDataName
.Count
-1 do
358 {Take path and return the file name only.}
359 CdDataName
.Strings
[myloop
] := GetWinFileName(CdDataName
.Strings
[myloop
]);
361 ComboBox_ProgramsList
.Items
:= CdDataName
;
362 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
364 ComboBox_ProgramsList
.Text := ComboBox_ProgramsList
.Items
[0];
365 EditBox_ProgramPath
.Enabled
:= true;
366 ComboBox_ProgramsList
.Enabled
:= true;
367 ComboBox_ProgramsListChange(self
);
373 ComboBox_ProgramsList
.Items
.Add(DiscErrorText
);
374 ComboBox_ProgramsList
.ItemIndex
:= 0;
375 EditBox_ProgramPath
.Text := '';
376 EditBox_ProgramPath
.Enabled
:= false;
377 ComboBox_ProgramsList
.Enabled
:= false;
378 CheckListBox_Flags
.Clear
;
384 procedure TForm1
.ComboBox_ProgramsListChange(Sender
: TObject
);
386 ProgramsListSelectedItem
:integer;
391 PrefixInt
:= FindPrefixInt(ComboBox_PreFix
.Items
.Strings
[ComboBox_PreFix
.ItemIndex
]);
392 EditBox_ProgramPath
.Enabled
:= true;
393 {Plus one to line it up with the grid}
394 ProgramsListSelectedItem
:= (Data
[PrefixInt
].Grid
.cols
[DataNameCol
].IndexOf(Data
[PrefixInt
].Grid
.cols
[DataNameCol
].Strings
[ComboBox_ProgramsList
.ItemIndex
]) +1);
396 EditBox_ProgramPath
.Text := Data
[PrefixInt
].Grid
.Cells
[DataPathCol
, ProgramsListSelectedItem
] ;
397 CutUpFlags(Data
[PrefixInt
].Grid
.Cells
[DataFlagsCol
, ProgramsListSelectedItem
]);
401 if CdData
.Text <> '' then
403 EditBox_ProgramPath
.Text := CdData
.Strings
[CdDataName
.IndexOf(ComboBox_ProgramsList
.Text)] ;
408 procedure TForm1
.ComboBox_WineVersionEditingDone(Sender
: TObject
);
410 WineVersionEditingDone();
411 OnWineVersionChange();
414 procedure TForm1
.ComboBox_WineVersionEnter(Sender
: TObject
);
417 ItemTextVersion
:string;
418 ItemTextArchitecture
:string;
420 //Log(0, '', 'Running WineVersion');
421 if ComboBox_DistributionName
.ItemIndex
<> -1 then
423 ItemTextName
:= ComboBox_DistributionName
.Items
.Strings
[ComboBox_DistributionName
.ItemIndex
];
424 if ComboBox_DistributionVersion
.ItemIndex
<> -1 then
426 ItemTextVersion
:= ComboBox_DistributionVersion
.Items
.Strings
[ComboBox_DistributionVersion
.ItemIndex
];
427 if ComboBox_Architecture
.ItemIndex
<> -1 then
429 ItemTextArchitecture
:= ComboBox_Architecture
.Items
.Strings
[ComboBox_Architecture
.ItemIndex
];
430 FolderScan(ComboBox_WineVersion
, (PathToWine
+ ItemTextName
+ '/' + ItemTextVersion
+ '/' + ItemTextArchitecture
+ '/'));
435 OnWineVersionChange();
438 procedure TForm1
.EditBox_ProgramPathChange(Sender
: TObject
);
440 ColourCheck(EditBox_ProgramPath
);
443 procedure TForm1
.FormClose(Sender
: TObject
; var CloseAction
: TCloseAction
);
445 SaveLastUsedConfig();
449 procedure TForm1
.Btn_AboutClick(Sender
: TObject
);
451 UnitAbout
.Form3
.Show
;
454 procedure TForm1
.Btn_DebugChannelsConfigClick(Sender
: TObject
);
456 UnitDebugConfig
.Form2
.Show
;