Lots more shop stuff, working on the asset pages.

This commit is contained in:
Graphictoria 2022-07-18 00:22:20 -04:00
parent a4218d3302
commit 4d888e938e
7 changed files with 174 additions and 126 deletions

View File

@ -1,121 +0,0 @@
<?php
/*
Graphictoria 2022
Asset Helper
*/
namespace App\Helpers;
class AssetHelper
{
public static $assetTypes = [
[0] = 'Product',
[1] = 'Image',
[2] = 'T-Shirt',
[3] = 'Audio',
[4] = 'Mesh',
[5] = 'Lua',
[6] = 'HTML',
[7] = 'Text',
[8] = 'Hat',
[9] = 'Place',
[10] = 'Model',
[11] = 'Shirt',
[12] = 'Pants',
[13] = 'Decal',
[14] = null, // Doesn't exist on Roblox.
[15] = null, // Doesn't exist on Roblox.
[16] = 'Avatar',
[17] = 'Head',
[18] = 'Face',
[19] = 'Gear',
[20] = null, // Doesn't exist on Roblox.
[21] = 'Badge',
[22] = 'Group Emblem',
[23] = null, // Doesn't exist on Roblox.
[24] = 'Animation',
[25] = 'Arms',
[26] = 'Legs',
[27] = 'Torso',
[28] = 'Right Arm',
[29] = 'Left Arm',
[30] = 'Left Leg',
[31] = 'Right Leg',
[32] = 'Package',
[33] = 'YouTubeVideo',
[34] = 'Game Pass',
[35] = 'App',
[36] = null, // Doesn't exist on Roblox.
[37] = 'Code',
[38] = 'Plugin',
[39] = 'SolidModel',
[40] = 'MeshPart',
[41] = 'Hair Accessory',
[42] = 'Face Accessory',
[43] = 'Neck Accessory',
[44] = 'Shoulder Accessory',
[45] = 'Front Accessory',
[46] = 'Back Accessory',
[47] = 'Waist Accessory',
[48] = 'Climb Animation',
[49] = 'Death Animation',
[50] = 'Fall Animation',
[51] = 'Idle Animation',
[52] = 'Jump Animation',
[53] = 'Run Animation',
[54] = 'Swim Animation',
[55] = 'Walk Animation',
[56] = 'Pose Animation',
[57] = 'Ear Accessory',
[58] = 'Eye Accessory',
[59] = 'LocalizationTableManifest',
[60] = 'LocalizationTableTranslation',
[61] = 'Emote Animation',
[62] = 'Video',
[63] = 'TexturePack',
[64] = 'T-Shirt Accessory',
[65] = 'Shirt Accessory',
[66] = 'Pants Accessory',
[67] = 'Jacket Accessory',
[68] = 'Sweater Accessory',
[69] = 'Shorts Accessory',
[70] = 'Left Shoe Accessory',
[71] = 'Right Shoe Accessory',
[72] = 'Dress Skirt Accessory',
[73] = 'Font Family',
[74] = 'Font Face',
[75] = 'MeshHiddenSurfaceRemoval'
];
public static $assetGenres = [
[0] = 'All',
[1] = 'Town And City',
[2] = 'Medieval',
[3] = 'Sci-Fi',
[4] = 'Fighting',
[5] = 'Horror',
[6] = 'Naval',
[7] = 'Adventure',
[8] = 'Sports',
[9] = 'Comedy',
[10] = 'Western',
[11] = 'Military',
[12] = 'Skate Park',
[13] = 'Building',
[14] = 'FPS',
[15] = 'RPG'
];
public static $gearAssetGenres = [
[0] = 'Melee Weapon',
[1] = 'Ranged Weapon',
[2] = 'Explosive',
[3] = 'Power Up',
[4] = 'Navigation Enhancer',
[5] = 'Musical Instrument',
[6] = 'Social Item',
[7] = 'Building Tool',
[8] = 'Personal Transport'
];
}

View File

@ -8,6 +8,7 @@ use App\Models\Asset;
use App\Models\Shout;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
class ShopController extends Controller
{
@ -75,13 +76,15 @@ class ShopController extends Controller
foreach($assets as $asset) {
$creator = $asset->user;
// TODO: XlXi: creator profile url
array_push($data, [
'Name' => $asset->name,
'Creator' => [
'Name' => $creator->username,
'Link' => url('/user/' . strval($creator->username) . '/profile')
'Url' => 'todo123'
],
'Thumbnail' => $asset->getThumbnail()
'Thumbnail' => $asset->getThumbnail(),
'Url' => route('shop.asset', ['asset' => $asset->id, 'assetName' => Str::slug($asset->name, '-')])
]);
}

View File

@ -2,8 +2,10 @@
namespace App\Http\Controllers\Web;
use App\Models\Asset;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class ShopController extends Controller
{
@ -11,4 +13,19 @@ class ShopController extends Controller
{
return view('web.shop.index');
}
public function showAsset(Request $request, Asset $asset, string $assetName = null)
{
if ($asset->moderated)
abort(404);
$assetSlug = Str::slug($asset->name, '-');
if ($assetName != $assetSlug)
return redirect()->route('shop.asset', ['asset' => $asset->id, 'assetName' => $assetSlug]);
return view('web.shop.asset')->with([
'title' => sprintf('%s by %s', $asset->name, $asset->user->username),
'asset' => $asset
]);
}
}

View File

@ -21,11 +21,126 @@ class Asset extends Model
'updated_at' => 'datetime',
];
protected $assetTypes = [
/* 0 */ 'Product',
/* 1 */ 'Image',
/* 2 */ 'T-Shirt',
/* 3 */ 'Audio',
/* 4 */ 'Mesh',
/* 5 */ 'Lua',
/* 6 */ 'HTML',
/* 7 */ 'Text',
/* 8 */ 'Hat',
/* 9 */ 'Place',
/* 10 */ 'Model',
/* 11 */ 'Shirt',
/* 12 */ 'Pants',
/* 13 */ 'Decal',
/* 14 */ null, // Doesn't exist on Roblox.
/* 15 */ null, // Doesn't exist on Roblox.
/* 16 */ 'Avatar',
/* 17 */ 'Head',
/* 18 */ 'Face',
/* 19 */ 'Gear',
/* 20 */ null, // Doesn't exist on Roblox.
/* 21 */ 'Badge',
/* 22 */ 'Group Emblem',
/* 23 */ null, // Doesn't exist on Roblox.
/* 24 */ 'Animation',
/* 25 */ 'Arms',
/* 26 */ 'Legs',
/* 27 */ 'Torso',
/* 28 */ 'Right Arm',
/* 29 */ 'Left Arm',
/* 30 */ 'Left Leg',
/* 31 */ 'Right Leg',
/* 32 */ 'Package',
/* 33 */ 'YouTubeVideo',
/* 34 */ 'Game Pass',
/* 35 */ 'App',
/* 36 */ null, // Doesn't exist on Roblox.
/* 37 */ 'Code',
/* 38 */ 'Plugin',
/* 39 */ 'SolidModel',
/* 40 */ 'MeshPart',
/* 41 */ 'Hair Accessory',
/* 42 */ 'Face Accessory',
/* 43 */ 'Neck Accessory',
/* 44 */ 'Shoulder Accessory',
/* 45 */ 'Front Accessory',
/* 46 */ 'Back Accessory',
/* 47 */ 'Waist Accessory',
/* 48 */ 'Climb Animation',
/* 49 */ 'Death Animation',
/* 50 */ 'Fall Animation',
/* 51 */ 'Idle Animation',
/* 52 */ 'Jump Animation',
/* 53 */ 'Run Animation',
/* 54 */ 'Swim Animation',
/* 55 */ 'Walk Animation',
/* 56 */ 'Pose Animation',
/* 57 */ 'Ear Accessory',
/* 58 */ 'Eye Accessory',
/* 59 */ 'LocalizationTableManifest',
/* 60 */ 'LocalizationTableTranslation',
/* 61 */ 'Emote Animation',
/* 62 */ 'Video',
/* 63 */ 'TexturePack',
/* 64 */ 'T-Shirt Accessory',
/* 65 */ 'Shirt Accessory',
/* 66 */ 'Pants Accessory',
/* 67 */ 'Jacket Accessory',
/* 68 */ 'Sweater Accessory',
/* 69 */ 'Shorts Accessory',
/* 70 */ 'Left Shoe Accessory',
/* 71 */ 'Right Shoe Accessory',
/* 72 */ 'Dress Skirt Accessory',
/* 73 */ 'Font Family',
/* 74 */ 'Font Face',
/* 75 */ 'MeshHiddenSurfaceRemoval'
];
protected $assetGenres = [
/* 0 */ 'All',
/* 1 */ 'Town And City',
/* 2 */ 'Medieval',
/* 3 */ 'Sci-Fi',
/* 4 */ 'Fighting',
/* 5 */ 'Horror',
/* 6 */ 'Naval',
/* 7 */ 'Adventure',
/* 8 */ 'Sports',
/* 9 */ 'Comedy',
/* 10 */ 'Western',
/* 11 */ 'Military',
/* 12 */ 'Skate Park',
/* 13 */ 'Building',
/* 14 */ 'FPS',
/* 15 */ 'RPG'
];
protected $gearAssetGenres = [
/* 0 */ 'Melee Weapon',
/* 1 */ 'Ranged Weapon',
/* 2 */ 'Explosive',
/* 3 */ 'Power Up',
/* 4 */ 'Navigation Enhancer',
/* 5 */ 'Musical Instrument',
/* 6 */ 'Social Item',
/* 7 */ 'Building Tool',
/* 8 */ 'Personal Transport'
];
public function user()
{
return $this->belongsTo(User::class, 'creatorId');
}
public function typeString()
{
return $this->assetTypes[$this->assetTypeId];
}
public function latestVersion()
{
return $this->belongsTo(AssetVersion::class, 'assetVersionId');

View File

@ -307,13 +307,14 @@ class Shop extends Component {
:
<div>
{
this.state.pageItems.map(({Name, Creator, Thumbnail}, index) =>
<a className="graphictoria-item-card" href="#" key={ index }>
this.state.pageItems.map(({Name, Creator, Thumbnail, Url}, index) =>
<a className="graphictoria-item-card" href={ Url } key={ index }>
<span className="card m-2">
<img className="img-fluid" src={ Thumbnail } />
<div className="p-2">
<p>{ Name }</p>
<p className="text-muted">Free</p>
{ /* TODO: XlXi: price */ }
<p className="text-muted">Todo123</p>
</div>
</span>
</a>

View File

@ -0,0 +1,30 @@
@extends('layouts.app')
@section('title', $title)
@section('page-specific')
@endsection
@section('content')
<div class="container graphictoria-center-vh">
@if(!$asset->approved)
<div class="alert alert-danger text-center"><strong>This asset is pending approval.</strong> It will not appear in-game and cannot be voted on or purchased at this time.</div>
@endif
<div class="card shadow-sm">
<div class="card-body">
<div class="row">
<div class="col-6">
</div>
<div class="col-6">
<h4 class="mb-0">{{ $asset->name }}</h4>
{{-- TODO: XlXi: url to user's profile --}}
<p>By: {{ $asset->user->username }}<p>
<br />
<p>Type: {{ $asset->typeString() }}</p>
<p>Description:</p>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -1,5 +1,7 @@
<?php
use App\Models\Asset;
Route::group(['as' => 'home.'], function() {
Route::get('/', 'HomeController@landing')->name('landing')->middleware('guest');
Route::get('/my/dashboard', 'HomeController@dashboard')->name('dashboard')->middleware('auth');
@ -7,6 +9,7 @@ Route::group(['as' => 'home.'], function() {
Route::group(['as' => 'shop.', 'prefix' => 'shop'], function() {
Route::get('/', 'ShopController@index')->name('index');
Route::get('/{asset}/{assetName:slug?}', 'ShopController@showAsset')->name('asset');
});
Route::group(['as' => 'auth.', 'namespace' => 'Auth'], function() {