OSDN Git Service

t#31671:add elm copy
[pettanr/pettanr.git] / app / models / speech_balloon.rb
index d8e6e31..19195ee 100644 (file)
@@ -168,6 +168,24 @@ class SpeechBalloon < ActiveRecord::Base
     self.panel.remove_element(self, au)
   end
   
+  def copy from_panel
+    sb = SpeechBalloon.new self.attributes
+    sb.panel_id = from_panel.id
+    sb.t = sb.panel.new_t 
+    sb.z = sb.panel.new_z 
+    b = sb.build_balloon(self.balloon.attributes)
+    s = sb.build_speech(self.speech.attributes)
+    sb.extend self.speech_balloon_template.engine_speech_balloon_module
+    b.extend self.speech_balloon_template.engine_balloon_module
+    s.extend self.speech_balloon_template.engine_speech_module
+    b.new_speech_balloon = sb
+    s.new_speech_balloon = sb
+    sbe = sb.extend_speech_balloon
+    be = b.extend_balloon
+    se = s.extend_speech
+    {:speech_balloon => sb, :balloon => b, :speech => s, :speech_balloon_extend => sbe, :balloon_extend => be, :speech_extend => se }
+  end
+  
   def scenario
     ERB::Util.html_escape(self.caption.to_s) + self.balloon.scenario.to_s + 
     self.speech.scenario.to_s