2026-06-08 16:25:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2026-06-16 16:21:43 +02:00
|
|
|
use App\Models\Entry;
|
2026-06-09 11:45:59 +02:00
|
|
|
use App\Models\EntryFile;
|
|
|
|
|
use App\Services\FileServersService;
|
2026-06-08 16:25:52 +02:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class ToolsController extends Controller
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public function patcher()
|
|
|
|
|
{
|
2026-06-09 11:45:59 +02:00
|
|
|
return view('tools.patcher');
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-16 16:21:43 +02:00
|
|
|
public function directPatch( Request $request, int $entryId, EntryFile $file )
|
2026-06-09 11:45:59 +02:00
|
|
|
{
|
2026-06-16 18:35:01 +02:00
|
|
|
if( $file->entry_id != $entryId || $file->state === 'private' ) {
|
2026-06-09 11:45:59 +02:00
|
|
|
abort(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$service = app(FileServersService::class);
|
|
|
|
|
|
2026-06-16 16:21:43 +02:00
|
|
|
|
2026-06-08 16:25:52 +02:00
|
|
|
$patches = [
|
2026-06-09 11:45:59 +02:00
|
|
|
'file' => $service->getDownloadFileUrl( $file ),
|
|
|
|
|
'name' => $file->entry->title,
|
|
|
|
|
'outputName' => $file->filename
|
2026-06-08 16:25:52 +02:00
|
|
|
];
|
|
|
|
|
|
2026-06-16 16:21:43 +02:00
|
|
|
|
|
|
|
|
|
2026-06-08 16:25:52 +02:00
|
|
|
return view('tools.patcher', compact('patches'));
|
|
|
|
|
}
|
2026-06-16 16:21:43 +02:00
|
|
|
|
|
|
|
|
public function play( Request $request, int $entryId, EntryFile $file )
|
|
|
|
|
{
|
2026-06-16 18:35:01 +02:00
|
|
|
if( $file->entry_id != $entryId || $file->state === 'private' ) {
|
2026-06-16 16:21:43 +02:00
|
|
|
abort(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$service = app(FileServersService::class);
|
|
|
|
|
|
2026-06-16 18:35:01 +02:00
|
|
|
$emuConfig = [
|
|
|
|
|
'core' => $file->playOnlineSetting?->core,
|
|
|
|
|
'threads' => $file->playOnlineSetting?->threads,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if( $file->entry->type === 'homebrew' ){
|
|
|
|
|
$filePath = $service->getDownloadFileUrl( $file );
|
|
|
|
|
|
|
|
|
|
return view('tools.play-homebrew', compact('filePath', 'emuConfig'));
|
|
|
|
|
}
|
2026-06-16 16:21:43 +02:00
|
|
|
$patches = [
|
|
|
|
|
'file' => $service->getDownloadFileUrl( $file ),
|
|
|
|
|
'name' => $file->entry->title,
|
|
|
|
|
'outputName' => $file->filename
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return view('tools.play', compact('patches', 'emuConfig'));
|
|
|
|
|
}
|
2026-06-08 16:25:52 +02:00
|
|
|
}
|