OSDN Git Service

#xxxxx DTXViewerのプロジェクトを追加。
[dtxmania/dtxmania.git] / DTXViewerプロジェクト / @FDK10プロジェクト / Activity.cpp
1 #include "stdafx.h"
2 #include "Activity.h"
3
4 namespace FDK {
5         namespace AppBase {
6
7 Activity::Activity()
8 {
9         this->bActivate = false;
10         this->bFirstWork = true;
11 }
12
13 bool Activity::OneTimeSceneInit()
14 {
15         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
16         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
17         bool bRet = true;
18
19         // (1)\8e©\95ª
20         bRet = MyOneTimeSceneInit();
21         
22         // (2)\8eq\8fW\8d\87
23         Activity* pa;
24         this->Activities.resetList();
25         while( ( pa = this->Activities.getNext() ) != NULL )
26         {
27                 if( ! pa->OneTimeSceneInit() )
28                         bRet = false;
29         }
30         return bRet;
31 }
32
33 bool Activity::Activate()
34 {
35         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
36         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
37         bool bRet = true;
38
39         // (1)\8e©\95ª
40         bRet = MyActivate();
41         
42         // (2)\8eq\8fW\8d\87
43         Activity* pa;
44         this->Activities.resetList();
45         while( ( pa = this->Activities.getNext() ) != NULL )
46         {
47                 if( ! pa->Activate() )
48                         bRet = false;
49         }
50         return bRet;
51 }
52
53 bool Activity::UnActivate()
54 {
55         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
56         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
57         bool bRet = true;
58
59         // (1)\8e©\95ª
60         bRet = MyUnActivate();
61         
62         // (2)\8eq\8fW\8d\87
63         Activity* pa;
64         this->Activities.resetList();
65         while( ( pa = this->Activities.getNext() ) != NULL )
66         {
67                 if( !pa->UnActivate() )
68                         bRet = false;
69         }
70         return bRet;
71 }
72
73 bool Activity::FinalCleanup()
74 {
75         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
76         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
77         bool bRet = true;
78
79         // (1)\8e©\95ª
80         bRet = MyFinalCleanup();
81         
82         // (2)\8eq\8fW\8d\87
83         Activity* pa;
84         this->Activities.resetList();
85         while( ( pa = this->Activities.getNext() ) != NULL )
86         {
87                 if( !pa->FinalCleanup() )
88                         bRet = false;
89         }
90         return bRet;
91 }
92
93 bool Activity::InitDeviceObjects()
94 {
95         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
96         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
97         bool bRet = true;
98
99         // (1)\8e©\95ª
100         bRet = MyInitDeviceObjects();
101
102         // (2)\8eq\8fW\8d\87
103         Activity* pa;
104         this->Activities.resetList();
105         while( ( pa = this->Activities.getNext() ) != NULL )
106         {
107                 if( !pa->InitDeviceObjects() )
108                         bRet = false;
109         }
110         return bRet;
111 }
112
113 bool Activity::RestoreDeviceTextures()
114 {
115         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
116         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
117         bool bRet = true;
118
119         // (1)\8e©\95ª
120         bRet = MyRestoreDeviceTextures();
121
122         // (2)\8eq\8fW\8d\87
123         Activity* pa;
124         this->Activities.resetList();
125         while( ( pa = this->Activities.getNext() ) != NULL )
126         {
127                 if( !pa->RestoreDeviceTextures() )
128                         bRet = false;
129         }
130         return bRet;
131 }
132
133 bool Activity::RestoreDeviceSurfaces()
134 {
135         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
136         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
137         bool bRet = true;
138
139         // (1)\8e©\95ª
140         bRet = MyRestoreDeviceSurfaces();
141
142         // (2)\8eqActivity\8fW\8d\87
143         Activity* pa;
144         this->Activities.resetList();
145         while( ( pa = this->Activities.getNext() ) != NULL )
146         {
147                 if( !pa->RestoreDeviceSurfaces() )
148                         bRet = false;
149         }
150         return bRet;
151 }
152
153 bool Activity::InvalidateDeviceObjects()
154 {
155         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
156         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
157         bool bRet = true;
158
159         // (1)\8e©\95ª
160         bRet = MyInvalidateDeviceObjects();
161
162         // (2)\8eq\8fW\8d\87
163         Activity* pa;
164         this->Activities.resetList();
165         while( ( pa = this->Activities.getNext() ) != NULL )
166         {
167                 if( ! pa->InvalidateDeviceObjects() )
168                         bRet = false;
169         }
170         return bRet;
171 }
172
173 bool Activity::DeleteDeviceObjects()
174 {
175         // \8e©\95ª\81{\8eq\8fW\8d\87\91S\95\94\82É\82Â\82¢\82Ä\81A\83G\83\89\81[\82ª\8fo\82½\82ç\8bL\89¯\82µ\82Ä\82¨\82­\81B
176         // \83G\83\89\81[\82ª\82Å\82Ä\82Ä\82à\81A\8cÄ\82Ñ\8fo\82µ\82Í\91S\95\94\82É\82Â\82¢\82Ä\82Ð\82Æ\92Ê\82è\8ds\82¤\81B
177         bool bRet = true;
178
179         // (1)\8e©\95ª
180         bRet = MyDeleteDeviceObjects();
181
182         // (2)\8eq\8fW\8d\87
183         Activity* pa;
184         this->Activities.resetList();
185         while( ( pa = this->Activities.getNext() ) != NULL )
186         {
187                 if( ! pa->DeleteDeviceObjects() )
188                         bRet = false;
189         }
190         return bRet;
191 }
192
193 bool Activity::MyActivate()
194 {
195         if( this->bActivate )
196                 return true;            // \82·\82Å\82É\8a\88\90«\89»\82µ\82Ä\82é\82È\82ç\89½\82à\82µ\82È\82¢
197
198         this->bActivate = true;         // MyResoreDeviceObjects() \82Ì\8cÄ\82Ñ\8fo\82µ\82Ì\91O\82É\90Ý\92è
199
200         bool bTex\90¬\8c÷ = MyRestoreDeviceTextures();
201         bool bSur\90¬\8c÷ = MyRestoreDeviceSurfaces();
202         if( ! bTex\90¬\8c÷ || ! bSur\90¬\8c÷ )          // \83G\83\89\81[\82ª\8fo\82Ä\82à\82Ð\82Æ\92Ê\82è\82º\82ñ\82Ô\89ñ\82·
203                 this->bActivate = false;
204
205         return this->bActivate;
206 }
207
208 bool Activity::MyUnActivate()
209 {
210         if( ! this->bActivate )
211                 return true;            // \8a\88\90«\89»\82µ\82Ä\82È\82¢\82È\82ç\89½\82à\82µ\82È\82¢
212
213         MyInvalidateDeviceObjects();
214
215         this->bActivate = false;        // MyInvalidateDeviceObjects() \82Ì\8cÄ\82Ñ\8fo\82µ\82Ì\8cã\82É\90Ý\92è
216         return true;
217 }
218
219 bool Activity::MyRestoreDeviceTextures()
220 {
221         if( ! this->bActivate )
222                 return true;            // \8a\88\90«\89»\82µ\82Ä\82È\82¢\82È\82ç\89½\82à\82µ\82È\82¢
223
224         // \8eq\83e\83N\83X\83`\83\83\82Ì\8d\\92z
225         bool bRet = true;
226         CTexture* pt;
227         this->Textures.resetList();
228         while( ( pt = this->Textures.getNext() ) != NULL )
229         {
230                 if( FAILED( pt->RestoreDeviceObjects() ) )
231                         bRet = false;
232         }
233         return bRet;
234 }
235
236 bool Activity::MyRestoreDeviceSurfaces()
237 {
238         if( ! this->bActivate )
239                 return true;            // \8a\88\90«\89»\82µ\82Ä\82È\82¢\82È\82ç\89½\82à\82µ\82È\82¢
240
241         // \8eq\83T\81[\83t\83F\83C\83X\82Ì\8d\\92z
242         bool bRet = true;
243         CSurface* ps;
244         this->Surfaces.resetList();
245         while( ( ps = this->Surfaces.getNext() ) != NULL )
246         {
247                 if( FAILED( ps->RestoreDeviceObjects() ) )
248                         bRet = false;
249         }
250         return bRet;
251 }
252
253 bool Activity::MyInvalidateDeviceObjects()
254 {
255         if( ! this->bActivate )
256                 return true;            // \8a\88\90«\89»\82µ\82Ä\82È\82¢\82È\82ç\89½\82à\82µ\82È\82¢
257
258         bool bRet = true;
259
260         // \8eq\83e\83N\83X\83`\83\83\82Ì\96³\8cø\89»
261         CTexture* pt;
262         this->Textures.resetList();
263         while( ( pt = this->Textures.getNext() ) != NULL )
264         {
265                 if( FAILED( pt->InvalidateDeviceObjects() ) )
266                         bRet = false;
267         }
268
269         // \8eq\83T\81[\83t\83F\83C\83X\82Ì\96³\8cø\89»
270         CSurface* ps;
271         this->Surfaces.resetList();
272         while( ( ps = this->Surfaces.getNext() ) != NULL )
273         {
274                 if( FAILED( ps->InvalidateDeviceObjects() ) )
275                         bRet = false;
276         }
277
278         return bRet;
279 }
280
281 bool Activity::MyDeleteDeviceObjects()
282 {
283         bool bRet = true;
284
285         // \8eq\83e\83N\83X\83`\83\83\82Ì\8dí\8f\9c
286         CTexture* pt;
287         this->Textures.resetList();
288         while( ( pt = this->Textures.getNext() ) != NULL )
289         {
290                 if( FAILED( pt->DeleteDeviceObjects() ) )
291                         bRet = false;
292         }
293
294         // \8eq\83T\81[\83t\83F\83C\83X\82Ì\8dí\8f\9c
295         CSurface* ps;
296         this->Surfaces.resetList();
297         while( ( ps = this->Surfaces.getNext() ) != NULL )
298         {
299                 if( FAILED( ps->DeleteDeviceObjects() ) )
300                         bRet = false;
301         }
302
303         return bRet;
304 }
305
306         }//AppBase
307 }//FDK