OSDN Git Service

最初のコミット
[shooting3/s2001.git] / project / sfglib / ConsoleImpl.h
1 /**
2  * @file
3  * @brief \89æ\96Ê\95`\89æ\81i\83X\83v\83\89\83C\83g\81E\94w\8ci\89æ\91\9c\81j\82Ì\8eÀ\91\95\82ð\8ds\82¤.
4  *
5  * @author S.F.
6  * @version $Id:
7  *
8  * Copyright (C) 2000-2002 Satoshi Fujiwara. All Rights Reserved.
9  */
10
11 /// \8fd\95¡\83C\83\93\83N\83\8b\81[\83h\96h\8e~\83}\83N\83\8d
12 #if !defined(AFX_ConsoleImpl_H__B6F6F87A_C87F_40DA_8F4F_C037111CAC9D__INCLUDED_)
13 #define AFX_ConsoleImpl_H__B6F6F87A_C87F_40DA_8F4F_C037111CAC9D__INCLUDED_
14
15 #if _MSC_VER > 1000
16 #pragma once
17 #endif // _MSC_VER > 1000
18 #include "sf.h"
19 #include "Console.h"
20 extern "C" {
21 namespace sf { 
22         namespace system {
23                 namespace console {
24                         /// \83X\83v\83\89\83C\83g\97\83o\81[\83e\83b\83N\83X\83o\83b\83t\83@\82Ì\83t\83\89\83
25                         const DWORD VertexFVF = 
26                                 (D3DFVF_XYZRHW | ///< \8dÀ\95W\8cn
27                                 D3DFVF_DIFFUSE | ///< \83f\83B\83t\83\85\81[\83Y
28                                 D3DFVF_SPECULAR | ///< \83X\83y\83L\83\85\83\89
29                                 D3DFVF_TEX1 );
30
31                         /// 3D\83J\83X\83^\83\80\92¸\93_\83t\83H\81[\83}\83b\83g
32                         struct Vertex2 {
33                             D3DVECTOR position; ///< \83I\83u\83W\83F\83N\83g\8dÀ\95W\81B
34                                 DWORD   diffuse; ///< \83f\83B\83t\83\85\81[\83Y
35                                 DWORD   specular;///< \83X\83y\83L\83\85\83\89\90¬\95ª
36                                 float   tu;///< \83e\83N\83X\83`\83\83u\8dÀ\95W
37                                 float   tv;///< \83e\83N\83X\83`\83\83v\8dÀ\95W
38                         };
39
40                         /// 3D\83X\83v\83\89\83C\83g\97\83o\81[\83e\83b\83N\83X\83o\83b\83t\83@\82Ì\83t\83\89\83
41                         const DWORD Vertex2FVF = (D3DFVF_DIFFUSE |  D3DFVF_SPECULAR | D3DFVF_XYZ | D3DFVF_TEX1);
42         
43                         /** Console\83C\83\93\83^\81[\83t\83F\81[\83X\82Ì\8eÀ\91\95. */
44                         class ConsoleImpl : public Console  
45                         {
46                                 // LIFECYCLE //
47                         public:
48                                 /// \83R\83\93\83X\83g\83\89\83N\83^
49                                 ConsoleImpl();
50                                 /** \83R\83\93\83X\83g\83\89\83N\83^
51                                 * @param hwnd \83E\83B\83\93\83h\83E\83n\83\93\83h\83\8b
52                                 * @param bWindow \83E\83B\83\93\83h\83E\95\\8e¦\82©\83t\83\8b\83X\83N\83\8a\81[\83\93\95\\8e¦\82© */
53                                 ConsoleImpl(const HWND hwnd,const bool bWindow);
54                                 /// \83f\83X\83g\83\89\83N\83^                                
55                                 virtual ~ConsoleImpl();
56                                 // OPERATORS //
57                                 // OPERATIONS //
58                                 virtual void initialize(void);
59                                 /** \8f\89\8aú\89»\82ð\8ds\82¤.
60                                  * @param hwnd \83E\83B\83\93\83h\83E\83n\83\93\83h\83\8b
61                                  * @param bWindow true \83E\83B\83\93\83h\83E\95\\8e¦ false \83t\83\8b\83X\83N\83\8a\81[\83\93\95\\8e¦ */
62                                 void initialize(const HWND hwnd,const bool bWindow);
63
64                                 /** \8fI\97¹\8f\88\97\9d\82ð\8ds\82¤.
65                                  * \8fI\97¹\8e\9e\82É\8aJ\95ú\82µ\82È\82­\82Ä\82Í\82¢\82¯\82È\82¢\82à\82Ì\82Í\82±\82±\82Å\8aJ\95ú\82·\82é */
66                                 void uninitialize(void);
67
68                                 virtual void clearScreen(COLOR value = 0x00000000);
69                                 virtual void fillScreen(COLOR value = 0x00000000);
70                                 void update(void);
71                                 
72                                 // \83o\83b\83N\83o\83b\83t\83@\82ÉAscii\95\8e\9a\97ñ\82ð\8ew\92è\82µ\82½\83e\83N\83X\83`\83\83\81[\94Ô\8d\86\82Å\95\\8e¦\82·\82é\81B
73                                 virtual void print(const int textureNo,const float x,const float y,const float angleRad,const float scale,const COLOR color,
74                                         const char *format,...);
75                                 // \83X\83v\83\89\83C\83g\82Ì\83\8d\81[\83h
76                                 sprite::Sprite* const createSprite(const sprite::Info* const pInfo);
77
78                                 // ACCESS //
79
80                                 // INQUIRY //
81                                 virtual const bool isEnabled(void) const {return mbD3DReady;};
82
83                         private:
84                                 /** D3D\83f\83o\83C\83X\82ð\83`\83F\83b\83N\82µ\81A\91I\91ð\82·\82é.
85                                  * \8c»\8dÝ\82Ì\83n\81[\83h\83E\83F\83A\82ÌD3D\83f\83o\83C\83X\82ð\83`\83F\83b\83N\82µ\81AConsoleImpl\82ª\95K\97v\82Æ\82·\82é\97v\8b\81\82É\91Î\89\9e\82µ\81A\82à\82Á\82Æ\82à\94\\97Í\82Ì\8d\82\82¢\82à\82Ì\82ð\91I\91ð\82µ\82Ü\82·\81B*/
86                                 void checkAndSetDevice(const D3DDEVTYPE devtype = D3DDEVTYPE_HAL);
87
88                                 /** \83f\83o\83C\83X\83^\83C\83v\82ð\83`\83F\83b\83N\82µ\81A\90Ý\92è\82·\82é */
89                                 void checkAndSetDeviceType(const D3DDEVTYPE devtype);
90         
91                                 /** \8c»\8dÝ\82Ì\83n\81[\83h\83E\83F\83A\82Ì\83o\83b\83N\83o\83b\83t\83@\83t\83H\81[\83}\83b\83g\82ð\83`\83F\83b\83N\82µ\81A\90Ý\92è\82·\82é
92                                  * \83V\83X\83e\83\80\82ª\97v\8b\81\82·\82é\83o\83b\83N\83o\83b\83t\83@\83t\83H\81[\83}\83b\83g\82ª\82 \82é\82©\82Ç\82¤\82©\83`\83F\83b\83N\82µ\81A\82 \82ê\82Î\90Ý\92è\82µ\82Ü\82·\81B<br>
93                                  * \82È\82¯\82ê\82Î\81A\97v\8b\81\82·\82é\82à\82Ì\82É\8dÅ\82à\8bß\82¢\83o\83b\83N\83o\83b\83t\83@\82Ì\83t\83H\81[\83}\83b\83g\82ð\91I\91ð\82µ\82Ü\82· */
94                                 void checkAndSetBackBufferFormat(void);
95                                 /** \8c»\8dÝ\82Ì\83n\81[\83h\83E\83F\83A\82Ì\83e\83N\83X\83`\83\83\83t\83H\81[\83}\83b\83g\82ð\83`\83F\83b\83N\82µ\81A\90Ý\92è\82·\82é */
96                                 void checkAndSetTextureFormat(void);
97                                 /** \8c»\8dÝ\82Ì\83n\81[\83h\83E\83F\83A\82Ì\83r\83b\83g\90[\93x\82ð\92²\82×\82Ä\81A\90Ý\92è\82·\82é */
98                                 void checkAndSetDepthFormat(void);
99                                 
100                                 /// \83\8c\83\93\83_\83\8a\83\93\83O\83X\83e\81[\83g\81A\83e\83N\83X\83`\83\83\83X\83e\81[\83W\83X\83e\81[\83g\82Ì\8f\89\8aú\89»\82ð\8ds\82¤
101                                 void initDeviceStates(void);
102
103                                 /// \89æ\96Ê\82Ì\8f\89\8aú\89»\81E\83r\83\85\81[\83|\81[\83g\82Ì\90Ý\92è\82È\82Ç\82ð\8ds\82¤ 
104                                 void initConsoleViewStyle(void);
105                                 
106                                 /// \83\89\83C\83g\82Ì\8f\89\8aú\89»\82ð\8ds\82¤
107                                 void initLight();
108
109                                 /// \95Ï\8a·\8ds\97ñ\82Ì\8f\89\8aú\89»\82ð\8ds\82¤
110                                 void initMatrix();
111
112
113                                 /// Reset\8e\9e\82É\8dÄ\8dì\90¬\82µ\82È\82­\82Ä\82Í\82¢\82¯\82È\82¢\8f\88\97\9d\82ð\8ds\82¤
114                                 void initNotManagedObjects(void);
115
116                                 /// D3DDevice\82Å\8aÇ\97\9d\82³\82ê\82È\82¢\83I\83u\83W\83F\83N\83g\82ð\8aJ\95ú\82·\82é
117                                 void releaseNotManagedObjects(void);
118                                 
119                                 /// \83t\83H\83\93\83g\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
120                                 void loadFont(void);
121
122                                 /// \83t\83\8c\81[\83\80\8aJ\8en\82ð\90é\8c¾\82·\82é
123                                 void startFrame(void);
124
125                                 /// \83t\83\8c\81[\83\80\8fI\97¹\82ð\90é\8c¾\82·\82é
126                                 void endFrame(void);
127
128                                 /// \83e\83L\83X\83g\82Ì\95`\89æ\82ð\8ds\82¤
129                                 void textDraw(int textureNo,float x,float y,float angleRad,float scale,COLOR color,char *pBuf);
130
131                                 /// \83e\83L\83X\83g\83L\83\85\81[\82Ì\93à\97e\82ð\8fo\97Í\82·\82é
132                                 void textOut(void);
133
134                                 HWND    mhWndMain;///< Window\83n\83\93\83h\83\8b
135                                 
136                                 bool                                    mbD3DReady;///< \82·\82×\82Ä\82Ì\8f\89\8aú\89»\82ª\8a®\97¹\82µ\81A\8eg\97p\89Â\94\
137                                 bool                                    mbWindowed;     ///< \83E\83B\83\93\83h\83E\83\82\81[\83h\82©\82Ç\82¤\82©
138                                 
139                                 LPDIRECT3D9                             mpD3D;///< D3D
140                                 D3DDEVTYPE                              mD3DDeviceType;///< D3D\83f\83o\83C\83X\83^\83C\83v                                                                   
141                                 
142                                 LPDIRECT3DDEVICE9               mpD3DDevice;///< D3DDevice
143                                 LPD3DXSPRITE                    mpD3DXSprite;///< D3DXSprite
144                                 
145                                 D3DFORMAT                               mD3DFormat;///< \83v\83\89\83C\83}\83\8a\81E\83o\83b\83N\83o\83b\83t\83@\82Ì\83t\83H\81[\83}\83b\83g
146                                 D3DFORMAT                               mTextureFormat;///< \93§\89ß\83e\83N\83X\83`\83\83\97p\83t\83H\81[\83}\83b\83g
147                                 D3DFORMAT                               mDepthFormat;///<\81@\90[\93x\83o\83b\83t\83@\97p\83t\83H\81[\83}\83b\83g
148                                 D3DPRESENT_PARAMETERS   mD3Dpp;///< D3DPRESENT_PARAMETERS
149                                 
150                                 IDirect3DTexture9*              mpFontTexture[font::COUNT_MAX];///< \83t\83H\83\93\83g\83e\83N\83X\83`\83\83\94z\97ñ
151                                 sprite::AbstractSprite* mpSprite[sprite::MAX];///< \83X\83v\83\89\83C\83g\83e\83N\83X\83`\83\83\94z\97ñ
152                                 
153                                 ///\81@\83e\83L\83X\83g\95\8e\9a\97ñ\95Û\8e\9d\83N\83\89\83X
154                                 class TextQueueData{
155                                 public:
156                                         /**\81@\83R\83\93\83X\83g\83\89\83N\83
157                                          * @param \83e\83N\83X\83`\83\83\94Ô\8d\86
158                                          * @param x \95\\8e¦x\8dÀ\95W
159                                          * @param y \95\\8e¦y\8dÀ\95W
160                                          * @param angleRad \95\\8e¦\8ap\93x(\83\89\83W\83A\83\93)
161                                          * @param scale \8ag\91å\8fk\8f¬\97¦
162                                          * @param color \95\\8e¦\90F
163                                          * @param pBuffer \83e\83L\83X\83g\95\8e\9a\97ñ\82Ì\83|\83C\83\93\83^ */
164                                         TextQueueData(const int textureNo,const float x,const float y,const float angleRad,const float scale,const COLOR color,const char *pBuffer = NULL);
165                                         /// \83f\83X\83g\83\89\83N\83^
166                                         ~TextQueueData();
167                                         // ACCESS 
168                                         /** \83e\83L\83X\83g\95\8e\9a\97ñ\82Ì\83|\83C\83\93\83^\82ð\8eæ\93¾\82·\82é.
169                                          * @return \83e\83L\83X\83g\95\8e\9a\97ñ\82Ì\90æ\93ª\83A\83h\83\8c\83X */
170                                         char * const buffer(void) { return mpBuf;};
171                                         
172                                         /** \83t\83H\83\93\83g\83e\83N\83X\83`\83\83\94Ô\8d\86\82ð\8eæ\93¾\82·\82é.
173                                          * @return \83t\83H\83\93\83g\83e\83N\83X\83`\83\83\94Ô\8d\86 */
174                                         const int textureNo() const { return mTextureNo;};
175                                         
176                                         /** \95\\8e¦\8aJ\8enX\8dÀ\95W\82ð\8eæ\93¾\82·\82é.
177                                          * @return \95\\8e¦\8aJ\8enX\8dÀ\95W */
178                                         const float x() const { return mX;};
179
180                                         /** \95\\8e¦\8aJ\8enY\8dÀ\95W\82ð\8eæ\93¾\82·\82é.
181                                          * @return \95\\8e¦\8aJ\8enY\8dÀ\95W */
182                                         const float y() const { return mY;};
183
184                                         /** \95\\8e¦\8ap\93x\82ð\8eæ\93¾\82·\82é.
185                                          * @return \95\\8e¦\8aJ\8enX\8dÀ\95W */
186                                         const float angeleRad() const { return mAngleRad;};
187
188                                         /** \8ag\91å\8fk\8f¬\97¦\82ð\8eæ\93¾\82·\82é.
189                                          * @return \8ag\91å\8fk\8f¬\97¦ */
190                                         const float scale() const { return mScale;};
191
192                                         /** \95\\8e¦\90F\82ð\8eæ\93¾\82·\82é.
193                                          * @return \95\\8e¦\90F */
194                                         const COLOR color() const { return mColor;};
195                                 private:
196                                         int mTextureNo;///< \83t\83H\83\93\83g\83e\83N\83X\83`\83\83\94Ô\8d\86
197                                         float mX;///< \95\\8e¦\8aJ\8enX\8dÀ\95W
198                                         float mY;///< \95\\8e¦\8aJ\8enY\8dÀ\95W
199                                         float mAngleRad;///< \95\\8e¦\8ap\93x\81i\83\89\83W\83A\83\93\81j
200                                         float mScale;///< \8ag\91å\8fk\8f¬\97¦
201                                         COLOR mColor;///< \95\\8e¦\90F
202                                         char mpBuf[text::BUFFER_LENGTH];///< \95\\8e¦\95\8e\9a\97ñ
203                                 };
204
205                                 /// \83e\83L\83X\83g\95\\8e¦\97p\83L\83\85\81[\83o\83b\83t\83
206                                 std::queue<TextQueueData *> mTextQueue;
207
208                         }; // ConsoleImpl
209                 } // namespace console
210         } // namespace system
211 } // namespace sf
212 }
213 #endif // !defined(AFX_ConsoleImpl_H__B6F6F87A_C87F_40DA_8F4F_C037111CAC9D__INCLUDED_)