OSDN Git Service

Client is version 0.5.52, New balloon is working at Editor & Reader.
[pettanr/pettanr.git] / app / assets / javascripts / peta-apps.js
index 89e3be9..e362b29 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * pettanR peta.apps.js
- *   version 0.5.51
+ *   version 0.5.52
  *   
  * author:
  *   itozyun
                                        // Panel Element
                                        case PANEL_ELEMENT_ARRAY :
                                                json.type = FILE_TYPE.PANEL_ELEMENT;
-                                               data = createFileData( json, PANEL_ELEMENT_ARRAY, 'caption,url,width,height,x,y,z,t' ); // 画像の分
+                                               data = createFileData( json, PANEL_ELEMENT_ARRAY, 'caption,url,width,height,x,y,z,t,balloons,speeches,settings' ); // 画像の分
                                                // 噴出しの分
                                                // 景色の分
                                                break;
                                        };
                                };
 
-                               // パネル要素
+                               // パネル要素 配列
                                elements = json.elements;
                                if( Type.isArray( elements ) === true ){
                                        for( i = 0, l = elements.length; i<l; ++i ){
                                                addChildData( data, getResource( PANEL_ELEMENT_ARRAY, elements[ i ] ) );
                                        };
                                };
+                               //パネル要素,吹き出し
+                               if( json.speech_balloon_template_id ){
+                                       data.balloon_template = getResource( BALLOON_TEMPLETE_ARRAY, json.speech_balloon_template_id );
+                               };
                                
                                // Artist
                                if( json.artist || json.artist_id ){
                                        case FILE_TYPE.RESOURCE_PICTURE :
                                                data = data.picture;
                                        case FILE_TYPE.PICTURE :
-                                               return '実素材情報 revision:' + data.revision + ' ' + data.credit + ' ' + data.settings;
+                                               return '実素材情報  revision: ' + data.revision + ' credit: ' + data.credit;// + ' ' + data.settings;
                                        case FILE_TYPE.ORIGINAL_PICTURE :
                                                return [ '原画情報 ', data.width, 'x', data.height, ', filesize:', data.filesize, ' md5', data.md5 ].join( '' );
                                        case FILE_TYPE.COMIC :
        FILE_DATA_ORIGINAL_PICTURES_ROOT.children.push( FILE_DATA_MY_ORIGINAL_PICTURES_ROOT );
        
        FileAPI.createFolderUnderRoot( FILE_DATA_SERVICE_ROOT );
+       
+       // Balloon Templete の取得
+       // Reader, Editor で必要
+       (function( tree ){
+               tree.getRootFile().getSeqentialFiles();
+       })( FileAPI.createTree( FILE_DATA_BALLOON_ROOT ) );
+
 
        Driver.isPettanrFileInstance = function( file ){
                if( FileAPI.isFileInstance( file ) === true ){
@@ -3854,16 +3865,29 @@ var Editor = gOS.registerApplication( function(){
                this.$       = jqTextElementOrigin.clone( true );
                this.data    = data;
                this.elmText = this.$.find( 'td,.speach-inner' ).get( 0 );
-               this.type    = data.balloon_template_id;
-               this.content = ( function(){
-                       var _speachs = data.speeches_attributes;
-                       for( var k in _speachs ){
-                               return _speachs[ k ].content || '';
-                       }
-                       return '';
-               })();
+               this.type    = data.balloon_template_id || data.balloon_template.id;
+               this.content = '';
+               
+               var speachs = data.speeches;
+               for( var k in speachs ){
+                       this.content += speachs[ k ].content || '';
+               };
+               
+               var balloons = data.balloons,
+                       p, balloonData;
+               if( balloons ){
+                       for( p in balloons ){
+                               balloonData = balloons[ p ];
+                               break;
+                       };
+               };
                // this.balloon = pettanr.balloon.createBalloon( data.width, data.height, data.tail, this.type );
-               this.balloon = pettanr.newBalloon.create( data.balloon_classname, data.width, data.height, data.tail )
+               this.balloon = pettanr.newBalloon.create( this.type, balloonData.width, balloonData.height, balloonData.settings );
+               data.x       = balloonData.x;
+               data.y       = balloonData.y;
+               data.width   = balloonData.width;
+               data.height  = balloonData.height;
+               
                this.z       = data.z;
                this.timing  = data.t || PANEL_ELEMENT_ARRAY.length;
                
@@ -4155,18 +4179,20 @@ var Editor = gOS.registerApplication( function(){
                                if( data.classname ){
                                        data = {
                                                balloon_template_id : data.id,
-                                               balloon_classname   : data.classname,
-                                               size                : 1,
-                                               tail                : 90,
-                                               x                   : Math.floor( panelW / 2 - 100 + Math.random() * 10 ),
-                                               y                   : Math.floor( panelH / 2 - 100 + Math.random() * 10 ),
                                                z                   : -1,
-                                               t                   : 0,
-                                               width               : 200,
-                                               height              : 200,
-                                               speeches_attributes : {
-                                                       text1: {
-                                                               content:    'Hello'
+                                               t                   : 0,      
+                                               balloons : {
+                                                       balloon1 : {
+                                                               width    : 200,
+                                                               height   : 200,
+                                                               x        : Math.floor( panelW / 2 - 100 + Math.random() * 10 ),
+                                                               y        : Math.floor( panelH / 2 - 100 + Math.random() * 10 ),
+                                                               settings : {}                                                                                                           
+                                                       }
+                                               },
+                                               speeches : {
+                                                       speech1 : {
+                                                               content : 'Hello'
                                                        }
                                                }
                                        };
@@ -4423,13 +4449,13 @@ var Editor = gOS.registerApplication( function(){
                
 
                if( Type.isArray( panelElements ) === true ){
-                       for( var i=0; i<panelElements.length; ++i ){
+                       for( var i = 0; i < panelElements.length; ++i ){
                                panelElm = panelElements[ i ];
+                               if( panelElm.balloons ){
+                                       PANEL_ELEMENT_CONTROL.createTextElement( panelElm );
+                               } else
                                if( panelElm.picture ){
                                        PANEL_ELEMENT_CONTROL.createImageElement( panelElm );
-                               } else
-                               if( panelElm.balloon_template_id ){
-                                       PANEL_ELEMENT_CONTROL.createTextElement( panelElm );
                                };
                        };
                };
@@ -5193,14 +5219,14 @@ var Model = ( function(){
                        var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
                        return [
                                '{', cr,
-                                       '"speech_balloon_template_id": ', 1, ',', cr,
+                                       '"speech_balloon_template_id": ', _textElement.data.balloon_template_id, ',', cr,
                                        '"classname": "Square",',
                                        '"z": ',                _textElement.z + 1, ',', cr,
                                        '"t": ',                t, ',', cr,
                                        '"settings": "{\'tail\':' + _textElement.a + '}",',
                            '"balloons_attributes": {', cr,
                                '"newb', t, '": {', cr,
-                                                       '"system_picture_id": ',  2, ',', cr,
+                                                       '"system_picture_id": ',  _textElement.balloon.src, ',', cr,
                                                '"caption": "alt text",', cr,
                                                        '"x": ',        _textElement.x, ',', cr,
                                                        '"y": ',        _textElement.y, ',', cr,