1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: font_DispStringBuffer.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 24807 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_FONT_DISPSTRINGBUFFER_H_ 17 #define NW_FONT_DISPSTRINGBUFFER_H_ 18 19 #if defined(_MSC_VER) && _MSC_VER >= 1500 20 #pragma once 21 #endif 22 23 #include <nw/font/font_Types.h> 24 25 namespace nw { 26 namespace font { 27 28 namespace internal { 29 30 struct CharAttribute 31 { 32 math::VEC4 pos; 33 ut::Color8 color[TEXTCOLOR_MAX]; 34 math::VEC4 tex; 35 const internal::TextureObject* 36 pTexObj; //!< テクスチャオブジェクトへのポインタ 37 }; 38 39 } // namespace internal 40 41 //--------------------------------------------------------------------------- 42 //! :private 43 //! 44 //! @brief 文字列表示用バッファを管理するクラスです。 45 //--------------------------------------------------------------------------- 46 struct DispStringBuffer 47 { 48 const u32 charCountMax; //!< 格納可能な文字数 49 50 u16 charCount; //!< 格納した文字数 51 u16 drawCharCount; //!< 描画コマンドを生成する文字数 52 53 u8 generatedCommand; //!< コマンドが生成された。 54 u8 padding[3]; 55 56 u8* drawFlags; //!< フラグ配列 57 u32* commandBuffer; //!< コマンドバッファ 58 u32 commandBufferSize; //!< 使用しているコマンドバッファサイズ 59 u32 commandBufferCapacity; //!< コマンドバッファのキャパシティ 60 u32 textColorCommandOffset; //!< テキストカラーのコマンドのオフセット 61 62 //! 頂点属性配列 63 internal::CharAttribute* GetCharAttrsDispStringBuffer64 GetCharAttrs() const 65 { 66 return reinterpret_cast<internal::CharAttribute*>( 67 reinterpret_cast<uptr>(this) + sizeof(*this) ); 68 } 69 70 static u32 CalcCommandBufferCapacity(u32 charNum); 71 72 //! コンストラクタです。 73 DispStringBuffer(u32 charNum); 74 75 //! コマンドをクリアします。 ClearCommandDispStringBuffer76 void ClearCommand() 77 { 78 generatedCommand = false; 79 } 80 81 //! コマンドが生成済みかどうかを判定します。 IsGeneratedCommandDispStringBuffer82 bool IsGeneratedCommand() 83 { 84 return 0 != generatedCommand; 85 } 86 87 //! コマンドが空かどうかを判定します。 IsCommandEmptyDispStringBuffer88 bool IsCommandEmpty() 89 { 90 return 0 == commandBufferSize; 91 } 92 93 //! 描画コマンドを生成する文字数を取得します。 GetDrawCharCountDispStringBuffer94 u16 GetDrawCharCount() const { return drawCharCount; } 95 96 //! 描画コマンドを生成する文字数を設定します。 SetDrawCharCountDispStringBuffer97 void SetDrawCharCount(u16 count) 98 { 99 drawCharCount = count; 100 } 101 102 //! 描画コマンドを生成する文字数をリセットします。 ResetDrawCharCountDispStringBuffer103 void ResetDrawCharCount() 104 { 105 SetDrawCharCount(0xFFFF); 106 } 107 }; 108 109 } // namespace font 110 } // namespace nw 111 112 #endif // NW_FONT_DISPSTRINGBUFFER_H_ 113