forked from OpenNeo/impress
Disable pet faces that the item doesn't fit, in new item previews
This commit is contained in:
parent
a184c75575
commit
2b2bffd9da
4 changed files with 24 additions and 3 deletions
|
@ -175,6 +175,12 @@ body.items-show
|
||||||
&:not(:checked) + img
|
&:not(:checked) + img
|
||||||
opacity: .5
|
opacity: .5
|
||||||
|
|
||||||
|
&:disabled + img
|
||||||
|
filter: grayscale(1)
|
||||||
|
|
||||||
|
label:has(input[type=radio]:disabled)
|
||||||
|
cursor: not-allowed
|
||||||
|
|
||||||
noscript
|
noscript
|
||||||
position: absolute
|
position: absolute
|
||||||
inset: 0
|
inset: 0
|
||||||
|
|
|
@ -222,6 +222,10 @@ module ItemsHelper
|
||||||
cookies["DTIOutfitViewerIsPlaying"] == "true"
|
cookies["DTIOutfitViewerIsPlaying"] == "true"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def item_fits?(pet_type, all_appearances)
|
||||||
|
all_appearances.any? { |a| a.fits? pet_type }
|
||||||
|
end
|
||||||
|
|
||||||
def item_zone_partial_fit?(appearances_in_zone, all_appearances)
|
def item_zone_partial_fit?(appearances_in_zone, all_appearances)
|
||||||
appearances_in_zone.size < all_appearances.size
|
appearances_in_zone.size < all_appearances.size
|
||||||
end
|
end
|
||||||
|
|
|
@ -502,7 +502,7 @@ class Item < ApplicationRecord
|
||||||
Appearance = Struct.new(:item, :body, :swf_assets) do
|
Appearance = Struct.new(:item, :body, :swf_assets) do
|
||||||
include ActiveModel::Serializers::JSON
|
include ActiveModel::Serializers::JSON
|
||||||
delegate :present?, :empty?, to: :swf_assets
|
delegate :present?, :empty?, to: :swf_assets
|
||||||
delegate :species, to: :body
|
delegate :species, :fits?, to: :body
|
||||||
|
|
||||||
def attributes
|
def attributes
|
||||||
{item:, body:, swf_assets:}
|
{item:, body:, swf_assets:}
|
||||||
|
@ -522,6 +522,14 @@ class Item < ApplicationRecord
|
||||||
def attributes
|
def attributes
|
||||||
{id:, species:}
|
{id:, species:}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fits_all?
|
||||||
|
id == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def fits?(target)
|
||||||
|
fits_all? || target.body_id == id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def appearances
|
def appearances
|
||||||
|
|
|
@ -44,8 +44,11 @@
|
||||||
- @preview_pet_type_options.each do |pet_type|
|
- @preview_pet_type_options.each do |pet_type|
|
||||||
%label
|
%label
|
||||||
= radio_button_tag "species_face_id", pet_type.species_id,
|
= radio_button_tag "species_face_id", pet_type.species_id,
|
||||||
checked: pet_type == @preview_outfit.pet_type
|
checked: pet_type == @preview_outfit.pet_type,
|
||||||
= pet_type_image pet_type, :happy, :face
|
disabled: !item_fits?(pet_type, @all_appearances)
|
||||||
|
= pet_type_image pet_type,
|
||||||
|
item_fits?(pet_type, @all_appearances) ? :happy : :sad,
|
||||||
|
:face
|
||||||
|
|
||||||
.item-zones-info
|
.item-zones-info
|
||||||
%section
|
%section
|
||||||
|
|
Loading…
Reference in a new issue