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