Coverage report

  %line %branch
tsukuba_bunko.peko.scenario.stage.StageCoordinator
0% 
0% 

 1  
 /*
 2  
  * All Rights Reserved.
 3  
  * Copyright (C) 1999-2005 Tsukuba Bunko.
 4  
  *
 5  
  * Licensed under the BSD License ("the License"); you may not use
 6  
  * this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *       http://www.tsukuba-bunko.org/licenses/LICENSE.txt
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  *
 17  
  * $Id: StageCoordinator.java,v 1.3 2005/08/19 03:18:11 ppoi Exp $
 18  
  */
 19  
 package tsukuba_bunko.peko.scenario.stage;
 20  
 
 21  
 import	tsukuba_bunko.peko.ActionControler;
 22  
 import tsukuba_bunko.peko.Logger;
 23  
 
 24  
 import	tsukuba_bunko.peko.canvas.stage.Actor;
 25  
 import	tsukuba_bunko.peko.canvas.stage.Stage;
 26  
 
 27  
 import tsukuba_bunko.peko.scenario.Coordinator;
 28  
 import	tsukuba_bunko.peko.scenario.SceneContext;
 29  
 
 30  
 
 31  
 /**
 32  
  * StageCanvas への操作を取り持つコーディネータモジュールです。
 33  
  * @author	$Author: ppoi $
 34  
  * @version	$Revision: 1.3 $ $Date: 2005/08/19 03:18:11 $
 35  
  */
 36  
 public class StageCoordinator	extends Coordinator	{
 37  
 
 38  
 	/**
 39  
 	 * 立ち位置:中央
 40  
 	 */
 41  
 	public static final int	POSITION_CENTER = 0;
 42  
 
 43  
 	/**
 44  
 	 * 立ち位置:左
 45  
 	 */
 46  
 	public static final int	POSITION_LEFT = 1;
 47  
 
 48  
 	/**
 49  
 	 * 立ち位置:右
 50  
 	 */
 51  
 	public static final int	POSITION_RIGHT = 2;
 52  
 
 53  
 
 54  
 	/**
 55  
 	 * ネストレベル
 56  
 	 */
 57  0
 	protected int	_level = 0;
 58  
 
 59  
 
 60  
 	/**
 61  
 	 * <code>StageCoordinator</code> のインスタンスを生成します。
 62  
 	 */
 63  
 	public StageCoordinator()
 64  
 	{
 65  0
 		super();
 66  0
 	}
 67  
 
 68  
 
 69  
 	/**
 70  
 	 * <code>name</code> で識別される役者の情報を取得します。
 71  
 	 * @param	name	役者名
 72  
 	 * @return	Actor オブジェクト。該当する役者がいない場合 <code>null</code>
 73  
 	 */
 74  
 	public Actor getActor( String name )
 75  
 	{
 76  0
 		Actor	actor = getStage().getActor( name );
 77  0
 		if( actor == null )	{
 78  0
 			return null;
 79  
 		}
 80  
 		else	{
 81  0
 			Actor	copy = new Actor( actor.getName() );
 82  0
 			actor.copyTo( copy );
 83  0
 			return copy;
 84  
 		}
 85  
 	}
 86  
 
 87  
 
 88  
 	/**
 89  
 	 * 役者を舞台に登場させます。
 90  
 	 * @param	actor	登場する役者
 91  
 	 */
 92  
 	public void enter( Actor actor )
 93  
 	{
 94  0
 		if( isActiveThread() )	{
 95  0
 			getStage().enter( actor );
 96  
 		}
 97  0
 	}
 98  
 
 99  
 	/**
 100  
 	 * 役者を動かします。
 101  
 	 * @param	actor	動かす役者
 102  
 	 */
 103  
 	public void action( Actor actor )
 104  
 	{
 105  0
 		if( isActiveThread() )	{
 106  0
 			Stage	stage = getStage();
 107  0
 			Actor	current = stage.getActor( actor.getName() );
 108  0
 			if( current != null )	{
 109  0
 				if( current.getLooksImage() != actor.getLooksImage() )	{
 110  0
 					stage.exit( actor.getName() );
 111  0
 					stage.enter( actor );
 112  0
 				}
 113  
 				else	{
 114  0
 					stage.enter( actor );
 115  
 				}
 116  
 			}
 117  
 		}
 118  0
 	}
 119  
 
 120  
 	/**
 121  
 	 * 役者を退場させます。
 122  
 	 * @param	name	退場させる役者名
 123  
 	 * @return	退場した役者
 124  
 	 */
 125  
 	public Actor exit( String name )
 126  
 	{
 127  0
 		if( isActiveThread() )	{
 128  0
 			return getStage().exit( name );
 129  
 		}
 130  
 		else	{
 131  0
 			return null;
 132  
 		}
 133  
 	}
 134  
 
 135  
 	/**
 136  
 	 * 背景を指定した色に設定します。
 137  
 	 * @param	color	色名
 138  
 	 */
 139  
 	public void setBackgroundColor( String color )
 140  
 	{
 141  0
 		if( isActiveThread() )	{
 142  0
 			getStage().setBackgroundColor( color );
 143  
 		}
 144  0
 	}
 145  
 
 146  
 	/**
 147  
 	 * 背景を指定された画像に設定します。
 148  
 	 * @param	image	画像名
 149  
 	 */
 150  
 	public void setBackgroundImage( String image )
 151  
 	{
 152  0
 		if( isActiveThread() )	{
 153  0
 			getStage().setBackgroundImage( image );
 154  
 		}
 155  0
 	}
 156  
 
 157  
 	/**
 158  
 	 * スライドを表示します。
 159  
 	 * @param	slide	スライド名
 160  
 	 */
 161  
 	public void showSlide( String slide )
 162  
 	{
 163  0
 		if( isActiveThread() )	{
 164  0
 			getStage().showSlide( slide );
 165  
 		}
 166  0
 	}
 167  
 
 168  
 	/**
 169  
 	 * スライドを隠します。
 170  
 	 */
 171  
 	public void hideSlide()
 172  
 	{
 173  0
 		if( isActiveThread() )	{
 174  0
 			getStage().hideSlide();
 175  
 		}
 176  0
 	}
 177  
 
 178  
 	/**
 179  
 	 * BGM を再生します。
 180  
 	 * @param	id	BGM ID
 181  
 	 * @param	clipName	クリップ名
 182  
 	 * @param	loop	ループする場合 <code>true</code>、それ以外の場合 <code>false</code>
 183  
 	 */
 184  
 	public void playBGM( String id, String clipName, boolean loop )
 185  
 	{
 186  0
 		if( isActiveThread() )	{
 187  0
 			getStage().playBGM( id, clipName, loop );
 188  
 		}
 189  0
 	}
 190  
 
 191  
 	/**
 192  
 	 * BGM を停止します。
 193  
 	 * @param	id	BGM ID
 194  
 	 */
 195  
 	public void stopBGM( String id, int mode )
 196  
 	{
 197  0
 		if( isActiveThread() )	{
 198  0
 			getStage().stopBGM( id, mode );
 199  
 		}
 200  0
 	}
 201  
 
 202  
 	/**
 203  
 	 * SE を再生します。
 204  
 	 * @param	id	SE ID
 205  
 	 * @param	clipName	クリップ名
 206  
 	 * @param	loop	ループする場合 <code>true</code>、それ以外の場合 <code>false</code>
 207  
 	 */
 208  
 	public void playSE( String id, String clipName, boolean loop )
 209  
 	{
 210  0
 		if( isActiveThread() )	{
 211  0
 			getStage().playSE( id, clipName, loop );
 212  
 		}
 213  0
 	}
 214  
 
 215  
 	/**
 216  
 	 * SE を停止します。
 217  
 	 * @param	id	SE ID
 218  
 	 */
 219  
 	public void stopSE( String id, int mode )
 220  
 	{
 221  0
 		if( isActiveThread() )	{
 222  0
 			getStage().stopSE( id, mode );
 223  
 		}
 224  0
 	}
 225  
 
 226  
 	/**
 227  
 	 * ステージを指定されたエフェクトを使用して更新します。
 228  
 	 * @param	effect	エフェクト名
 229  
 	 */
 230  
 	public void updateStage( String effect )
 231  
 	{
 232  0
 		Logger.debug( "[scenario.stage] update stage. effect=" + effect );
 233  0
 		if( _level > 1 )	{
 234  0
 			return;
 235  
 		}
 236  
 
 237  0
 		Stage	stage = getStage();
 238  0
 		stage.updateCanvas( effect );
 239  0
 	}
 240  
 
 241  
 	/**
 242  
 	 * エフェクトを使用せずにステージを更新します。
 243  
 	 */
 244  
 	public void updateStage()
 245  
 	{
 246  0
 		if( isActiveThread() )	{
 247  0
 			updateStage( null );
 248  
 		}
 249  0
 	}
 250  
 
 251  
 	/**
 252  
 	 * テキストキャンバスを隠します。
 253  
 	 */
 254  
 	public void hideTextCanvas()
 255  
 	{
 256  0
 		if( isActiveThread() )	{
 257  0
 			getCanvasManager().hideTextCanvas();
 258  
 		}
 259  0
 	}
 260  
 
 261  
 	/**
 262  
 	 * ステージを取得します。
 263  
 	 * @return	ステージ
 264  
 	 */
 265  
 	protected Stage getStage()
 266  
 	{
 267  0
 		return getCanvasManager().getStage();
 268  
 	}
 269  
 
 270  
 	/**
 271  
 	 * スライドが表示中かどうかを判定します。
 272  
 	 * @return	スライドが表示中の場合 <code>true</code>,非表示中の場合 <code>false</code>
 273  
 	 */
 274  
 	public boolean isSlideVisible()
 275  
 	{
 276  0
 		return (getStage().getSlideImage() != null);
 277  
 	}
 278  
 
 279  
 
 280  
 //
 281  
 //	Coordinator の実装
 282  
 //
 283  
 	public void prepare( SceneContext context, Thread activeThread )
 284  
 	{
 285  0
 		super.prepare( context, activeThread );
 286  0
 		_level = 0;
 287  0
 	}
 288  
 
 289  
 	/**
 290  
 	 * StageCanvas に対する操作を開始します。
 291  
 	 */
 292  
 	public void begin()
 293  
 	{
 294  0
 		if( isActiveThread() )	{
 295  0
 			_level++;
 296  0
 			getCanvasManager().hideTextCanvas();
 297  0
 			getActionControler().setActive( false );
 298  0
 			getActionControler().setSaveEnabled( true );
 299  
 		}
 300  0
 	}
 301  
 
 302  
 	/**
 303  
 	 * StageCanvas に対する操作を終了し、キャンバスの状態を確定します。
 304  
 	 */
 305  
 	public void commit()
 306  
 	{
 307  0
 		if( isActiveThread() )	{
 308  0
 			_level--;
 309  0
 			if( _level == 0 )	{
 310  0
 				ActionControler	controler = getActionControler();
 311  0
 				controler.setActive( true );
 312  0
 				controler.setSaveEnabled( false );
 313  0
 				Stage	stage = getStage();
 314  0
 				stage.commit();
 315  
 			}
 316  
 		}
 317  0
 	}
 318  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.