Add default texture for alex model
This commit is contained in:
parent
0a0b25b5af
commit
d54709c23d
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
/* global initSkinViewer, defaultSkin */
|
||||
/* global initSkinViewer, defaultSteveSkin, defaultAlexSkin */
|
||||
|
||||
// TODO: Help wanted. This file needs to be tested.
|
||||
|
||||
@ -10,8 +10,16 @@ function initUploadListeners() {
|
||||
}
|
||||
|
||||
$('body')
|
||||
.on('change', ['#file', '#skin-type'], () => handleFiles())
|
||||
.on('change', '#file', () => handleFiles())
|
||||
.on('ifToggled', '#type-cape', () => handleFiles())
|
||||
.on('change', '#skin-type', function () {
|
||||
if ($('#file').prop('files').length === 0) {
|
||||
$.msp.config.slim = ($(this).val() === 'alex');
|
||||
$.msp.config.skinUrl = getDefaultSkin();
|
||||
initSkinViewer();
|
||||
}
|
||||
handleFiles();
|
||||
})
|
||||
.on('ifToggled', '#type-skin', function () {
|
||||
$(this).prop('checked') ? $('#skin-type').show() : $('#skin-type').hide();
|
||||
})
|
||||
@ -20,7 +28,7 @@ function initUploadListeners() {
|
||||
});
|
||||
|
||||
$(document).ready(() => {
|
||||
$.msp.config.skinUrl = defaultSkin;
|
||||
$.msp.config.skinUrl = defaultSteveSkin;
|
||||
initSkinViewer();
|
||||
$('[for="private"]').tooltip();
|
||||
});
|
||||
@ -45,7 +53,7 @@ function handleFiles(files, type) {
|
||||
const $name = $('#name');
|
||||
|
||||
if (type === 'cape') {
|
||||
$.msp.config.skinUrl = defaultSkin;
|
||||
$.msp.config.skinUrl = getDefaultSkin();
|
||||
|
||||
if (img.width / img.height === 2) {
|
||||
$.msp.config.capeUrl = img.src;
|
||||
@ -59,7 +67,7 @@ function handleFiles(files, type) {
|
||||
$.msp.config.skinUrl = img.src;
|
||||
$.msp.config.capeUrl = null;
|
||||
} else {
|
||||
$.msp.config.skinUrl = defaultSkin;
|
||||
$.msp.config.skinUrl = getDefaultSkin();
|
||||
toastr.warning(trans('skinlib.badSkinSize'));
|
||||
}
|
||||
}
|
||||
@ -89,6 +97,10 @@ function handleFiles(files, type) {
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultSkin() {
|
||||
return $('#skin-type').val() === 'alex' ? defaultAlexSkin : defaultSteveSkin;
|
||||
}
|
||||
|
||||
function upload() {
|
||||
const form = new FormData();
|
||||
const file = $('#file').prop('files')[0];
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* global defaultSkin, initSkinViewer */
|
||||
/* global initSkinViewer, defaultSteveSkin, defaultAlexSkin */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -69,7 +69,7 @@ async function showPlayerTexturePreview(pid) {
|
||||
if (type === 'cape') {
|
||||
$.msp.config.capeUrl = '';
|
||||
} else if (type === (result.preference === 'slim' ? 'alex' : 'steve')) {
|
||||
$.msp.config.skinUrl = defaultSkin;
|
||||
$.msp.config.skinUrl = type === 'steve' ? defaultSteveSkin : defaultAlexSkin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@
|
||||
|
||||
<script type="text/javascript" src="{{ assets('js/skinview3d.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
var defaultSkin = "data:image/png;base64,{{ App\Http\Controllers\TextureController::getDefaultSkin() }}";
|
||||
var defaultAlexSkin = "data:image/png;base64,{{ App\Http\Controllers\TextureController::getDefaultAlexSkin() }}";
|
||||
var defaultSteveSkin = "data:image/png;base64,{{ App\Http\Controllers\TextureController::getDefaultSteveSkin() }}";
|
||||
</script>
|
||||
|
@ -142,7 +142,7 @@
|
||||
var texture = {!! $texture->toJson() !!};
|
||||
|
||||
$.msp.config.slim = (texture.type === 'alex');
|
||||
$.msp.config.skinUrl = defaultSkin;
|
||||
$.msp.config.skinUrl = texture.type === 'alex' ? defaultAlexSkin : defaultSteveSkin;
|
||||
|
||||
if (texture.type === 'cape') {
|
||||
$.msp.config.capeUrl = url('textures/' + texture.hash);
|
||||
|
@ -94,7 +94,7 @@
|
||||
@section('script')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$.msp.config.skinUrl = defaultSkin;
|
||||
$.msp.config.skinUrl = defaultSteveSkin;
|
||||
initSkinViewer();
|
||||
registerAnimationController();
|
||||
registerWindowResizeHandler();
|
||||
|
@ -136,7 +136,7 @@
|
||||
@section('script')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$.msp.config.skinUrl = defaultSkin;
|
||||
$.msp.config.skinUrl = defaultSteveSkin;
|
||||
initSkinViewer();
|
||||
registerAnimationController();
|
||||
registerWindowResizeHandler();
|
||||
|
@ -28,7 +28,7 @@ class MinecraftTest extends TestCase
|
||||
$this->assertEquals(50, imagesy($avatar));
|
||||
|
||||
$avatar = Minecraft::generateAvatarFromSkin(
|
||||
TextureController::getDefaultSkin(),
|
||||
TextureController::getDefaultSteveSkin(),
|
||||
50,
|
||||
'f',
|
||||
true
|
||||
@ -79,7 +79,7 @@ class MinecraftTest extends TestCase
|
||||
$this->assertEquals(50, imagesy($preview));
|
||||
|
||||
$preview = Minecraft::generatePreviewFromSkin(
|
||||
TextureController::getDefaultSkin(),
|
||||
TextureController::getDefaultSteveSkin(),
|
||||
50,
|
||||
true,
|
||||
true
|
||||
|
@ -165,7 +165,7 @@ class TextureControllerTest extends TestCase
|
||||
->seeHeader('Content-Type', 'image/png');
|
||||
|
||||
$steve = factory(Texture::class)->create();
|
||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSkin());
|
||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
||||
Storage::disk('textures')->put($steve->hash, $png);
|
||||
|
||||
$user = factory(User::class)->create(['avatar' => $steve->tid]);
|
||||
@ -183,7 +183,7 @@ class TextureControllerTest extends TestCase
|
||||
public function testAvatarWithSize()
|
||||
{
|
||||
$steve = factory(Texture::class)->create();
|
||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSkin());
|
||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
||||
Storage::disk('textures')->put($steve->hash, $png);
|
||||
|
||||
$user = factory(User::class)->create(['avatar' => $steve->tid]);
|
||||
@ -209,7 +209,7 @@ class TextureControllerTest extends TestCase
|
||||
$this->get("/preview/{$steve->tid}.png")
|
||||
->seeHeader('Content-Type', 'image/png');
|
||||
|
||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSkin());
|
||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
||||
Storage::disk('textures')->put($steve->hash, $png);
|
||||
Storage::disk('textures')->put($cape->hash, $png);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user