class Speech < ActiveRecord::Base
belongs_to :speech_balloon
+ belongs_to :writing_format
validates :speech_balloon_id, :numericality => {:allow_blank => true}
+ validates :writing_format_id, :presence => true, :numericality => true, :existence => {:both => false}
+ validates :font_size, :presence => true, :numericality => {:only_integer => false}
+ validates :text_align, :presence => true, :numericality => true, :inclusion => { :in => 0..3 }
+ validates :fore_color, :presence => true, :numericality => {:greater_than_or_equal_to => 0, :less_than => 0x1000000}
validates :x, :presence => true, :numericality => true
validates :y, :presence => true, :numericality => true
validates :width, :presence => true, :numericality => true, :natural_number => true
validates :height, :presence => true, :numericality => true, :natural_number => true
validates :quotes, :length => {:maximum => 15}, :quotes_even => true
-# validates :settings, :presence => true
+ validates :settings, :extend_speech => true
before_validation :valid_encode
self.speech_balloon.panel.visible? roles
end
+ def new_speech_balloon
+ @new_speech_balloon
+ end
+
+ def new_speech_balloon= v
+ @new_speech_balloon = v
+ end
+
def get_speech_balloon
- self.speech_balloon
+ self.speech_balloon || @new_speech_balloon
end
def get_panel_id
'speech'
end
- def field_tree f
- 'panels-' + self.tag_panel_id + '-speech_balloons_attributes-' + self.tag_element_id + '-speech_attributes-' + f.to_s
+ def tag_new_index
+ if self.get_speech_balloon == nil
+ nil
+ else
+ self.get_speech_balloon.tag_new_index
+ end
end
def self.default_page_size
{'speech_attributes' => speech_attributes}
end
+ def writing_format_engine_model
+ self.writing_format.engine_model
+ end
+
def scenario
- ERB::Util.html_escape(self.content)
+ self.writing_format_engine_model.render self.content
end
def plain_scenario