|
5 | 5 |
|
6 | 6 | #include "CGame.h" |
7 | 7 | #include "CIO/CFile.h" |
| 8 | +#include "CIO/CMenu.h" |
| 9 | +#include "CIO/CWindow.h" |
8 | 10 | #include "CMap.h" |
9 | 11 | #include "CSurface.h" |
10 | 12 | #include "SGE/sge_blib.h" |
|
17 | 19 |
|
18 | 20 | bool CGame::ReCreateWindow() |
19 | 21 | { |
| 22 | + suppressResizeEvents_ = 3; |
20 | 23 | displayTexture_.reset(); |
21 | 24 | renderer_.reset(); |
22 | 25 | window_.reset(); |
23 | 26 | window_.reset(SDL_CreateWindow("Return to the Roots Map editor [BETA]", SDL_WINDOWPOS_CENTERED, |
24 | 27 | SDL_WINDOWPOS_CENTERED, GameResolution.x, GameResolution.y, |
25 | | - fullscreen ? SDL_WINDOW_FULLSCREEN : 0)); |
| 28 | + fullscreen ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE)); |
26 | 29 | if(!window_) |
27 | 30 | return false; |
28 | 31 | renderer_.reset(SDL_CreateRenderer(window_.get(), -1, 0)); |
29 | 32 | if(!renderer_) |
30 | 33 | return false; |
31 | | - displayTexture_ = makeSdlTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, GameResolution.x, |
32 | | - GameResolution.y); |
33 | | - Surf_Display = makeRGBSurface(GameResolution.x, GameResolution.y, true); |
| 34 | + RecreateDisplayResources(); |
34 | 35 | if(!displayTexture_ || !Surf_Display) |
35 | 36 | return false; |
36 | 37 |
|
37 | 38 | SetAppIcon(); |
38 | 39 | return true; |
39 | 40 | } |
40 | 41 |
|
| 42 | +void CGame::RecreateDisplayResources() |
| 43 | +{ |
| 44 | + displayTexture_.reset(); |
| 45 | + displayTexture_ = makeSdlTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, GameResolution.x, |
| 46 | + GameResolution.y); |
| 47 | + Surf_Display = makeRGBSurface(GameResolution.x, GameResolution.y, true); |
| 48 | +} |
| 49 | + |
| 50 | +void CGame::UpdateDisplaySize(const Extent& newSize) |
| 51 | +{ |
| 52 | + GameResolution = newSize; |
| 53 | + RecreateDisplayResources(); |
| 54 | + for(auto& menu : Menus) |
| 55 | + menu->resetSurface(); |
| 56 | + for(auto& wnd : Windows) |
| 57 | + wnd->resetSurface(); |
| 58 | +} |
| 59 | + |
41 | 60 | bool CGame::Init() |
42 | 61 | { |
43 | 62 | std::cout << "Return to the Roots Map editor\n"; |
|
0 commit comments