OSDN Git Service

GameSurfaceSDL::initInterfaces() にフィールドグラフィックの事前作成処理を追加。 /
authorDeskull <desull@users.sourceforge.jp>
Sat, 27 Dec 2014 13:35:05 +0000 (22:35 +0900)
committerDeskull <desull@users.sourceforge.jp>
Sat, 27 Dec 2014 13:35:05 +0000 (22:35 +0900)
Add rendering process of field graphic to GameSurfaceSDL::initInterfaces().

Deeangband/GameSurfaceSDL.cpp
Deeangband/GameSurfaceSDL.h

index b1d7d14..bc18318 100644 (file)
@@ -77,6 +77,8 @@ namespace Deeangband
        void GameSurfaceSDL::initInterfaces(GameWorld *gameWorld)
        {
                std::map<TAG, boost::shared_ptr<Floor>>::iterator floorIt;
+               SDL_Rect floorSerfaceRect = {0, 0, 24, 24};
+
 
                font = TTF_OpenFont("ttf\\ipam.ttf", 18);
                src.x = 0;
@@ -104,7 +106,25 @@ namespace Deeangband
 
                for(floorIt = gameWorld->GetFloorList()->begin(); floorIt != gameWorld->GetFloorList()->end(); floorIt++)
                {
-                       fieldChipSurfaces;
+                       SDL_Surface *surface, *symbolSurface;
+                       Color symColor = floorIt->second->GetSymbolColor();
+                       Color backColor = floorIt->second->GetBackColor();
+                       SDL_Color sdlSymCol = {(Uint8)symColor.GetRed(), (Uint8)symColor.GetGreen(), (Uint8)symColor.GetBlue(), (Uint8)symColor.GetAlpha()};
+                       SDL_Rect blitRect = {0, 0, 24, 24};
+                       SDL_Rect symbolRect = {0, 0, 30, 30};
+                       char symBuf[80];
+
+                       surface = SDL_CreateRGBSurface(0, 24, 24, 32, 0, 0, 0, 0);
+
+                       SDL_FillRect(surface, &blitRect, SDL_MapRGBA(windowSurface->format, (Uint8)backColor.GetRed(), (Uint8)backColor.GetGreen(), (Uint8)backColor.GetBlue(), (Uint8)backColor.GetAlpha()));
+                       sprintf_s(symBuf, 5, "%s", floorIt->second->GetSymbol().c_str()); 
+                       symbolSurface = TTF_RenderUTF8_Blended(font, toUTF8(symBuf).c_str(), sdlSymCol);
+                       blitRect.x += (24 - symbolSurface->w) / 2;
+                       blitRect.y += (24 - symbolSurface->h) / 2;
+                       SDL_BlitSurface(symbolSurface, &symbolRect, surface, &blitRect); 
+                       SDL_FreeSurface(symbolSurface);
+
+                       floorChipSurfaces.insert(std::map<TAG, SDL_Surface*>::value_type(floorIt->first, surface));
                }
 
                renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
index eb69c06..4bfd002 100644 (file)
@@ -56,7 +56,7 @@ namespace Deeangband
                SDL_Surface *creatureStatusSurface;  //!< \83N\83\8a\81[\83`\83\83\81[\83X\83e\81[\83^\83X\95\\8e¦\82ÌSurface\8eQ\8fÆ
                SDL_Surface *creatureSideStatusSurface;  //!< \83T\83C\83h\83N\83\8a\81[\83`\83\83\81[\83X\83e\81[\83^\83X\95\\8e¦\82ÌSurface\8eQ\8fÆ
 
-               std::map<TAG, std::map<ID, boost::shared_ptr<SDL_Surface>>> *fieldChipSurfaces;
+               std::map<TAG, SDL_Surface*> floorChipSurfaces; //!< \83t\83\8d\83A\83O\83\89\83t\83B\83b\83N\82ÌSurface\8eQ\8fÆ\83\8a\83X\83g
 
                void GameSurfaceSDL::pushAnyKey(void);