add ability of selecting multi textures at closet
This commit is contained in:
parent
be4af844fe
commit
b232503fab
@ -33,32 +33,36 @@ class ClosetController extends Controller
|
||||
$page = $page <= 0 ? 1 : $page;
|
||||
$q = $request->input('q', null);
|
||||
|
||||
if ($q) {
|
||||
$result = [];
|
||||
$items = [];
|
||||
|
||||
foreach ($this->closet->getItems() as $item) {
|
||||
if (strstr($item->name, $q)) {
|
||||
$result[] = $item;
|
||||
if ($q) {
|
||||
foreach (['skin', 'cape'] as $category) {
|
||||
// do search
|
||||
foreach ($this->closet->getItems($category) as $item) {
|
||||
if (strstr($item->name, $q)) {
|
||||
$items[$category][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$items = $result;
|
||||
} else {
|
||||
$items = $this->closet->getItems($category);
|
||||
$items['skin'] = $this->closet->getItems('skin');
|
||||
$items['cape'] = $this->closet->getItems('cape');
|
||||
}
|
||||
|
||||
// pagination
|
||||
$items = array_slice($items, ($page-1)*6, 6);
|
||||
$total_pages = [];
|
||||
|
||||
$total_pages = ceil(count($items) / 6);
|
||||
foreach ($items as $key => $value) {
|
||||
$total_pages[] = ceil(count($items[$key]) / 6);
|
||||
$items[$key] = array_slice($value, ($page-1)*6, 6);
|
||||
}
|
||||
|
||||
echo View::make('user.closet')->with('items', $items)
|
||||
->with('page', $page)
|
||||
->with('q', $q)
|
||||
->with('category', $category)
|
||||
->with('total_pages', $total_pages)
|
||||
->with('user', $users->get(session('uid')))
|
||||
->render();
|
||||
return view('user.closet')->with('items', $items)
|
||||
->with('page', $page)
|
||||
->with('q', $q)
|
||||
->with('category', $category)
|
||||
->with('total_pages', max($total_pages))
|
||||
->with('user', $users->get(session('uid')));
|
||||
}
|
||||
|
||||
public function info()
|
||||
|
@ -125,16 +125,14 @@ class PlayerController extends Controller
|
||||
*/
|
||||
public function setTexture(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'tid' => 'required|integer'
|
||||
]);
|
||||
foreach ($request->input('tid') as $key => $value) {
|
||||
if (!($texture = Texture::find($value)))
|
||||
return json(trans('skinlib.un-existent'), 6);
|
||||
|
||||
if (!($texture = Texture::find($request->tid)))
|
||||
return json(trans('skinlib.un-existent'), 6);
|
||||
$field_name = "tid_{$texture->type}";
|
||||
|
||||
$field_name = "tid_{$texture->type}";
|
||||
|
||||
$this->player->setTexture([$field_name => $request->tid]);
|
||||
$this->player->setTexture([$field_name => $value]);
|
||||
}
|
||||
|
||||
return json(trans('user.player.set.success', ['name' => $this->player->player_name]), 0);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-07-16 10:02:24
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-09-25 10:16:21
|
||||
* @Last Modified time: 2016-11-13 12:15:16
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@ -124,6 +124,8 @@ $('.fa-repeat').click(function(){
|
||||
MSP.setStatus("rotation", !MSP.getStatus("rotation"));
|
||||
});
|
||||
|
||||
var selected = [];
|
||||
|
||||
$('body').on('click', '.item', function() {
|
||||
$('.item-selected').removeClass('item-selected');
|
||||
$(this).addClass('item-selected');
|
||||
@ -137,9 +139,19 @@ $('body').on('click', '.item', function() {
|
||||
success: function(json) {
|
||||
if (json.type == "cape") {
|
||||
MSP.changeCape('../textures/' + json.hash);
|
||||
selected['cape'] = tid;
|
||||
} else {
|
||||
MSP.changeSkin('../textures/' + json.hash);
|
||||
selected['skin'] = tid;
|
||||
}
|
||||
|
||||
selected.length = 0;
|
||||
|
||||
['skin', 'cape'].forEach(function(key) {
|
||||
if (selected[key] !== undefined) selected.length++;
|
||||
|
||||
$('#textures-indicator').html(selected.length);
|
||||
});
|
||||
},
|
||||
error: showAjaxError
|
||||
});
|
||||
@ -251,18 +263,20 @@ function setTexture() {
|
||||
if (this.checked) pid = this.id;
|
||||
});
|
||||
|
||||
var tid = $('.item-selected').attr('tid');
|
||||
|
||||
if (!pid) {
|
||||
toastr.info(trans('user.emptySelectedPlayer'));
|
||||
} else if (!tid) {
|
||||
} else if (selected.length == 0) {
|
||||
toastr.info(trans('user.emptySelectedTexture'));
|
||||
} else {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "./player/set",
|
||||
dataType: "json",
|
||||
data: { 'pid' : pid, 'tid' : tid },
|
||||
data: {
|
||||
'pid': pid,
|
||||
'tid[skin]': selected['skin'],
|
||||
'tid[cape]': selected['cape']
|
||||
},
|
||||
success: function(json) {
|
||||
if (json.errno == 0) {
|
||||
swal({
|
||||
|
@ -23,62 +23,30 @@
|
||||
<div class="row">
|
||||
<!-- Left col -->
|
||||
<div class="col-md-8">
|
||||
<!-- Custom tabs -->
|
||||
<div class="nav-tabs-custom">
|
||||
<!-- Tabs within a box -->
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#skin-category" data-toggle="tab">{{ trans('general.skin') }}</a></li>
|
||||
<li><a href="#cape-category" data-toggle="tab">{{ trans('general.cape') }}</a></li>
|
||||
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title" title="{{ trans('user.closet.switch-category') }}" data-toggle="tooltip" data-placement="bottom">
|
||||
@if ($q)
|
||||
搜索结果
|
||||
@else
|
||||
<a href="?category=skin" {{ ($category == "skin") ? 'class=selected' : "" }}>{{ trans('general.skin') }}</a>
|
||||
/
|
||||
<a href="?category=cape" {{ ($category == "cape") ? 'class=selected' : "" }}>{{ trans('general.cape') }}</a>
|
||||
@endif
|
||||
</h3>
|
||||
|
||||
<div class="box-tools pull-right">
|
||||
<div class="has-feedback">
|
||||
<div style="padding: 7px;">
|
||||
<div class="has-feedback pull-right">
|
||||
<form method="get" action="" class="user-search-form">
|
||||
<input type="text" name="q" class="form-control input-sm" placeholder="输入,回车搜索" value="{{ $q }}">
|
||||
<span class="glyphicon glyphicon-search form-control-feedback"></span>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.box-tools -->
|
||||
</div><!-- /.box-header -->
|
||||
|
||||
<div class="box-body">
|
||||
|
||||
@forelse ($items as $item)
|
||||
<div class="item" tid="{{ $item->tid }}">
|
||||
<div class="item-body">
|
||||
<img src="{{ url('preview/'.$item->tid) }}.png">
|
||||
</div>
|
||||
<div class="item-footer">
|
||||
<p class="texture-name">
|
||||
<span title="{{ $item->name }}">{{ $item->name }} <small>({{ $item->type }})</small></span>
|
||||
</p>
|
||||
|
||||
<a href="{{ url('skinlib/show?tid='.$item->tid) }}" title="{{ trans('user.closet.view') }}" class="more" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-share"></i></a>
|
||||
<span title="{{ trans('user.closet.more') }}" class="more" data-toggle="dropdown" aria-haspopup="true" id="share-button"><i class="fa fa-cog"></i></span>
|
||||
|
||||
<ul class="dropdown-menu" aria-labelledby="share-button">
|
||||
<li><a href="javascript:renameClosetItem({{ $item->tid }});">{{ trans('user.closet.rename.title') }}</a></li>
|
||||
<li><a href="javascript:removeFromCloset({{ $item->tid }});">{{ trans('user.closet.remove.title') }}</a></li>
|
||||
<li><a href="javascript:setAsAvatar({{ $item->tid }});">{{ trans('user.closet.set-avatar') }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div class="empty-msg">
|
||||
@if($q)
|
||||
{{ trans('skinlib.general.no-result') }}
|
||||
@else
|
||||
{!! trans('user.closet.empty-msg', ['url' => url('skinlib')]) !!}
|
||||
@endif
|
||||
</ul>
|
||||
<div class="tab-content no-padding">
|
||||
<div class="chart tab-pane active box-body" id="skin-category">
|
||||
@include('vendor.closet-items', ['items' => $items['skin']])
|
||||
</div>
|
||||
|
||||
@endforelse
|
||||
|
||||
<div class="chart tab-pane box-body" id="cape-category">
|
||||
@include('vendor.closet-items', ['items' => $items['cape']])
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<ul class="pagination pagination-sm no-margin pull-right">
|
||||
@ -99,7 +67,8 @@
|
||||
</ul>
|
||||
<p class="pull-right">{{ trans('general.pagination', ['page' => $page, 'total' => $total_pages]) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.nav-tabs-custom -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Left col -->
|
||||
|
30
resources/views/vendor/closet-items.tpl
vendored
Normal file
30
resources/views/vendor/closet-items.tpl
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
@forelse ($items as $item)
|
||||
<div class="item" tid="{{ $item->tid }}">
|
||||
<div class="item-body">
|
||||
<img src="{{ url('preview/'.$item->tid) }}.png">
|
||||
</div>
|
||||
<div class="item-footer">
|
||||
<p class="texture-name">
|
||||
<span title="{{ $item->name }}">{{ $item->name }} <small>({{ $item->type }})</small></span>
|
||||
</p>
|
||||
|
||||
<a href="{{ url('skinlib/show?tid='.$item->tid) }}" title="{{ trans('user.closet.view') }}" class="more" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-share"></i></a>
|
||||
<span title="{{ trans('user.closet.more') }}" class="more" data-toggle="dropdown" aria-haspopup="true" id="share-button"><i class="fa fa-cog"></i></span>
|
||||
|
||||
<ul class="dropdown-menu" aria-labelledby="share-button">
|
||||
<li><a href="javascript:renameClosetItem({{ $item->tid }});">{{ trans('user.closet.rename.title') }}</a></li>
|
||||
<li><a href="javascript:removeFromCloset({{ $item->tid }});">{{ trans('user.closet.remove.title') }}</a></li>
|
||||
<li><a href="javascript:setAsAvatar({{ $item->tid }});">{{ trans('user.closet.set-avatar') }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div class="empty-msg">
|
||||
@if($q)
|
||||
{{ trans('skinlib.general.no-result') }}
|
||||
@else
|
||||
{!! trans('user.closet.empty-msg', ['url' => url('skinlib')]) !!}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@endforelse
|
1
resources/views/vendor/texture-preview.tpl
vendored
1
resources/views/vendor/texture-preview.tpl
vendored
@ -1,5 +1,6 @@
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title" style="width: 100%;">{{ trans('general.texture-preview') }}
|
||||
<span id="textures-indicator" data-toggle="tooltip" title="" class="badge bg-light-blue"></span>
|
||||
<div class="operations">
|
||||
<i data-toggle="tooltip" data-placement="bottom" title="{{ trans('general.walk') }}" class="fa fa-pause"></i>
|
||||
<i data-toggle="tooltip" data-placement="bottom" title="{{ trans('general.run') }}" class="fa fa-forward"></i>
|
||||
|
Loading…
Reference in New Issue
Block a user