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 :x, :presence => true, :numericality => true
validates :y, :presence => true, :numericality => true
validates :width, :presence => true, :numericality => true, :natural_number => true
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