X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。
| Revision | 163 (tree) |
|---|---|
| Time | 2017-01-22 22:33:32 |
| Author | |
コンソールのコマンドを2個追加(window・exit)、コンパイラの警告対策、OpenGLでのリセット処理に対応。
| @@ -69,6 +69,21 @@ | ||
| 69 | 69 | DestroyD3D(); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | +//! @brief フルスクリーンフラグ設定 | |
| 73 | +//! @param fullscreen フルスクリーンフラグ | |
| 74 | +//! @attention 同フラグは、初期化時の InitD3D() 関数でも設定できます。 | |
| 75 | +void D3DGraphics::SetFullScreenFlag(bool fullscreen) | |
| 76 | +{ | |
| 77 | + fullscreenflag = fullscreen; | |
| 78 | +} | |
| 79 | + | |
| 80 | +//! @brief フルスクリーンフラグ取得 | |
| 81 | +//! @return フルスクリーンフラグ | |
| 82 | +bool D3DGraphics::GetFullScreenFlag() | |
| 83 | +{ | |
| 84 | + return fullscreenflag; | |
| 85 | +} | |
| 86 | + | |
| 72 | 87 | //! @brief 初期化@n |
| 73 | 88 | //! (DirectX 9) |
| 74 | 89 | //! @param WindowCtrl WindowControlクラスのポインタ |
| @@ -342,10 +357,16 @@ | ||
| 342 | 357 | //! @brief デバイスのリソースを解放 |
| 343 | 358 | void D3DGraphics::CleanupD3Dresource() |
| 344 | 359 | { |
| 345 | - if( TextureFont != -1 ){ CleanupTexture(TextureFont); } | |
| 360 | + if( TextureFont != -1 ){ | |
| 361 | + CleanupTexture(TextureFont); | |
| 362 | + TextureFont = -1; | |
| 363 | + } | |
| 346 | 364 | |
| 347 | 365 | #ifdef ENABLE_DEBUGCONSOLE |
| 348 | - if( TextureDebugFont != -1 ){ CleanupTexture(TextureDebugFont); } | |
| 366 | + if( TextureDebugFont != -1 ){ | |
| 367 | + CleanupTexture(TextureDebugFont); | |
| 368 | + TextureDebugFont = -1; | |
| 369 | + } | |
| 349 | 370 | #endif |
| 350 | 371 | |
| 351 | 372 | if( pxmsfont != NULL ){ |
| @@ -633,10 +654,10 @@ | ||
| 633 | 654 | bmpdata[0x03] = (unsigned char)((bufsize >> 8) & 0x000000FF); |
| 634 | 655 | bmpdata[0x04] = (unsigned char)((bufsize >> 16) & 0x000000FF); |
| 635 | 656 | bmpdata[0x05] = (unsigned char)((bufsize >> 24) & 0x000000FF); |
| 636 | - bmpdata[0x0A] = headersize; | |
| 637 | - bmpdata[0x0E] = headersize - 14; | |
| 638 | - bmpdata[0x12] = width; | |
| 639 | - bmpdata[0x16] = height; | |
| 657 | + bmpdata[0x0A] = (unsigned char)headersize; | |
| 658 | + bmpdata[0x0E] = (unsigned char)(headersize - 14); | |
| 659 | + bmpdata[0x12] = (unsigned char)width; | |
| 660 | + bmpdata[0x16] = (unsigned char)height; | |
| 640 | 661 | bmpdata[0x1A] = 1; |
| 641 | 662 | bmpdata[0x1C] = 24; |
| 642 | 663 | bmpdata[0x1E] = 0; |
| @@ -53,6 +53,7 @@ | ||
| 53 | 53 | hGLRC = NULL; |
| 54 | 54 | width = 0; |
| 55 | 55 | height = 0; |
| 56 | + fullscreenflag = false; | |
| 56 | 57 | SystemFont = NULL; |
| 57 | 58 | now_SystemFontUStr = new WCHAR [1]; |
| 58 | 59 | now_SystemFontUStr[0] = NULL; |
| @@ -86,6 +87,21 @@ | ||
| 86 | 87 | DestroyD3D(); |
| 87 | 88 | } |
| 88 | 89 | |
| 90 | +//! @brief フルスクリーンフラグ設定 | |
| 91 | +//! @param fullscreen フルスクリーンフラグ | |
| 92 | +//! @attention 同フラグは、初期化時の InitD3D() 関数でも設定できます。 | |
| 93 | +void D3DGraphics::SetFullScreenFlag(bool fullscreen) | |
| 94 | +{ | |
| 95 | + fullscreenflag = fullscreen; | |
| 96 | +} | |
| 97 | + | |
| 98 | +//! @brief フルスクリーンフラグ取得 | |
| 99 | +//! @return フルスクリーンフラグ | |
| 100 | +bool D3DGraphics::GetFullScreenFlag() | |
| 101 | +{ | |
| 102 | + return fullscreenflag; | |
| 103 | +} | |
| 104 | + | |
| 89 | 105 | //! @brief 初期化@n |
| 90 | 106 | //! (OpenGL 1.1) |
| 91 | 107 | //! @param WindowCtrl WindowControlクラスのポインタ |
| @@ -106,6 +122,8 @@ | ||
| 106 | 122 | width = prc.right; |
| 107 | 123 | height = prc.bottom; |
| 108 | 124 | |
| 125 | + fullscreenflag = fullscreen; | |
| 126 | + | |
| 109 | 127 | //フルスクリーン化 |
| 110 | 128 | if( fullscreen == true ){ |
| 111 | 129 | DEVMODE devmode; |
| @@ -219,14 +237,99 @@ | ||
| 219 | 237 | OutputLog.WriteLog(LOG_INIT, "グラフィック", "OpenGL(リセット)"); |
| 220 | 238 | #endif |
| 221 | 239 | |
| 240 | + //リソース解放 | |
| 241 | + CleanupD3Dresource(); | |
| 242 | + | |
| 243 | + if( hGLRC != NULL ){ | |
| 244 | + wglDeleteContext(hGLRC); | |
| 245 | + hGLRC = NULL; | |
| 246 | + } | |
| 247 | + | |
| 248 | + | |
| 249 | + // 解放処理ここまで | |
| 250 | + // ここから初期化処理 | |
| 251 | + | |
| 222 | 252 | hWnd = WindowCtrl->GethWnd(); |
| 223 | 253 | |
| 254 | + //フルスクリーン化 | |
| 255 | + if( fullscreenflag == true ){ | |
| 256 | + DEVMODE devmode; | |
| 257 | + ZeroMemory(&devmode, sizeof(devmode)); | |
| 258 | + devmode.dmSize = sizeof(devmode); | |
| 259 | + devmode.dmPelsWidth = width; | |
| 260 | + devmode.dmPelsHeight = height; | |
| 261 | + devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; | |
| 262 | + | |
| 263 | + if( ChangeDisplaySettings(&devmode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL ){ | |
| 264 | + return 1; | |
| 265 | + } | |
| 266 | + ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); | |
| 267 | + } | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + HDC hDC; | |
| 272 | + int pfdID; | |
| 273 | + BOOL bResult; | |
| 274 | + | |
| 275 | + //ピクセルフォーマット | |
| 276 | + static PIXELFORMATDESCRIPTOR pfd = { | |
| 277 | + sizeof (PIXELFORMATDESCRIPTOR), | |
| 278 | + 1, | |
| 279 | + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, | |
| 280 | + PFD_TYPE_RGBA, | |
| 281 | + 24, | |
| 282 | + 0, 0, 0, | |
| 283 | + 0, 0, 0, | |
| 284 | + 0, 0, | |
| 285 | + 0, 0, 0, 0, 0, | |
| 286 | + 32, | |
| 287 | + 0, | |
| 288 | + 0, | |
| 289 | + PFD_MAIN_PLANE, | |
| 290 | + 0, | |
| 291 | + 0, | |
| 292 | + 0, | |
| 293 | + 0 | |
| 294 | + }; | |
| 295 | + | |
| 296 | + //デバイスコンテキスト取得 | |
| 297 | + hDC = GetDC(hWnd); | |
| 298 | + | |
| 299 | + //ピクセルフォーマットを取得 | |
| 300 | + pfdID = ChoosePixelFormat(hDC, &pfd); | |
| 301 | + if( pfdID == 0 ){ return 1; } | |
| 302 | + | |
| 303 | + //ピクセルフォーマットを指定 | |
| 304 | + bResult = SetPixelFormat(hDC, pfdID, &pfd); | |
| 305 | + if( bResult == FALSE ){ return 1; } | |
| 306 | + | |
| 307 | + //コンテキストを指定 | |
| 308 | + hGLRC = wglCreateContext(hDC); | |
| 309 | + if( hGLRC == NULL ){ return 1; } | |
| 310 | + | |
| 311 | + //デバイスコンテキスト解放 | |
| 312 | + ReleaseDC(hWnd, hDC); | |
| 313 | + | |
| 314 | + //システムフォント用意 | |
| 315 | + //フォント名:MS ゴシック サイズ:18 | |
| 316 | + SystemFont = CreateFont(18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "MS ゴシック"); | |
| 317 | + | |
| 224 | 318 | #ifdef ENABLE_DEBUGLOG |
| 225 | 319 | //ログに出力 |
| 226 | - OutputLog.WriteLog(LOG_ERROR, "", ""); | |
| 320 | + OutputLog.WriteLog(LOG_COMPLETE, "", ""); | |
| 227 | 321 | #endif |
| 228 | 322 | |
| 229 | - return 2; | |
| 323 | + //テクスチャフォント用画像を取得 | |
| 324 | + TextureFont = LoadTexture(TextureFontFname, true, false); | |
| 325 | + | |
| 326 | +#ifdef ENABLE_DEBUGCONSOLE | |
| 327 | + if( LoadDebugFontTexture() == false ){ | |
| 328 | + return 1; | |
| 329 | + } | |
| 330 | +#endif | |
| 331 | + | |
| 332 | + return 0; | |
| 230 | 333 | } |
| 231 | 334 | |
| 232 | 335 | //! @brief 解放 |
| @@ -235,6 +338,37 @@ | ||
| 235 | 338 | { |
| 236 | 339 | if( hGLRC == NULL ){ return; } |
| 237 | 340 | |
| 341 | + CleanupD3Dresource(); | |
| 342 | + | |
| 343 | + if( hGLRC != NULL ){ | |
| 344 | + wglDeleteContext(hGLRC); | |
| 345 | + hGLRC = NULL; | |
| 346 | + } | |
| 347 | + | |
| 348 | +#ifdef ENABLE_DEBUGLOG | |
| 349 | + //ログに出力 | |
| 350 | + OutputLog.WriteLog(LOG_CLEANUP, "グラフィック", "OpenGL"); | |
| 351 | +#endif | |
| 352 | + | |
| 353 | + //libjpeg解放 | |
| 354 | + jpeg_destroy_decompress(&cinfo); | |
| 355 | +} | |
| 356 | + | |
| 357 | +//! @brief デバイスのリソースを解放 | |
| 358 | +void D3DGraphics::CleanupD3Dresource() | |
| 359 | +{ | |
| 360 | + if( TextureFont != -1 ){ | |
| 361 | + CleanupTexture(TextureFont); | |
| 362 | + TextureFont = -1; | |
| 363 | + } | |
| 364 | + | |
| 365 | +#ifdef ENABLE_DEBUGCONSOLE | |
| 366 | + if( TextureDebugFont != -1 ){ | |
| 367 | + CleanupTexture(TextureDebugFont); | |
| 368 | + TextureDebugFont = -1; | |
| 369 | + } | |
| 370 | +#endif | |
| 371 | + | |
| 238 | 372 | for(int i=0; i<MAX_MODEL; i++){ |
| 239 | 373 | CleanupModel(i); |
| 240 | 374 | } |
| @@ -254,19 +388,6 @@ | ||
| 254 | 388 | glDeleteLists(SystemFontListIdx, SystemFontListIdxSize); |
| 255 | 389 | SystemFontListIdx = 0; |
| 256 | 390 | } |
| 257 | - | |
| 258 | - if( hGLRC != NULL ){ | |
| 259 | - wglDeleteContext(hGLRC); | |
| 260 | - hGLRC = NULL; | |
| 261 | - } | |
| 262 | - | |
| 263 | -#ifdef ENABLE_DEBUGLOG | |
| 264 | - //ログに出力 | |
| 265 | - OutputLog.WriteLog(LOG_CLEANUP, "グラフィック", "OpenGL"); | |
| 266 | -#endif | |
| 267 | - | |
| 268 | - //libjpeg解放 | |
| 269 | - jpeg_destroy_decompress(&cinfo); | |
| 270 | 391 | } |
| 271 | 392 | |
| 272 | 393 | //! @brief モデルファイルを読み込む(.x) |
| @@ -207,6 +207,7 @@ | ||
| 207 | 207 | HGLRC hGLRC; //!< OpenGLのコンテキスト |
| 208 | 208 | int width; //!< 幅 |
| 209 | 209 | int height; //!< 高さ |
| 210 | + bool fullscreenflag; //!< フルスクリーン表示 | |
| 210 | 211 | PAINTSTRUCT Paint_ps; //!< BeginPaint()関数とEndPaint()関数用 |
| 211 | 212 | MODELDATA pmodel[MAX_MODEL]; //!< モデルデータを格納 |
| 212 | 213 | TEXTUREDATA ptextures[MAX_TEXTURE]; //!< テクスチャを格納 |
| @@ -239,6 +240,7 @@ | ||
| 239 | 240 | jpeg_decompress_struct cinfo; //!< libjpeg |
| 240 | 241 | jpeg_error_mgr jerr; //!< libjpeg |
| 241 | 242 | |
| 243 | + void CleanupD3Dresource(); | |
| 242 | 244 | int CheckFileExtension(char* filename, int nowformat); |
| 243 | 245 | int CheckFileTypeFlag(char* filename, int nowformat); |
| 244 | 246 | bool LoadBMPTexture(char* filename, bool BlackTransparent, TEXTUREDATA *ptexture); |
| @@ -262,6 +264,8 @@ | ||
| 262 | 264 | public: |
| 263 | 265 | D3DGraphics(); |
| 264 | 266 | ~D3DGraphics(); |
| 267 | + void SetFullScreenFlag(bool fullscreen); | |
| 268 | + bool GetFullScreenFlag(); | |
| 265 | 269 | int InitD3D(WindowControl *WindowCtrl, char *TextureFontFilename, bool fullscreen); |
| 266 | 270 | int ResetD3D(WindowControl *WindowCtrl); |
| 267 | 271 | void DestroyD3D(); |
| @@ -532,14 +532,17 @@ | ||
| 532 | 532 | mainmenu_mouseY = SCREEN_HEIGHT/2; |
| 533 | 533 | |
| 534 | 534 | //標準ミッションのスクロールバーの設定 |
| 535 | - if( TOTAL_OFFICIALMISSION > TOTAL_MENUITEMS ){ | |
| 535 | +#if TOTAL_OFFICIALMISSION > TOTAL_MENUITEMS | |
| 536 | + //if( TOTAL_OFFICIALMISSION > TOTAL_MENUITEMS ){ | |
| 536 | 537 | mainmenu_scrollbar_official_height = (float)(MAINMENU_H-25) / TOTAL_OFFICIALMISSION * TOTAL_MENUITEMS; |
| 537 | 538 | mainmenu_scrollbar_official_scale = ((float)(MAINMENU_H-25) - mainmenu_scrollbar_official_height) / (TOTAL_OFFICIALMISSION - TOTAL_MENUITEMS); |
| 538 | - } | |
| 539 | - else{ | |
| 539 | + //} | |
| 540 | +#else | |
| 541 | + //else{ | |
| 540 | 542 | mainmenu_scrollbar_official_height = 0.0f; |
| 541 | 543 | mainmenu_scrollbar_official_scale = 0.0f; |
| 542 | - } | |
| 544 | + //} | |
| 545 | +#endif | |
| 543 | 546 | |
| 544 | 547 | //addonのスクロールバーの設定 |
| 545 | 548 | if( GameAddon.GetTotaldatas() > TOTAL_MENUITEMS ){ |
| @@ -2165,13 +2168,9 @@ | ||
| 2165 | 2168 | } |
| 2166 | 2169 | |
| 2167 | 2170 | //ゲーム実行速度の表示 |
| 2168 | - if( 1 ){ | |
| 2169 | - sprintf(str, "fps:%.2f", fps); | |
| 2170 | - } | |
| 2171 | - else{ | |
| 2172 | - int speed = (int)(fps / (1000.0f/GAMEFRAMEMS) * 100); | |
| 2173 | - sprintf(str, "PROCESSING SPEED %d%%", speed); | |
| 2174 | - } | |
| 2171 | + //int speed = (int)(fps / (1000.0f/GAMEFRAMEMS) * 100); | |
| 2172 | + //sprintf(str, "PROCESSING SPEED %d%%", speed); | |
| 2173 | + sprintf(str, "fps:%.2f", fps); | |
| 2175 | 2174 | d3dg->Draw2DTextureFontText(SCREEN_WIDTH - strlen(str)*14 - 14 +1, 10+1, str, d3dg->GetColorCode(0.0f,0.0f,0.0f,1.0f), 14, 18); |
| 2176 | 2175 | d3dg->Draw2DTextureFontText(SCREEN_WIDTH - strlen(str)*14 - 14, 10, str, d3dg->GetColorCode(1.0f,0.5f,0.0f,1.0f), 14, 18); |
| 2177 | 2176 |
| @@ -2778,7 +2777,7 @@ | ||
| 2778 | 2777 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "ff revive kill <NUM> treat <NUM> nodamage <NUM>"); |
| 2779 | 2778 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "break <NUM> newobj <NUM>"); |
| 2780 | 2779 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "bot nofight caution stop estop speed"); |
| 2781 | - AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "ss clear"); | |
| 2780 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "window ss clear exit"); | |
| 2782 | 2781 | } |
| 2783 | 2782 | |
| 2784 | 2783 | //人の統計情報 |
| @@ -3359,6 +3358,37 @@ | ||
| 3359 | 3358 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), str); |
| 3360 | 3359 | } |
| 3361 | 3360 | |
| 3361 | + //ウィンドウ・フルスクリーン切り替え | |
| 3362 | + if( strcmp(NewCommand, "window") == 0 ){ | |
| 3363 | + //現在の表示モード取得 | |
| 3364 | + bool flag = d3dg->GetFullScreenFlag(); | |
| 3365 | + | |
| 3366 | + if( flag == false ){ flag = true; } | |
| 3367 | + else{ flag = false; } | |
| 3368 | + | |
| 3369 | + //切り替え処理 | |
| 3370 | + WindowCtrl->ChangeWindowMode(flag); | |
| 3371 | + d3dg->SetFullScreenFlag(flag); | |
| 3372 | + if( ResetGame(WindowCtrl) != 0 ){ | |
| 3373 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "[Error] Change failed."); | |
| 3374 | + } | |
| 3375 | + else{ | |
| 3376 | + Recovery(); | |
| 3377 | + | |
| 3378 | + //キー入力を取得 | |
| 3379 | + // ※ディスプレイ解像度の変化によるマウスの移動分を捨てる | |
| 3380 | + inputCtrl->GetInputState(true); | |
| 3381 | + inputCtrl->MoveMouseCenter(); | |
| 3382 | + | |
| 3383 | + if( flag == true ){ | |
| 3384 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "Changed FullScreen mode."); | |
| 3385 | + } | |
| 3386 | + else{ | |
| 3387 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "Changed Window mode."); | |
| 3388 | + } | |
| 3389 | + } | |
| 3390 | + } | |
| 3391 | + | |
| 3362 | 3392 | //スクリーンショットを撮影 |
| 3363 | 3393 | // ※コンソール画面を削除するため、撮影を1フレーム遅らせる。 |
| 3364 | 3394 | if( ScreenShot == 2 ){ |
| @@ -3393,6 +3423,12 @@ | ||
| 3393 | 3423 | } |
| 3394 | 3424 | } |
| 3395 | 3425 | |
| 3426 | + //コンソールを閉じる | |
| 3427 | + if( strcmp(NewCommand, "exit") == 0 ){ | |
| 3428 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "Closed debug console."); | |
| 3429 | + Show_Console = false; | |
| 3430 | + } | |
| 3431 | + | |
| 3396 | 3432 | #ifdef _DEBUG |
| 3397 | 3433 | //リセット操作 |
| 3398 | 3434 | if( strcmp(NewCommand, "f12") == 0 ){ |
| @@ -3505,13 +3541,13 @@ | ||
| 3505 | 3541 | } |
| 3506 | 3542 | |
| 3507 | 3543 | //! @brief screen派生クラスの初期化(クラスの設定) |
| 3508 | -void InitScreen(opening *Opening, mainmenu *MainMenu, briefing *Briefing, maingame *MainGame, result *Result) | |
| 3544 | +void InitScreen(WindowControl *WindowCtrl, opening *Opening, mainmenu *MainMenu, briefing *Briefing, maingame *MainGame, result *Result) | |
| 3509 | 3545 | { |
| 3510 | - Opening->SetClass(&GameState, &d3dg, &inputCtrl, &GameSound); | |
| 3511 | - MainMenu->SetClass(&GameState, &d3dg, &inputCtrl, &GameSound); | |
| 3512 | - Briefing->SetClass(&GameState, &d3dg, &inputCtrl); | |
| 3513 | - MainGame->SetClass(&GameState, &d3dg, &inputCtrl, &GameSound); | |
| 3514 | - Result->SetClass(&GameState, &d3dg, &inputCtrl); | |
| 3546 | + Opening->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl, &GameSound); | |
| 3547 | + MainMenu->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl, &GameSound); | |
| 3548 | + Briefing->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl); | |
| 3549 | + MainGame->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl, &GameSound); | |
| 3550 | + Result->SetClass(&GameState, WindowCtrl, &d3dg, &inputCtrl); | |
| 3515 | 3551 | } |
| 3516 | 3552 | |
| 3517 | 3553 | //! @brief screen派生クラスの実行 |
| @@ -243,7 +243,7 @@ | ||
| 243 | 243 | ~result(); |
| 244 | 244 | }; |
| 245 | 245 | |
| 246 | -void InitScreen(opening *Opening, mainmenu *MainMenu, briefing *Briefing, maingame *MainGame, result *Result); | |
| 246 | +void InitScreen(WindowControl *WindowCtrl, opening *Opening, mainmenu *MainMenu, briefing *Briefing, maingame *MainGame, result *Result); | |
| 247 | 247 | void ProcessScreen(WindowControl *WindowCtrl, opening *Opening, mainmenu *MainMenu, briefing *Briefing, maingame *MainGame, result *Result, unsigned int framecnt); |
| 248 | 248 | |
| 249 | 249 | #endif |
| \ No newline at end of file |
| @@ -119,7 +119,7 @@ | ||
| 119 | 119 | briefing Briefing; |
| 120 | 120 | maingame MainGame; |
| 121 | 121 | result Result; |
| 122 | - InitScreen(&Opening, &MainMenu, &Briefing, &MainGame, &Result); | |
| 122 | + InitScreen(&MainWindow, &Opening, &MainMenu, &Briefing, &MainGame, &Result); | |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | #ifdef ENABLE_DEBUGLOG |
| @@ -34,6 +34,7 @@ | ||
| 34 | 34 | //! @brief コンストラクタ |
| 35 | 35 | scene::scene() |
| 36 | 36 | { |
| 37 | + WindowCtrl = NULL; | |
| 37 | 38 | d3dg = NULL; |
| 38 | 39 | inputCtrl = NULL; |
| 39 | 40 | framecnt = 0; |
| @@ -44,9 +45,10 @@ | ||
| 44 | 45 | {} |
| 45 | 46 | |
| 46 | 47 | //! @brief クラスを設定 |
| 47 | -void scene::SetClass(StateMachine *in_GameState, D3DGraphics *in_d3dg, InputControl *in_inputCtrl) | |
| 48 | +void scene::SetClass(StateMachine *in_GameState, WindowControl *in_WindowCtrl, D3DGraphics *in_d3dg, InputControl *in_inputCtrl) | |
| 48 | 49 | { |
| 49 | 50 | GameState = in_GameState; |
| 51 | + WindowCtrl = in_WindowCtrl; | |
| 50 | 52 | d3dg = in_d3dg; |
| 51 | 53 | inputCtrl = in_inputCtrl; |
| 52 | 54 | } |
| @@ -219,9 +221,10 @@ | ||
| 219 | 221 | {} |
| 220 | 222 | |
| 221 | 223 | //! @brief 3Dシーンクラスを設定 |
| 222 | -void D3Dscene::SetClass(StateMachine *in_GameState, D3DGraphics *in_d3dg, InputControl *in_inputCtrl, SoundManager *in_GameSound) | |
| 224 | +void D3Dscene::SetClass(StateMachine *in_GameState, WindowControl *in_WindowCtrl, D3DGraphics *in_d3dg, InputControl *in_inputCtrl, SoundManager *in_GameSound) | |
| 223 | 225 | { |
| 224 | 226 | GameState = in_GameState; |
| 227 | + WindowCtrl = in_WindowCtrl; | |
| 225 | 228 | d3dg = in_d3dg; |
| 226 | 229 | inputCtrl = in_inputCtrl; |
| 227 | 230 | GameSound = in_GameSound; |
| @@ -40,15 +40,16 @@ | ||
| 40 | 40 | class scene |
| 41 | 41 | { |
| 42 | 42 | protected: |
| 43 | - class StateMachine *GameState; //!< ゲーム全体の状態遷移クラス | |
| 44 | - class D3DGraphics *d3dg; //!< 描画クラス | |
| 45 | - class InputControl *inputCtrl; //!< 入力取得クラス | |
| 46 | - unsigned int framecnt; //!< フレーム数のカウント | |
| 43 | + class StateMachine *GameState; //!< ゲーム全体の状態遷移クラス | |
| 44 | + class WindowControl *WindowCtrl; //!< ウィンドウ制御クラス | |
| 45 | + class D3DGraphics *d3dg; //!< 描画クラス | |
| 46 | + class InputControl *inputCtrl; //!< 入力取得クラス | |
| 47 | + unsigned int framecnt; //!< フレーム数のカウント | |
| 47 | 48 | |
| 48 | 49 | public: |
| 49 | 50 | scene(); |
| 50 | 51 | ~scene(); |
| 51 | - virtual void SetClass(StateMachine *in_GameState, D3DGraphics *in_d3dg, InputControl *in_inputCtrl); | |
| 52 | + virtual void SetClass(StateMachine *in_GameState, WindowControl *in_WindowCtrl, D3DGraphics *in_d3dg, InputControl *in_inputCtrl); | |
| 52 | 53 | virtual int Create(); |
| 53 | 54 | virtual int Recovery(); |
| 54 | 55 | virtual void Input(); |
| @@ -93,7 +94,7 @@ | ||
| 93 | 94 | public: |
| 94 | 95 | D3Dscene(); |
| 95 | 96 | ~D3Dscene(); |
| 96 | - virtual void SetClass(StateMachine *in_GameState, D3DGraphics *in_d3dg, InputControl *in_inputCtrl, SoundManager *in_GameSound); | |
| 97 | + virtual void SetClass(StateMachine *in_GameState, WindowControl *in_WindowCtrl, D3DGraphics *in_d3dg, InputControl *in_inputCtrl, SoundManager *in_GameSound); | |
| 97 | 98 | virtual void Process(); |
| 98 | 99 | virtual void Sound(); |
| 99 | 100 | virtual bool RenderMain(); |
| @@ -135,6 +135,41 @@ | ||
| 135 | 135 | return DefWindowProc(hWnd, msg, wParam, lParam); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | +//! @brief ウィンドウの表示モード切り替え | |
| 139 | +//! @param fullscreen false:ウィンドウ表示 true:フルスクリーン用表示 | |
| 140 | +//! @return 成功:true 失敗:false | |
| 141 | +bool WindowControl::ChangeWindowMode(bool fullscreen) | |
| 142 | +{ | |
| 143 | + if( hWnd == NULL ){ return false; } | |
| 144 | + | |
| 145 | + DWORD dwStyle; | |
| 146 | + RECT Rect; | |
| 147 | + int width, height; | |
| 148 | + | |
| 149 | + //ウィンドウサイズを取得 | |
| 150 | + GetClientRect(hWnd, &Rect); | |
| 151 | + | |
| 152 | + if( fullscreen == false ){ | |
| 153 | + ChangeDisplaySettings(NULL, 0); //ディスプレイ解像度を戻す | |
| 154 | + | |
| 155 | + dwStyle = WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX; | |
| 156 | + } | |
| 157 | + else{ | |
| 158 | + dwStyle = WS_POPUP; | |
| 159 | + } | |
| 160 | + | |
| 161 | + //ウィンドウサイズを計算 | |
| 162 | + AdjustWindowRect(&Rect, dwStyle, FALSE); | |
| 163 | + width = Rect.right - Rect.left; | |
| 164 | + height = Rect.bottom - Rect.top; | |
| 165 | + | |
| 166 | + //反映 | |
| 167 | + SetWindowLong(hWnd, GWL_STYLE, dwStyle); | |
| 168 | + SetWindowPos(hWnd, NULL, 0, 0, width, height, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW); | |
| 169 | + | |
| 170 | + return true; | |
| 171 | +} | |
| 172 | + | |
| 138 | 173 | //! @brief ウィンドウハンドルを取得 |
| 139 | 174 | //! @return ウィンドウハンドル |
| 140 | 175 | HWND WindowControl::GethWnd() |
| @@ -60,6 +60,7 @@ | ||
| 60 | 60 | ~WindowControl(); |
| 61 | 61 | void SetParam(HINSTANCE in_hInstance, int in_nCmdShow); |
| 62 | 62 | bool InitWindow(char* title, int width, int height, bool fullscreen); |
| 63 | + bool ChangeWindowMode(bool fullscreen); | |
| 63 | 64 | HWND GethWnd(); |
| 64 | 65 | int CheckMainLoop(); |
| 65 | 66 | void ErrorInfo(char *str); |