Add option for choosing types of textures to be cleared
This commit is contained in:
parent
e0fee86ea7
commit
ca9aded3df
@ -138,9 +138,13 @@ class PlayerController extends Controller
|
||||
return json(trans('user.player.set.success', ['name' => $this->player->player_name]), 0);
|
||||
}
|
||||
|
||||
public function clearTexture()
|
||||
public function clearTexture(Request $request)
|
||||
{
|
||||
$this->player->clearTexture();
|
||||
$types = array_filter(['steve', 'alex', 'cape'], function ($type) use ($request) {
|
||||
return $request->input($type);
|
||||
});
|
||||
|
||||
$this->player->clearTexture($types);
|
||||
|
||||
return json(trans('user.player.clear.success', ['name' => $this->player->player_name]), 0);
|
||||
}
|
||||
|
@ -97,17 +97,22 @@ class Player extends Model
|
||||
/**
|
||||
* Clear the textures of player.
|
||||
*
|
||||
* @return mixed
|
||||
* @param array|string $types
|
||||
* @return $this
|
||||
*/
|
||||
public function clearTexture()
|
||||
public function clearTexture($types)
|
||||
{
|
||||
$this->setPreference('default');
|
||||
$types = (array) $types;
|
||||
|
||||
return $this->setTexture([
|
||||
'tid_steve' => 0,
|
||||
'tid_alex' => 0,
|
||||
'tid_cape' => 0
|
||||
]);
|
||||
$map = [];
|
||||
|
||||
foreach ($types as $type) {
|
||||
$map["tid_$type"] = 0;
|
||||
}
|
||||
|
||||
$this->setTexture($map);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-07-16 10:02:24
|
||||
* @Last Modified by: g-plane
|
||||
* @Last Modified time: 2017-04-26 17:46:28
|
||||
* @Last Modified time: 2017-04-26 23:37:56
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@ -393,32 +393,49 @@ function changePlayerName(pid, current_player_name) {
|
||||
}
|
||||
|
||||
function clearTexture(pid) {
|
||||
swal({
|
||||
text: trans('user.clearTexture'),
|
||||
type: 'warning',
|
||||
showCancelButton: true
|
||||
}).then(function() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "./player/texture/clear",
|
||||
dataType: "json",
|
||||
data: { 'pid' : pid },
|
||||
success: function(json) {
|
||||
if (json.errno == 0) {
|
||||
swal({
|
||||
type: 'success',
|
||||
html: json.msg
|
||||
});
|
||||
} else {
|
||||
swal({
|
||||
type: 'error',
|
||||
html: json.msg
|
||||
});
|
||||
}
|
||||
},
|
||||
error: showAjaxError
|
||||
});
|
||||
let dom = `
|
||||
<div class="form-group">
|
||||
<input type="checkbox" id="clear-steve"> Default (Steve)
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="checkbox" id="clear-alex"> Slim (Alex)
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="checkbox" id="clear-cape"> ${trans('general.cape')}
|
||||
</div>
|
||||
<script>
|
||||
$('input[type=checkbox]').iCheck({ checkboxClass: 'icheckbox_square-blue' });
|
||||
</script>
|
||||
`;
|
||||
showModal(dom, trans('user.chooseClearTexture'), 'default', { callback: `ajaxClearTexture(${pid})` });
|
||||
return;
|
||||
}
|
||||
|
||||
function ajaxClearTexture(pid) {
|
||||
$('.modal').each(function () {
|
||||
if ($(this).css('display') == "none")
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
let data = { pid: pid };
|
||||
['steve', 'alex', 'cape'].forEach(type => {
|
||||
data[type] = $(`#clear-${type}`).prop('checked') ? 1 : 0;
|
||||
});
|
||||
|
||||
if (data['steve'] == data['alex'] == data['cape'] == 0) {
|
||||
toastr.warning(trans('user.noClearChoice'));
|
||||
return;
|
||||
}
|
||||
|
||||
Promise.resolve($.ajax({
|
||||
type: 'POST',
|
||||
url: './player/texture/clear',
|
||||
dataType: 'json',
|
||||
data: data
|
||||
})).then(json => {
|
||||
swal({ type: json.errno == 0 ? 'success' : 'error', html: json.msg });
|
||||
$('.modal').modal('hide');
|
||||
}).catch(error => showAjaxError);
|
||||
}
|
||||
|
||||
function deletePlayer(pid) {
|
||||
|
@ -86,6 +86,8 @@
|
||||
clearTexture: 'Sure to clear the skins & cape of this player?',
|
||||
deletePlayer: 'Sure to delete this player?',
|
||||
deletePlayerNotice: 'It\'s permanent. No backups.',
|
||||
chooseClearTexture: 'Choose texture types you want to clear',
|
||||
noClearChoice: 'You haven\'t choose any types',
|
||||
|
||||
// Profile
|
||||
setAvatar: 'Sure to set this as your avatar?',
|
||||
|
@ -86,6 +86,8 @@
|
||||
clearTexture: '确定要重置该用户的皮肤/披风吗?',
|
||||
deletePlayer: '真的要删除该玩家吗?',
|
||||
deletePlayerNotice: '这将是永久性的删除',
|
||||
chooseClearTexture: '选择要删除的材质类型',
|
||||
noClearChoice: '您还没选择要删除的材质类型',
|
||||
|
||||
// Profile
|
||||
setAvatar: '确定要将此材质设置为用户头像吗?',
|
||||
|
Loading…
Reference in New Issue
Block a user