• R/O
  • SSH
  • HTTPS

deeangband: Commit


Commit MetaInfo

Revision9208 (tree)
Time2014-02-20 20:34:23
Authordeskull

Log Message

Implementing GetCommand() to GameSurface.

Change Summary

Incremental Difference

--- source/branch/new_source/Deeangband/Deeangband/GameWorld.h (revision 9207)
+++ source/branch/new_source/Deeangband/Deeangband/GameWorld.h (revision 9208)
@@ -30,8 +30,9 @@
3030 #include "Species.h"
3131 #include "TrapBase.h"
3232
33-/*! @class GameWorld
34- * @brief ゲーム世界のクラス
33+/*!
34+ * @class GameWorld
35+ * @brief ゲーム世界のクラス
3536 */
3637 class GameWorld
3738 {
--- source/branch/new_source/Deeangband/Deeangband/GameSurface.h (revision 9207)
+++ source/branch/new_source/Deeangband/Deeangband/GameSurface.h (revision 9208)
@@ -9,6 +9,7 @@
99 #pragma once
1010
1111 #include "stdafx.h"
12+#include "Deeangband.h"
1213 #include "Floor.h"
1314
1415 /*!
@@ -24,4 +25,9 @@
2425 public:
2526 GameSurface();
2627 virtual ~GameSurface();
28+ virtual GameCommand GetCommand()
29+ {
30+ return GAME_COMMAND_REDRAW;
31+ }
2732 };
33+
--- source/branch/new_source/Deeangband/Deeangband/GameSurfaceSDL.h (revision 9207)
+++ source/branch/new_source/Deeangband/Deeangband/GameSurfaceSDL.h (revision 9208)
@@ -17,15 +17,6 @@
1717 #include <SDL_image.h>
1818 #include <SDL_ttf.h>
1919
20-/*!
21- * @brief SDLのキーコード定義
22- */
23-enum SDL_KEYCODE_LIST
24-{
25- SDL_KEY_ESC = 27,
26-};
27-
28-
2920 /*!
3021 * @class GameSurfaceSDL
3122 * @brief ゲームのメインインターフェイスクラス(SDL実装)
@@ -42,4 +33,5 @@
4233 GameSurfaceSDL(void);
4334 ~GameSurfaceSDL(void);
4435 void test(void);
36+ GameCommand GetCommand(void);
4537 };
--- source/branch/new_source/Deeangband/Deeangband/GameSurfaceSDL.cpp (revision 9207)
+++ source/branch/new_source/Deeangband/Deeangband/GameSurfaceSDL.cpp (revision 9208)
@@ -70,9 +70,6 @@
7070 SDL_Rect src = {0, 0, 300, 200};
7171 SDL_Rect title = {0, 0, 512, 512};
7272
73- //::setlocale(LC_CTYPE, "");
74- //::std::locale::global(std::locale("japanese"));
75-
7673 renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
7774
7875 SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
@@ -99,6 +96,36 @@
9996 }
10097 }
10198
99+GameCommand GameSurfaceSDL::GetCommand(void)
100+{
101+ SDL_Event event;
102+ SDL_Keycode key;
103+
104+ while (SDL_PollEvent(&event))
105+ {
106+ switch(event.type){
107+
108+ case SDL_KEYDOWN:
109+ {
110+ key=event.key.keysym.sym;
111+
112+ if(key == SDLK_ESCAPE)
113+ {
114+ return GAME_COMMAND_EXIT;
115+ }
116+ }
117+ break;
118+
119+ case SDL_QUIT:
120+ return GAME_COMMAND_EXIT;
121+ break;
122+
123+ }
124+ }
125+
126+ return GAME_COMMAND_REDRAW;
127+}
128+
102129 bool GameSurfaceSDL::SDL_event(void)
103130 {
104131 SDL_Event event;
@@ -112,7 +139,7 @@
112139 {
113140 key=event.key.keysym.sym;
114141
115- if(key == SDL_KEY_ESC)
142+ if(key == SDLK_ESCAPE)
116143 {
117144 return false;
118145 }
Show on old repository browser