diff --git a/app/assets/stylesheets/pet_states/show.sass b/app/assets/stylesheets/pet_states/show.sass new file mode 100644 index 00000000..8e19d73c --- /dev/null +++ b/app/assets/stylesheets/pet_states/show.sass @@ -0,0 +1,5 @@ +outfit-viewer + margin: 0 auto + +dt + cursor: help diff --git a/app/assets/stylesheets/pet_types/show.sass b/app/assets/stylesheets/pet_types/show.sass index df3b6b3e..3c912721 100644 --- a/app/assets/stylesheets/pet_types/show.sass +++ b/app/assets/stylesheets/pet_types/show.sass @@ -11,10 +11,14 @@ width: 200px max-width: calc(50% - .25em) min-width: 150px - padding: .5em box-sizing: border-box text-align: center + a + display: block + border-radius: 1em + padding: .5em + outfit-viewer width: 100% height: auto diff --git a/app/controllers/pet_states_controller.rb b/app/controllers/pet_states_controller.rb new file mode 100644 index 00000000..410de3c3 --- /dev/null +++ b/app/controllers/pet_states_controller.rb @@ -0,0 +1,6 @@ +class PetStatesController < ApplicationController + def show + @pet_type = PetType.matching_name_param(params[:pet_type_name]).first! + @pet_state = @pet_type.pet_states.find(params[:id]) + end +end diff --git a/app/models/pet_state.rb b/app/models/pet_state.rb index 6ab7ad62..392270d9 100644 --- a/app/models/pet_state.rb +++ b/app/models/pet_state.rb @@ -110,7 +110,7 @@ class PetState < ApplicationRecord def swf_asset_ids=(ids) self['swf_asset_ids'] = ids end - + def handle_assets! @parent_swf_asset_relationships_to_update.each do |rel| rel.swf_asset.save! @@ -118,6 +118,10 @@ class PetState < ApplicationRecord end end + def to_param + "#{id}-#{pose.split('_').map(&:capitalize).join('-')}" + end + def self.from_pet_type_and_biology_info(pet_type, info) swf_asset_ids = [] info.each do |zone_id, asset_info| diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index 1d388cfc..0f96f5b6 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -15,6 +15,10 @@ class PetType < ApplicationRecord species = Species.find_by_name!(species_name) where(color_id: color.id, species_id: species.id) } + scope :matching_name_param, ->(name_param) { + color_name, _, species_name = name_param.rpartition("-") + matching_name(color_name, species_name) + } scope :preferring_species, ->(species_id) { joins(:species).order([Arel.sql("species_id = ? DESC"), species_id]) } @@ -108,6 +112,10 @@ class PetType < ApplicationRecord Item.appearances_for(item, self, ...) end + def to_param + "#{color.human_name}-#{species.human_name}" + end + def self.all_by_ids_or_children(ids, pet_states) pet_states_by_pet_type_id = {} pet_states.each do |pet_state| diff --git a/app/views/pet_states/_pet_state.html.haml b/app/views/pet_states/_pet_state.html.haml index 492d8461..01e23076 100644 --- a/app/views/pet_states/_pet_state.html.haml +++ b/app/views/pet_states/_pet_state.html.haml @@ -1,5 +1,6 @@ %li - = outfit_viewer pet_state: - %span.name= pose_name pet_state.pose - - if pet_state.glitched? - %span.glitched{title: "Glitched"} 👾 + = link_to [pet_state.pet_type, pet_state] do + = outfit_viewer pet_state: + %span.name= pose_name pet_state.pose + - if pet_state.glitched? + %span.glitched{title: "Glitched"} 👾 diff --git a/app/views/pet_states/show.html.haml b/app/views/pet_states/show.html.haml new file mode 100644 index 00000000..2323255a --- /dev/null +++ b/app/views/pet_states/show.html.haml @@ -0,0 +1,36 @@ +- title "#{@pet_type.human_name}: #{pose_name @pet_state.pose} [\##{@pet_state.id}]" +- use_responsive_design + += outfit_viewer pet_state: @pet_state + +%dl + %dt{title: "Pose usually affects just the eyes and mouth. Neopets " + + "genders these as Male/Female, but I don't like those " + + "terms for like… it's just eyelashes! Sheesh!"} + Pose + %dd + = pose_name @pet_state.pose + - if @pet_state.pose == "UNCONVERTED" + (Retired, replaced by #{link_to "Alt Styles", alt_styles_path}) + + %dt{title: "This is our own internal ID number, nothing to do with " + + "Neopets's official data."} + DTI ID + %dd= @pet_state.id + + %dt{title: "When we notice a form looks wrong, we mark it Glitched, to " + + "tell our systems to prefer other forms for this pose instead."} + Glitched? + %dd + - if @pet_state.glitched? + 👾 Yes, it's bad news bonko'd + - else + ✅ Not marked as Glitched + +- content_for :stylesheets do + = stylesheet_link_tag "application/hanger-spinner" + = stylesheet_link_tag "application/outfit-viewer" + = stylesheet_link_tag "pet_states/show" + +- content_for :javascripts do + = javascript_include_tag "outfit-viewer", async: true diff --git a/config/routes.rb b/config/routes.rb index 72e7d006..27869947 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,7 +37,9 @@ OpenneoImpressItems::Application.routes.draw do end resources :alt_styles, path: 'alt-styles', only: [:index] resources :swf_assets, path: 'swf-assets', only: [:show] - resources :pet_types, path: 'rainbow-pool', only: [:show], param: "name" + resources :pet_types, path: 'rainbow-pool', only: [:show], param: "name" do + resources :pet_states, only: [:show], path: "forms" + end # Loading and modeling pets! post '/pets/load' => 'pets#load', :as => :load_pet