Skip to content

Commit

Permalink
Merge pull request #131 from originalaidn/skins-2
Browse files Browse the repository at this point in the history
fixing M4A4 name & adding "default" agent images
  • Loading branch information
hobsRKM authored Dec 3, 2024
2 parents 7c0e649 + f9c92b3 commit 87a9058
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/K4Ranks/RanksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function viewProfile(Request $request, $steam_id, $server_id) {
'g3sg1' => 'G3SG1',
'galilar' => 'Galil AR',
'm249' => 'M249',
'm4a1' => 'M4A1',
'm4a1' => 'M4A4',
'mac10' => 'MAC-10',
'p90' => 'P90',
'mp5sd' => 'MP5-SD',
Expand Down
17 changes: 9 additions & 8 deletions app/Http/Controllers/WeaponSkinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function load($type)
// Modified query to include weapon_nametag
$appliedSkins = DB::connection('mysqlskins')
->table('wp_player_skins')
->select('weapon_defindex', 'weapon_paint_id', 'weapon_wear', 'weapon_seed', 'weapon_nametag', 'weapon_stattrak', 'weapon_keychain', 'weapon_sticker_0', 'weapon_sticker_1', 'weapon_sticker_2', 'weapon_sticker_3', 'weapon_sticker_4', 'weapon_team')
->select('weapon_defindex', 'weapon_paint_id', 'weapon_wear', 'weapon_seed', 'weapon_nametag', 'weapon_stattrak', 'weapon_stattrak_count', 'weapon_keychain', 'weapon_sticker_0', 'weapon_sticker_1', 'weapon_sticker_2', 'weapon_sticker_3', 'weapon_sticker_4', 'weapon_team')
->where('steamid', Auth::user()?->steam_id)
->get();
$appliedKnife = DB::connection('mysqlskins')
Expand Down Expand Up @@ -135,6 +135,7 @@ public function load($type)
$skin['seed'] = $appliedSkin ? $appliedSkin->weapon_seed : '';
$skin['weapon_nametag'] = $appliedSkin ? $appliedSkin->weapon_nametag : '';
$skin['weapon_stattrak'] = $appliedSkin ? $appliedSkin->weapon_stattrak : '';
$skin['weapon_stattrak_count'] = $appliedSkin ? $appliedSkin->weapon_stattrak_count : '';
$skin['weapon_team'] = $appliedSkin ? $appliedSkin->weapon_team : '';
$skin['weapon_keychain'] = $appliedSkin ? $appliedSkin->weapon_keychain : '';
$skin['weapon_sticker_0'] = $appliedSkin ? $appliedSkin->weapon_sticker_0 : '';
Expand Down Expand Up @@ -263,17 +264,15 @@ public function agents()

foreach ($agents as &$agent) {
if ($appliedAgents) {
$agent['is_applied_t'] = $agent['team'] == 2 && $agent['model'] == $appliedAgents->agent_t;
$agent['is_applied_ct'] = $agent['team'] == 3 && $agent['model'] == $appliedAgents->agent_ct;
$agent['is_applied'] = ($agent['team'] == 2 && $agent['model'] == $appliedAgents->agent_t) || ($agent['team'] == 3 && $agent['model'] == $appliedAgents->agent_ct);
} else {
$agent['is_applied_t'] = false;
$agent['is_applied_ct'] = false;
$agent['is_applied'] = false;
}
}

// Sort applied agents to be first (T or CT applied)
usort($agents, function ($a, $b) {
return ($b['is_applied_t'] || $b['is_applied_ct']) - ($a['is_applied_t'] || $a['is_applied_ct']);
// Sort applied agents to be first
usort($agents, function($a, $b) {
return $b['is_applied'] - $a['is_applied'];
});

return view('weapons.agents', ['agents' => $agents]);
Expand Down Expand Up @@ -662,12 +661,14 @@ public function loadKnives($category)
$skin['seed'] = $appliedSkin->weapon_seed ?? '';
$skin['weapon_nametag'] = $appliedSkin->weapon_nametag ?? '';
$skin['weapon_stattrak'] = $appliedSkin->weapon_stattrak ?? '';
$skin['weapon_stattrak_count'] = $appliedSkin->weapon_stattrak_count ?? '';
$skin['weapon_team'] = $appliedSkin->weapon_team ?? '';
} else {
$skin['wear'] = '';
$skin['seed'] = '';
$skin['weapon_nametag'] = '';
$skin['weapon_stattrak'] = '';
$skin['weapon_stattrak_count'] = '';
$skin['weapon_team'] = '';
}
}
Expand Down
4 changes: 2 additions & 2 deletions resources/json/agents.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[
{
"team": 2,
"image": "",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/agent-5205.png",
"model": "null",
"agent_name": "Agent | Default"
},
{
"team": 3,
"image": "",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/agent-4619.png",
"model": "null",
"agent_name": "Agent | Default"
},
Expand Down
5 changes: 5 additions & 0 deletions resources/json/music.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,10 @@
"id": "85",
"name": "Music Kit | Tree Adams, Seventh Moon",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/music_kit-85.png"
},
{
"id": "86",
"name": "Music Kit | Perfect World, Ay Hey",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/music_kit-86.png"
}
]
17 changes: 9 additions & 8 deletions resources/views/weapons/agents.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
<span class="badge badge-warning">T</span>
@endif

<span id="agent_{{$agent['model']}}" class="badge badge-{{ $agent['team'] == 3 ? 'primary' : 'danger' }}">{{ (isset($agent['is_applied_t']) && isset($agent['is_applied_ct']) && $agent['is_applied_t'] && $agent['is_applied_ct'])
? __('skins.active_both')
: (isset($agent['is_applied_t']) && $agent['is_applied_t']
? __('skins.active_t')
: (isset($agent['is_applied_ct']) && $agent['is_applied_ct']
? __('skins.active_ct')
: ''))
}}</span>
@if($agent['is_applied'])
<span id="agent_{{$agent['model']}}" class="badge badge-{{ $agent['team'] == 3 ? 'primary' : 'danger' }}">
@if($agent['team'] == 2)
{{ __('skins.active_t') }}
@elseif($agent['team'] == 3)
{{ __('skins.active_ct') }}
@endif
</span>
@endif
<div class="loader-skins"></div> <!-- Add loader -->
<img src="{{ $agent['image'] }}" class="card-img-top" alt="{{ $agent['agent_name'] }}" crossorigin="anonymous">
</a>
Expand Down
1 change: 1 addition & 0 deletions resources/views/weapons/knives.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
</select>
</div>
</div>
<input type="hidden" class="form-control" id="weapon_stattrak_count" name="weapon_stattrak_count">
</div>
<div class="form-group mt-3">
<label for="wear">{{ __('gloves.wear') }}</label>
Expand Down
5 changes: 3 additions & 2 deletions resources/views/weapons/partials/knife-types.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a class="card style-6" href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#skinPreviewModal" data-skin-image="{{ $skin['image'] }}" data-skin-name="{{ $skin['paint_name'] }}">
<span id="skin_{{$skin['paint']}}_{{$skin['weapon_defindex']}}" class="skin_active badge
{{ $skin['is_applied_t'] && $skin['is_applied_ct'] ? 'badge-success' : ($skin['is_applied_t'] ? 'badge-danger' : ($skin['is_applied_ct'] ? 'badge-primary' : '')) }}">
{{ $skin['is_applied_t'] && $skin['is_applied_ct'] ? __('is_applied_both') : ($skin['is_applied_t'] ? __('skins.active_t') : ($skin['is_applied_ct'] ? __('skins.active_ct') : '')) }}
{{ $skin['is_applied_t'] && $skin['is_applied_ct'] ? __('skins.active_both') : ($skin['is_applied_t'] ? __('skins.active_t') : ($skin['is_applied_ct'] ? __('skins.active_ct') : '')) }}
</span>
<div class="loader-skins"></div> <!-- Add loader -->
<img src="{{ $skin['image'] }}" class="card-img-top lazy" alt="{{ $skin['paint_name'] }}" crossorigin="anonymous">
Expand All @@ -29,7 +29,8 @@
data-weapon-team="{{ $skin['weapon_team'] }}"
data-weapon-name="{{ $skin['weapon_name'] }}"
data-weapon-nametag="{{ $skin['weapon_nametag'] }}"
data-weapon-stattrak="{{ $skin['weapon_stattrak'] }}">
data-weapon-stattrak="{{ $skin['weapon_stattrak'] }}"
data-weapon-stattrak-count="{{ $skin['weapon_stattrak_count'] }}">
<i class="fas fa-cog"></i> {{ __('skins.applySkin') }}
</button>
</div>
Expand Down
1 change: 1 addition & 0 deletions resources/views/weapons/partials/weapon-types.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
data-weapon-name="{{ $skin['weapon_name'] }}"
data-weapon-nametag="{{ $skin['weapon_nametag'] }}"
data-weapon-stattrak="{{ $skin['weapon_stattrak'] }}"
data-weapon-stattrak-count="{{ $skin['weapon_stattrak_count'] }}"
data-weapon-keychain="{{ $skin['weapon_keychain'] }}"
data-weapon-sticker-0="{{ $skin['weapon_sticker_0'] }}"
data-weapon-sticker-1="{{ $skin['weapon_sticker_1'] }}"
Expand Down
4 changes: 4 additions & 0 deletions resources/views/weapons/skins.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
</select>
</div>
</div>
<input type="hidden" class="form-control" id="weapon_stattrak_count" name="weapon_stattrak_count">
<div class="col-md-6">
<div class="form-group mt-3">
<label for="wear">{{ __('gloves.wear') }}</label>
Expand Down Expand Up @@ -307,6 +308,7 @@ function populateKeychainsDropdowns(keychains) {
const weaponSeed = $(this).data('seed');
const weaponNametag = $(this).data('weapon-nametag');
const weaponStattrak = $(this).data('weapon-stattrak');
const weaponStattrakCount = $(this).data('weapon-stattrak-count');
const weaponKeychain = $(this).data('weapon-keychain');
const weaponSticker0 = $(this).data('weapon-sticker-0');
const weaponSticker1 = $(this).data('weapon-sticker-1');
Expand Down Expand Up @@ -336,8 +338,10 @@ function populateKeychainsDropdowns(keychains) {
}
if (weaponStattrak) {
$('#weapon_stattrak').val(weaponStattrak);
$('#weapon_stattrak_count').val(weaponStattrakCount);
} else {
$('#weapon_stattrak').val(0);
$('#weapon_stattrak_count').val(0);
}
if (weaponKeychain) {
const keychainID = weaponKeychain.split(';')[0];
Expand Down

0 comments on commit 87a9058

Please sign in to comment.