3 #include "CSurfaceManager.h"
8 CSurfaceManager::CSurfaceManager()
10 this->pSurfaceList = this->pSurfaceListLast = NULL;
13 void CSurfaceManager::ResetCache()
15 for( SurfaceList* sc = this->pSurfaceList; sc != NULL; sc = sc->next )
19 CSurface* CSurfaceManager::GetCachedSurface( LPCTSTR name, LPCTSTR filename, DWORD width, DWORD height, LOADPLACE place )
23 //
\83t
\83@
\83C
\83\8b\82Ì
\8dÅ
\8fI
\8dX
\90V
\8e\9e\8d\8f\82Ì
\8eæ
\93¾
\81G
24 //
\81@fileInfo
\81©
\8ew
\92è
\82³
\82ê
\82½
\83t
\83@
\83C
\83\8b\82Ì
\8dÅ
\8fI
\8dX
\90V
\8e\9e\8d\8f
25 WIN32_FILE_ATTRIBUTE_DATA fileInfo;
26 if( ! ::GetFileAttributesEx( filename, GetFileExInfoStandard, &fileInfo) )
27 return NULL; //
\8e¸
\94s
29 //
\83L
\83\83\83b
\83V
\83\85\83\8a\83X
\83g
\82Ì
\92\86\82É
\93¯
\88ê
\82Ì
\82à
\82Ì
\82ª
\82 \82é
\82©
\92²
\82×
\82é
30 for( cell = this->pSurfaceList; cell != NULL; cell = cell->next )
32 if( lstrcmp( name, cell->strSurfaceName ) == 0 && lstrcmp( filename, cell->strFileName ) == 0
33 && ( fileInfo.ftLastWriteTime.dwLowDateTime == cell->ftLastWriteTime.dwLowDateTime )
34 && ( fileInfo.ftLastWriteTime.dwHighDateTime == cell->ftLastWriteTime.dwHighDateTime )
35 && ( cell->width == width && cell->height == height && cell->place == place ) )
37 cell->bUse = true; //
\82 \82Á
\82½
\82Ì
\82Å
\82»
\82ê
\82ð
\8eg
\82¤
38 return &cell->surface;
42 //
\8c´
\94Å
\82Ì
\90V
\8bK
\8dì
\90¬
43 cell = new SurfaceList();
44 cell->surface.InitDeviceObjectsFromFile( name, filename, width, height, place );
45 if( FAILED( cell->surface.RestoreDeviceObjects() ) )
47 cell->surface.DeleteDeviceObjects();
49 return NULL; //
\8d\
\92z
\82É
\8e¸
\94s
52 lstrcpyn( cell->strFileName, filename, _MAX_PATH );
53 lstrcpyn( cell->strSurfaceName, name, _MAX_PATH );
55 cell->height = height;
57 cell->ftLastWriteTime = fileInfo.ftLastWriteTime;
58 cell->prev = cell->next = NULL;
59 APPENDLIST( this->pSurfaceList, this->pSurfaceListLast, cell );
60 return &cell->surface;
63 void CSurfaceManager::RemoveUnusedSurfaces()
65 SurfaceList* sc = this->pSurfaceList;
68 SurfaceList* next = sc->next;
71 REMOVELIST( this->pSurfaceList, this->pSurfaceListLast, sc );
72 sc->surface.DeleteDeviceObjects();
79 HRESULT CSurfaceManager::OneTimeSceneInit()
81 SurfaceList *s = this->pSurfaceList;
84 SurfaceList *next = s->next;
85 s->surface.DeleteDeviceObjects();
89 this->pSurfaceList = this->pSurfaceListLast = NULL;
93 HRESULT CSurfaceManager::FinalCleanup()
95 SurfaceList *s = this->pSurfaceList;
98 SurfaceList *next = s->next;
99 s->surface.DeleteDeviceObjects();
103 this->pSurfaceList = this->pSurfaceListLast = NULL;
107 HRESULT CSurfaceManager::InitDeviceObjects()
109 for( SurfaceList* s = this->pSurfaceList; s != NULL; s = s->next )
110 s->surface.InitDeviceObjectsFromFile( s->strSurfaceName, s->strFileName, s->width, s->height, s->place );
114 HRESULT CSurfaceManager::RestoreDeviceObjects()
116 for( SurfaceList* s = this->pSurfaceList; s != NULL; s = s->next )
117 s->surface.RestoreDeviceObjects();
121 HRESULT CSurfaceManager::InvalidateDeviceObjects()
123 for( SurfaceList* s = this->pSurfaceList; s != NULL; s = s->next )
124 s->surface.InvalidateDeviceObjects();
128 HRESULT CSurfaceManager::DeleteDeviceObjects()
130 for( SurfaceList* s = this->pSurfaceList; s != NULL; s = s->next )
131 s->surface.DeleteDeviceObjects();