00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * ビューポートスプライトステートヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef VIEWPORT_SPRITE_STATE_H_ 00026 #define VIEWPORT_SPRITE_STATE_H_ 00027 00028 #include "Graphics2D/SpriteState/SpriteState.h" 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * ビューポートスプライトステート 00035 */ 00036 class ViewportSpriteState : public SpriteState{ 00037 public: 00038 //-------------------------------------------------------------------------- 00039 // テンプレートステート 00040 //-------------------------------------------------------------------------- 00041 /// 無効 00042 static const ViewportSpriteState disableState; 00043 00044 /// デフォルト 00045 static const ViewportSpriteState defaultState; 00046 00047 //-------------------------------------------------------------------------- 00048 // 生成、破棄 00049 //-------------------------------------------------------------------------- 00050 /** 00051 * コンストラクタ 00052 */ 00053 ViewportSpriteState(); 00054 00055 /** 00056 * コンストラクタ 00057 * @param rectangle 矩形 00058 */ 00059 ViewportSpriteState(const RectangleI& rectangle); 00060 00061 /** 00062 * デストラクタ 00063 */ 00064 virtual ~ViewportSpriteState(); 00065 00066 //-------------------------------------------------------------------------- 00067 // デフォルトステート 00068 //-------------------------------------------------------------------------- 00069 /** 00070 * デフォルトステートの取得 00071 * @return デフォルトステート 00072 */ 00073 virtual const SpriteRequest* getDefaultState() const{ 00074 return &defaultState; 00075 } 00076 00077 //-------------------------------------------------------------------------- 00078 // 描画 00079 //-------------------------------------------------------------------------- 00080 /** 00081 * 適用 00082 * @param renderState レンダーステート 00083 */ 00084 virtual void apply(SpriteRenderState* renderState); 00085 00086 //-------------------------------------------------------------------------- 00087 // クリップ 00088 //-------------------------------------------------------------------------- 00089 /** 00090 * 矩形の設定 00091 * @param rectangle 設定する矩形 00092 */ 00093 virtual void setRectangle(const RectangleI& rectangle){ 00094 rectangle_ = rectangle; 00095 } 00096 00097 /** 00098 * 矩形の設定 00099 * @param position 設定する矩形の位置 00100 * @param size 設定する矩形のサイズ 00101 */ 00102 virtual void setRectangle( 00103 const Point2i& position, const DimensionI& size){ 00104 rectangle_.set(position.x, position.y, size.width, size.height); 00105 } 00106 00107 /** 00108 * 矩形の設定 00109 * @param x 設定する矩形のX位置 00110 * @param y 設定する矩形のY位置 00111 * @param width 設定する矩形の幅 00112 * @param height 設定する矩形の高さ 00113 */ 00114 virtual void setRectangle(int x, int y, int width, int height){ 00115 rectangle_.set(x, y, width, height); 00116 } 00117 00118 /** 00119 * 矩形の取得 00120 * @return 矩形 00121 */ 00122 virtual const RectangleI& getRectangle() const{ 00123 return rectangle_; 00124 } 00125 00126 /** 00127 * クリップが有効か 00128 * @return クリップが有効ならtrue 00129 */ 00130 virtual bool isEnabled() const{ 00131 return (rectangle_ != RectangleI::zero); 00132 } 00133 00134 //-------------------------------------------------------------------------- 00135 /** 00136 * クリップ位置の設定 00137 * @param position 設定するクリップ位置 00138 */ 00139 virtual void setPosition(const Point2i& position){ 00140 rectangle_.x = position.x; 00141 rectangle_.y = position.y; 00142 } 00143 00144 /** 00145 * クリップ位置の設定 00146 * @param x Xクリップ位置 00147 * @param y Yクリップ位置 00148 */ 00149 virtual void setPosition(int x, int y){ 00150 rectangle_.x = x; 00151 rectangle_.y = y; 00152 } 00153 00154 /** 00155 * クリップ位置の取得 00156 * @return クリップ位置 00157 */ 00158 virtual Point2i getPosition() const{ 00159 return Point2i(rectangle_.x, rectangle_.y); 00160 } 00161 00162 //-------------------------------------------------------------------------- 00163 /** 00164 * サイズの設定 00165 * @param size 設定するサイズ 00166 */ 00167 virtual void setSize(const DimensionI& size){ 00168 rectangle_.width = size.width; 00169 rectangle_.height = size.height; 00170 } 00171 00172 /** 00173 * サイズの設定 00174 * @param width 幅 00175 * @param height 高さ 00176 */ 00177 virtual void setSize(int width, int height){ 00178 rectangle_.width = width; 00179 rectangle_.height = height; 00180 } 00181 00182 /** 00183 * サイズの取得 00184 * @return サイズ 00185 */ 00186 virtual DimensionI getSize() const{ 00187 return DimensionI(rectangle_.width, rectangle_.height); 00188 } 00189 00190 private: 00191 //-------------------------------------------------------------------------- 00192 // 矩形 00193 RectangleI rectangle_; 00194 00195 }; 00196 00197 //------------------------------------------------------------------------------ 00198 } // End of namespace Lamp 00199 #endif // End of VIEWPORT_SPRITE_STATE_H_ 00200 //------------------------------------------------------------------------------