Skip to content

Commit bd6c4b3

Browse files
committed
1.5
1 parent 2aa2a87 commit bd6c4b3

File tree

6 files changed

+95
-73
lines changed

6 files changed

+95
-73
lines changed

src/app/forms/MainForm.php

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ function doAddGameAction(UXEvent $e = null)
6868
UXDialog::show(Localization::getByCode('MAINFORM.NOFIX'),'ERROR',$this);
6969
return;
7070
}
71-
elseif (str::contains($parsed['overrides'],'steam') == false and str::contains($parsed['overrides'],'eos'))
71+
if (str::contains($parsed['overrides'],'steam') == false and str::contains($parsed['overrides'],'eos'))
7272
UXDialog::show(Localization::getByCode('MAINFORM.EOSFIX'),'WARNING');
73-
7473
if ($parsed['isFreeTP'])
74+
{
7575
$this->appModule()->games->set('fakeSteam',true,$appName);
76+
UXDialog::show(Localization::getByCode('MAINFORM.FREETP'),'WARNING');
77+
}
7678

7779
if ($parsed['realAppId'] != null)
7880
{
@@ -182,17 +184,24 @@ function addGame($gameName,$exec,$overrides,$image = null,$icon = null)
182184
$gamePanel->children[4]->data('stop',new UXImageView(new UXImage('res://.data/img/stop.png')));
183185
$menu = new UXContextMenu;
184186

187+
$debug = new UXMenuItem(Localization::getByCode('MAINFORM.MENU.RUNDEBUG'));
188+
$separator = UXMenuItem::createSeparator();
185189
$desktopIcon = new UXMenuItem(fs::isFile($this->appModule()->games->get('desktopIcon',$gameName)) ? Localization::getByCode('MAINFORM.MENU.REMOVEDESKTOP') : Localization::getByCode('MAINFORM.MENU.CREATEDESKTOP'));
186190
$appMenuIcon = new UXMenuItem(fs::isFile($this->appModule()->games->get('appMenuIcon',$gameName)) ? Localization::getByCode('MAINFORM.MENU.REMOVEAPPMENU') : Localization::getByCode('MAINFORM.MENU.CREATEAPPMENU'));
187-
$separator = UXMenuItem::createSeparator();
191+
$separatorAlt = UXMenuItem::createSeparator();
188192
$bannerEdit = new UXMenuItem(Localization::getByCode('MAINFORM.MENU.EDITBANNER'));
189193
$gameSettings = new UXMenuItem(Localization::getByCode('MAINFORM.MENU.GAMESETTINGS'));
190-
$separatorAlt = UXMenuItem::createSeparator();
194+
$separator3 = UXMenuItem::createSeparator();
191195
$libraryDelete = new UXMenuItem(Localization::getByCode('MAINFORM.MENU.REMOVEGAME'));
192196

193-
$menu->items->addAll([$desktopIcon,$appMenuIcon,$separator,$bannerEdit,$gameSettings,$separatorAlt,$libraryDelete]);
197+
$menu->items->addAll([$debug,$separator,$desktopIcon,$appMenuIcon,$separatorAlt,$bannerEdit,$gameSettings,$separator3,$libraryDelete]);
194198

195199
$desktopEntry = filesWorker::generateDesktopEntry($gameName,$icon);
200+
201+
$debug->on('action',function () use ($gamePanel,$gameName)
202+
{
203+
$this->runGame($gamePanel->children[4],$gameName,true);
204+
});
196205
$desktopIcon->on('action',function () use ($desktopEntry,$gameName,$desktopIcon)
197206
{
198207
$desktopPath = str::trim(execute('xdg-user-dir DESKTOP',true)->getInput()->readFully()).'/'.$gameName.'.desktop';
@@ -289,7 +298,6 @@ function addGame($gameName,$exec,$overrides,$image = null,$icon = null)
289298
{
290299
if ($e->sender->graphic == $e->sender->data('stop'))
291300
{
292-
$this->data('manualKill',true);
293301
$kill = new Process(['killall','-r',fs::nameNoExt($exec).'.*'])->startAndWait();
294302

295303
if ($kill->getExitValue() != 0)
@@ -302,23 +310,7 @@ function addGame($gameName,$exec,$overrides,$image = null,$icon = null)
302310
}
303311
else
304312
{
305-
$process = filesWorker::generateProcess($gameName);
306-
if ($process == null)
307-
return;
308-
309-
310-
$e->sender->graphic = $e->sender->data('stop');
311-
$e->sender->enabled = false;
312-
$this->appModule()->overlayEmulator->disabled = false;
313-
314-
waitAsync('5s',function () use ($e){$e->sender->enabled = true;});
315-
new Thread(function () use ($e,$process,$gameName,$overlayEmulator)
316-
{
317-
filesWorker::runWithDebug($process,$gameName);
318-
319-
$this->appModule()->overlayEmulator->disabled = true;
320-
uiLater(function () use ($e){$e->sender->graphic = $e->sender->data('play');});
321-
})->start();
313+
$this->runGame($e->sender,$gameName);
322314
}
323315
});
324316

@@ -329,5 +321,26 @@ function addGame($gameName,$exec,$overrides,$image = null,$icon = null)
329321
$this->noGamesHeader->visible = $this->noGamesSubHeader->visible = false;
330322
}
331323
}
324+
325+
function runGame($panel,$gameName,$debug = false)
326+
{
327+
$process = filesWorker::generateProcess($gameName,$debug);
328+
if ($process == null)
329+
return;
330+
331+
$panel->graphic = $panel->data('stop');
332+
$panel->enabled = false;
333+
$this->appModule()->overlayEmulator->disabled = false;
334+
335+
waitAsync('5s',function () use ($panel){$panel->enabled = true;});
336+
337+
new Thread(function () use ($panel,$process,$gameName,$debug)
338+
{
339+
filesWorker::run($process,$gameName,$debug);
340+
341+
$this->appModule()->overlayEmulator->disabled = true;
342+
uiLater(function () use ($panel){$panel->graphic = $panel->data('play');});
343+
})->start();
344+
}
332345

333346
}

src/app/forms/gameSettings.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ function doShow(UXWindowEvent $e = null)
3434
* @event gamemode.click
3535
*/
3636
function doGamemodeClick(UXMouseEvent $e = null)
37-
{
38-
UXDialog::show('Некоторые фиксы перестают работать из-за Gamemode - выключите его, если игра не работает','WARNING');
37+
{
38+
if ($e->sender->selected)
39+
UXDialog::show('Некоторые фиксы перестают работать из-за Gamemode - выключите его, если игра не работает','WARNING');
3940

4041
$this->appModule()->games->set('gamemode',$e->sender->selected,$this->gameName->text);
4142
}

src/app/forms/gameStarting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function doShow(UXWindowEvent $e = null)
1818

1919
new Thread(function () use ($process)
2020
{
21-
filesWorker::runWithDebug($process,$GLOBALS['argv'][1]);
21+
filesWorker::run($process,$GLOBALS['argv'][1]);
2222
})->start();
2323
}
2424

src/app/modules/filesWorker.php

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ static function generateDesktopEntry($name,$icon = null)
2121
"Categories=Game";
2222
}
2323

24-
static function generateProcess($name)
24+
static function generateProcess($name,$debug = false)
2525
{
2626
if (execute('pidof steam',true)->getExitValue() == 1)
2727
{
2828
UXDialog::showAndWait(Localization::getByCode('FILESWORKER.STEAMNOTSTARTED'),'ERROR',$this);
2929
return;
3030
}
3131

32-
if (fs::isFile('/usr/bin/protontricks-launch') == false)
32+
if (self::findProtontricksPath() == false)
3333
{
3434
UXDialog::showAndWait(Localization::getByCode('FILESWORKER.NOPROTONTRICKS'),'ERROR',$this);
3535
return;
@@ -38,32 +38,31 @@ static function generateProcess($name)
3838
$executable = app()->appModule()->games->get('executable',$name);
3939

4040
$dxOverrides = 'd3d11=n;d3d10=n;d3d10core=n;dxgi=n;openvr_api_dxvk=n;d3d12=n;d3d12core=n;d3d9=n;d3d8=n;'; #For some reason, some distributions use wined3d instead of dxvk, this is workaround
41-
$overridesArr = ['WINEDLLOVERRIDES'=>$dxOverrides.app()->appModule()->games->get('overrides',$name),'WINEDEBUG'=>'+warn,+err,+trace'];
42-
$execArr = [filesWorker::findProtontricksPath().'protontricks-launch','--appid','480',$executable];
41+
$overridesArr = ['WINEDLLOVERRIDES'=>$dxOverrides.app()->appModule()->games->get('overrides',$name),'WINEDEBUG'=>$debug ? '+warn,+err,+trace' : '-all'];
42+
$exec = '"'.filesWorker::findProtontricksPath().'protontricks-launch" --appid 480 "'.$executable.'"';
4343
$envArr = str::split(app()->appModule()->games->get('environment',$name),' ');
4444

4545
if (isset($envArr[0]))
4646
$overridesArr = array_merge($overridesArr,$envArr);
4747

4848
if (app()->appModule()->games->get('gamemode',$name) and fs::isFile('/usr/bin/gamemoderun'))
49-
array_unshift($execArr,'gamemoderun');
49+
$exec = 'gamemoderun '.$exec;
50+
if ($debug == false)
51+
$exec .= ' > /dev/null 2>&1';
5052
#if (app()->appModule()->games->get('mangohud',$name) and fs::isFile('/usr/bin/mangohud'))
5153
#array_unshift($execArr,'mangohud');
5254

53-
return new Process($execArr,fs::parent($executable),$overridesArr);
55+
return new Process(['bash','-c',$exec],fs::parent($executable),$overridesArr);
5456
}
5557

56-
static function runWithDebug($process,$gameName)
58+
static function run($process,$gameName,$debug = false)
5759
{
5860
UXApplication::setImplicitExit(false);
5961

6062
if (app()->appModule()->games->get('fakeSteam',$gameName))
6163
$fakeSteam = new Process([self::findProtontricksPath().'protontricks-launch','--appid','480',fs::abs('./steam.exe')])->start();
6264

63-
$process = $process->start();
64-
65-
while ($process->getExitValue() == null)
66-
sleep(3);
65+
$process = $process->startAndWait();
6766

6867
if (isset($fakeSteam))
6968
{
@@ -74,47 +73,50 @@ static function runWithDebug($process,$gameName)
7473
catch (IOException $ex){}
7574
}
7675

77-
if ($process->getExitValue() != 0 and uiLaterAndWait(function (){return app()->form('MainForm')->data('manualKill');}) == false)
78-
{
79-
uiLaterAndWait(function () use ($process,$gameName){
80-
/*if (app()->appModule()->games->get('fakeSteam',$gameName) == false and $process->getExitValue() == 1 and uiConfirm(Localization::getByCode('FILESWORKER.ISSTEAMNOTSTARTEDERROR')))
81-
{
82-
app()->appModule()->games->set('fakeSteam',true,$gameName);
83-
UXDialog::showAndWait(Localization::getByCode('FILESWORKER.FAKESTEAMENABLED'));
84-
}
85-
else
86-
{*/
87-
$info = 'Game name - '.$gameName."\n".
88-
'Exit code - '.$process->getExitValue()."\n".
89-
"Game settings: \n";
90-
91-
foreach (app()->appModule()->games->section($gameName) as $param => $value)
92-
$info .= "\t$param - $value\n";
93-
94-
app()->form('log')->textArea->text = $info."\nWine output:\n".$process->getError()->readFully();
95-
app()->form('log')->textArea->text .= "\n\n\nGame output:\n".$process->getInput()->readFully();
96-
app()->form('log')->data('gameName',$gameName);
97-
98-
app()->showFormAndWait('log');
99-
#}
100-
});
101-
}
76+
if ($debug)
77+
self::debug($process,$gamename);
78+
79+
UXApplication::setImplicitExit(true);
80+
}
81+
82+
static function debug($process,$gameName)
83+
{
84+
uiLaterAndWait(function () use ($process,$gameName){
85+
/*if (app()->appModule()->games->get('fakeSteam',$gameName) == false and $process->getExitValue() == 1 and uiConfirm(Localization::getByCode('FILESWORKER.ISSTEAMNOTSTARTEDERROR')))
86+
{
87+
app()->appModule()->games->set('fakeSteam',true,$gameName);
88+
UXDialog::showAndWait(Localization::getByCode('FILESWORKER.FAKESTEAMENABLED'));
89+
}
90+
else
91+
{*/
92+
$info = 'Game name - '.$gameName."\n".
93+
'Exit code - '.$process->getExitValue()."\n".
94+
"Game settings: \n";
95+
96+
foreach (app()->appModule()->games->section($gameName) as $param => $value)
97+
$info .= "\t$param - $value\n";
98+
99+
app()->form('log')->textArea->text = $info."\nWine output:\n".$process->getError()->readFully();
100+
app()->form('log')->textArea->text .= "\n\n\nGame output:\n".$process->getInput()->readFully();
101+
app()->form('log')->data('gameName',$gameName);
102+
103+
app()->showFormAndWait('log');
104+
#}
105+
});
102106

103107
uiLaterAndWait(function ()
104108
{
105109
if (app()->form('MainForm')->data('manualKill') == true)
106110
app()->form('MainForm')->data('manualKill',false);
107111
});
108-
109-
UXApplication::setImplicitExit(true);
110112
}
111113

112114
static function findProtontricksPath()
113115
{
114-
if (fs::isFile('/usr/bin/protontricks') and fs::isFile('/usr/bin/protontricks-launch'))
115-
return '/usr/bin/';
116-
elseif (fs::isFile(System::getProperty('user.home').'/.local/bin/protontricks') and fs::isFile(System::getProperty('user.home').'/.local/bin/protontricks-launch'))
116+
if (fs::isFile(System::getProperty('user.home').'/.local/bin/protontricks') and fs::isFile(System::getProperty('user.home').'/.local/bin/protontricks-launch'))
117117
return System::getProperty('user.home').'/.local/bin/';
118+
elseif (fs::isFile('/usr/bin/protontricks') and fs::isFile('/usr/bin/protontricks-launch'))
119+
return '/usr/bin/';
118120
else
119121
return false;
120122
}

src/locale/en.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"MAINFORM.NOFIX": "No DLLs related to OnlineFix found!",
1010
"MAINFORM.EOSFIX": "EOS Fix detected - support for them is not complete, they may not work correctly",
1111
"MAINFORM.ICONPARSERERROR": "Error retrieving icon - %s",
12+
"MAINFORM.MENU.RUNDEBUG": "Run with debug",
1213
"MAINFORM.MENU.REMOVEDESKTOP": "Remove shortcut from desktop",
1314
"MAINFORM.MENU.REMOVEAPPMENU": "Remove shortcut from application menu",
1415
"MAINFORM.MENU.CREATEDESKTOP": "Create shortcut on desktop",
@@ -17,6 +18,7 @@
1718
"MAINFORM.MENU.GAMESETTINGS": "Launch settings",
1819
"MAINFORM.MENU.REMOVEGAME": "Remove game from launcher",
1920
"MAINFORM.KILLFAILED": "Failed to terminate the game process - it may still be starting",
21+
"MAINFORM.FREETP": "A fix from FreeTP has been found! It may not work.",
2022

2123
"BANNEREDITOR.STEAM.HEADER": "Get a new banner from Steam:",
2224
"BANNEREDITOR.STEAM.APPID": "Game AppID in Steam",
@@ -30,6 +32,7 @@
3032
"INITCONFIG.HEADER.WORKING": "Protontricks is working",
3133
"INITCONFIG.TEXTAREA": "In the opened Steam window, install Spacewar on the disk where you want the wineprefix to be, and do not create shortcuts in the application menu or desktop (uncheck the boxes)\n\nWhen Spacewar is installed:\n1. Right-click on it in the library\n2. Open \"Properties\", then \"Compatibility\"\n3. Enable the use of the Steam Play compatibility tool\n4. Select the Proton version to be used for all games with OnlineFix (it is recommended to use Proton GE if you have installed it, or Proton Experimental and Hotfix)\n5. Wait for Spacewar to update and launch it\n\nThe program will then detect the Spacewar process, terminate it, and proceed to the next step.\nIf this does not happen, check all the steps.",
3234
"INITCONFIG.NOPROTONTRICKS": "Install protontricks (flatpak is not supported) before using the launcher",
35+
"INITCONFIG.NOSTEAM": "Install Steam (Flatpak and Snap is not supported) beforce using the launcher",
3336

3437
"GAMESETTINGS.ADDITIONALS": "Additional features",
3538
"GAMESETTINGS.ADDITIONALS.USEGAMEMODE": "Use gamemode",
@@ -39,14 +42,14 @@
3942
"GAMESETTINGS.ENVS.ENVIRONMENT": "Environment variables",
4043

4144
"FILESWORKER.STEAMNOTSTARTED": "Steam is not running",
42-
"FILESWORKER.NOPROTONTRICKS": "Protontricks-launch is required to start the game, but it was not found in /usr/bin",
45+
"FILESWORKER.NOPROTONTRICKS": "Protontricks-launch is required to start the game, but it was not found",
4346
"FILESWORKER.FAKESTEAMENABLED": "Error bypass enabled. Try launching the game again",
4447
"FILESWORKER.ISSTEAMNOTSTARTEDERROR": "Did you just see the \"Steam is not running\" error?",
4548

4649
"GAMESTARTER.STARTING": "Game is starting",
4750

48-
"LOGFORM.HEADER": "Oops.. It seems that this game didn't work as it should",
49-
"LOGFORM.SUBHEADER": "Here is its log, which you can send to the launcher developer for analysis and possible fixes.",
51+
"LOGFORM.HEADER": "Game's operation log",
52+
"LOGFORM.SUBHEADER": "If there are errors in it, you can figure it out yourself or send the log to the developer for help",
5053
"LOGFORM.DONOTSEND": "Do not send",
5154
"LOGFORM.SEND": "Send",
5255

0 commit comments

Comments
 (0)