OSDN Git Service

GameSurfaceSDL クラスのリファクタリング / Code refactoring of GameSurfaceSDL class.
authorDeskull <desull@users.sourceforge.jp>
Mon, 12 Jan 2015 11:21:47 +0000 (20:21 +0900)
committerDeskull <desull@users.sourceforge.jp>
Mon, 12 Jan 2015 11:21:47 +0000 (20:21 +0900)
Deeangband/GameSurfaceSDL.cpp
Deeangband/GameSurfaceSDL.h

index a4586d3..4a6fd6d 100644 (file)
@@ -221,7 +221,7 @@ namespace Deeangband
                SDL_RenderClear(renderer);
 
                SDL_GetWindowSize(window, &rectTemp.w, &rectTemp.h);
-               this->rectMainMapDst.Set(200, 20, rectTemp.w - 210, rectTemp.h - 40);
+               this->rectMainMapDst.Set(240, 20, rectTemp.w - 210, rectTemp.h - 40);
                SDL_SetRenderDrawColor(renderer, 50, 20, 0, 255);
                SDL_RenderCopy(renderer, titleTexture, &rectTitleSrc, &rectTitleDst); 
 
@@ -601,7 +601,7 @@ void GameSurfaceSDL::calcMapDrawingSize(Coordinates *size)
 {
        int x, y;
        SDL_GetWindowSize(window, &x, &y);
-       size->Set((x - GameSurfaceSDL::sideBarWidth) / squareGraphicWidth, y / squareGraphicHeight - 1);
+       size->Set((x - 240) / squareGraphicWidth, y / squareGraphicHeight - 1);
        return;
 }
 
@@ -620,7 +620,7 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld *
                {
                        if(px >= 0 && py >= 0 && px < fieldPtr->GetWidth() && py < fieldPtr->GetHeight())
                        {
-                               SDL_Rect blitRect = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth, 30 + (py - y) * squareGraphicHeight , squareGraphicWidth, squareGraphicHeight};
+                               SDL_Rect blitRect = {rectDraw.x + (px - x) * squareGraphicWidth, rectDraw.y + (py - y) * squareGraphicHeight , squareGraphicWidth, squareGraphicHeight};
                                /*
                                SDL_Rect checkRect1 = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth - 2 + 12, 30 + (py - y) * squareGraphicHeight - 2 + 12, 4, 4};
                                SDL_Rect checkRect2 = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth - 2, 30 + (py - y) * squareGraphicHeight - 2, 4, 4};
@@ -679,7 +679,7 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld *
 
                if(subJectCreaturePtr->InSight(creatureIt->second->GetPosition().GetX(), creatureIt->second->GetPosition().GetY()))
                {
-                       SDL_Rect blitRect = {GameSurfaceSDL::sideBarWidth + (creatureIt->second->GetPosition().GetX() - x) * squareGraphicWidth, 30 + (creatureIt->second->GetPosition().GetY()- y) * squareGraphicHeight, squareGraphicWidth, squareGraphicHeight};
+                       SDL_Rect blitRect = {rectDraw.x + (creatureIt->second->GetPosition().GetX() - x) * squareGraphicWidth, rectDraw.y + (creatureIt->second->GetPosition().GetY()- y) * squareGraphicHeight, squareGraphicWidth, squareGraphicHeight};
                        SDL_RenderCopy(renderer, creatureTextures[creatureIt->first], &symbolRect, &blitRect); 
                }
                
index 7a4352b..735ca2d 100644 (file)
@@ -44,6 +44,12 @@ namespace Deeangband
                        this->h = h;
                }
 
+               SDL_Rect_Dee SDL_Rect_Dee::operator+(const SDL_Rect_Dee& plus)
+               {
+                       this->x += plus.x;
+                       this->y += plus.y;
+                       return *this;
+               }
 
                SDL_Rect_Dee()
                {
@@ -62,7 +68,6 @@ namespace Deeangband
        {
        private:
 
-               static const int sideBarWidth = 240; //!< \83T\83C\83h\83o\81[\82Ì\95\9d
                static const int squareGraphicWidth = 24; //!< 1\83}\83X\82Ì\83O\83\89\83t\83B\83b\83N\95\9d(\83s\83N\83Z\83\8b
                static const int squareGraphicHeight = 24; //!< 1\83}\83X\82Ì\83O\83\89\83t\83B\83b\83N\8d\82\82³(\83s\83N\83Z\83\8b