Skip to content

Commit

Permalink
✨feature: introduce overall colour toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed Feb 5, 2024
1 parent 3717a8e commit c4ab4bb
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 49 deletions.
2 changes: 1 addition & 1 deletion app/Models/Character/CharacterImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function getThumbnailUrlAttribute() {
*
* @return string
*/
public function displayColours($breaks = false) {
public function displayColours() {
// return the images as a row of colour boxes
if (!$this->colours) {
return '';
Expand Down
3 changes: 3 additions & 0 deletions config/lorekeeper/character_pairing.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
// Recommended to leave these settings alone unless you know what you're doing
/////////////////////////////////////

// 0: Disabled, 1: Enabled
'colours' => 0,

// if colours from parents should be inherited, entirely visual, no actual colour checks occur,
// just a colour palette generated from parents and displayed on the pairing slots
'inherit_colours' => 1, // 0: Disabled, 1: Enabled
Expand Down
18 changes: 10 additions & 8 deletions resources/views/admin/pairings/_pairing_myo.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
</div>
<div class="col-lg-8 col-md-6 col-8">{!! $myo['sex'] !!}</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6 col-4">
<h5>Colours</h5>
</div>
<div class="col-lg-8 col-md-6 col-8">
{!! $myo['palette'] ?? '<div class="alert alert-info">No colours generated. Inheritance likely disabled.</div>' !!}
</div>
</div>
@if(config('lorekeeper.character_pairing.colours'))
<div class="row">
<div class="col-lg-4 col-md-6 col-4">
<h5>Colours</h5>
</div>
<div class="col-lg-8 col-md-6 col-8">
{!! $myo['palette'] ?? '<div class="alert alert-info">No colours generated. Inheritance likely disabled.</div>' !!}
</div>
</div>
@endif
<div class="mb-3">
<div>
<h5>Traits</h5>
Expand Down
10 changes: 6 additions & 4 deletions resources/views/admin/pairings/roller.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ function(response, status, xhr) {
$parent.find('.character-rewards').removeClass('hide');
});
// load colour palette
$parent.find('.character-image-colours').load('{{ url('character') }}/' + $(this).val() + '/image/colours',
function(response, status, xhr) {
$parent.find('.character-image-colours').html(response);
});
if ("{{ config('lorekeeper.character_pairing.colours') }}" == 1) {
$parent.find('.character-image-colours').load('{{ url('character') }}/' + $(this).val() + '/image/colours',
function(response, status, xhr) {
$parent.find('.character-image-colours').html(response);
});
}
// check if both parents are selected
if ($char_1.find('.character-code').val() && $char_2.find('.character-code').val()) {
// get request to check if they are compatible
Expand Down
61 changes: 31 additions & 30 deletions resources/views/character/_image_info.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,41 +64,42 @@
<div class="col-lg-8 col-md-6 col-8">{!! $image->sex !!}</div>
</div>
@endif
<div class="row">
<div class="col-lg-4 col-md-6 col-4">
<h5>
Colours
@if ($image->character->is_myo_slot)
{!! add_help('These colours are created from the parents of the MYO slot. They are not editable until the MYO is created.') !!}
@endif
</h5>
</div>
<div class="col-lg-8 col-md-6 col-8">
@if ($image->colours)
<div class="{{ $image->character->is_myo_slot ? '' : 'row' }}">
{!! $image->displayColours() !!}
@if (Auth::check() && Auth::user()->hasPower('manage_characters') && !$image->character->is_myo_slot)
<div class="btn btn-outline-info btn-sm edit-image-colours ml-3 py-0" data-id="{{ $image->id }}">Edit</div>
@if (config('lorekeeper.character_pairing.colours'))
<div class="row">
<div class="col-lg-4 col-md-6 col-4">
<h5>
Colours
@if ($image->character->is_myo_slot)
{!! add_help('These colours are created from the parents of the MYO slot. They are not editable until the MYO is created.') !!}
@endif
</div>
@if (Auth::check() && Auth::user()->hasPower('manage_characters') && !$image->character->is_myo_slot)
<div class="collapse" id="colour-collapse-{{ $image->id }}">
@include('character.admin._edit_image_colours', ['image' => $image])
</h5>
</div>
<div class="col-lg-8 col-md-6 col-8">
@if ($image->colours)
<div class="{{ $image->character->is_myo_slot ? '' : 'row' }}">
{!! $image->displayColours() !!}
@if (Auth::check() && Auth::user()->hasPower('manage_characters') && !$image->character->is_myo_slot)
<div class="btn btn-outline-info btn-sm edit-image-colours ml-3 py-0" data-id="{{ $image->id }}">Edit</div>
@endif
</div>
@endif
@else
<div class="row">
<div>No colours listed.</div>
@if (Auth::check() && Auth::user()->hasPower('manage_characters') && !$image->character->is_myo_slot)
{!! Form::open(['url' => 'admin/character/image/' . $image->id . '/colours']) !!}
{!! Form::submit('Generate', ['class' => 'btn btn-outline-info btn-sm ml-3 py-0']) !!}
{!! Form::close() !!}
<div class="collapse" id="colour-collapse-{{ $image->id }}">
@include('character.admin._edit_image_colours', ['image' => $image])
</div>
@endif
</div>
@endif
@else
<div class="row">
<div>No colours listed.</div>
@if (Auth::check() && Auth::user()->hasPower('manage_characters') && !$image->character->is_myo_slot)
{!! Form::open(['url' => 'admin/character/image/' . $image->id . '/colours']) !!}
{!! Form::submit('Generate', ['class' => 'btn btn-outline-info btn-sm ml-3 py-0']) !!}
{!! Form::close() !!}
@endif
</div>
@endif
</div>
</div>
</div>

@endif

<div class="mb-3">
<div>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/character/design/image.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
<p>As a staff member, you may modify the thumbnail of the uploaded image and/or the credits, but not the image itself. If you have recropped the thumbnail, you may need to hard refresh to see the new one.</p>
@endif

@if ($request->character->is_myo_slot && $request->character->image->colours)
@if ($request->character->is_myo_slot && $request->character->image->colours && config('lorekeeper.character_pairing.colours'))
<div class="alert alert-info">
This is a pairing slot with predefined colours. Colours are a general guideline that your MYO should follow. You may deviate from these colours, but they should be recognizable as the same character. If you have any questions, please contact staff.
<div class="mt-2 mb-0">{!! $request->character->image->displayColours(true) !!}</div>
<div class="mt-2 mb-0">{!! $request->character->image->displayColours() !!}</div>
</div>
@endif

Expand Down
10 changes: 6 additions & 4 deletions resources/views/home/pairings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ function(response, status, xhr) {
$parent.find('.character-rewards').removeClass('hide');
});
// load colour palette
$parent.find('.character-image-colours').load('{{ url('character') }}/' + $(this).val() + '/image/colours',
function(response, status, xhr) {
$parent.find('.character-image-colours').html(response);
});
if ("{{ config('lorekeeper.character_pairing.colours') }}" == 1) {
$parent.find('.character-image-colours').load('{{ url('character') }}/' + $(this).val() + '/image/colours',
function(response, status, xhr) {
$parent.find('.character-image-colours').html(response);
});
}
// check if both parents are selected
if ($char_1.find('.character-code').val() && $char_2.find('.character-code').val()) {
// get request to check if they are compatible
Expand Down
3 changes: 3 additions & 0 deletions routes/lorekeeper/members.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
Route::get('{slug}/approval', 'CharacterController@getCharacterApproval');

Route::get('{slug}/image/colours', function ($slug) {
if (!config('lorekeeper.character_pairing.colours')) {
return "";
}
return \App\Models\Character\Character::where('slug', $slug)->first()?->image->displayColours();
});
});
Expand Down

0 comments on commit c4ab4bb

Please sign in to comment.