Implemented fullscreen toggle and window window repositioning and resizing. Release Build 7357.
This commit is contained in:
parent
d5bd8655a9
commit
0408250088
@ -233,8 +233,10 @@ const void SaveFile::SaveGame(){
|
|||||||
|
|
||||||
void SaveFile::LoadFile(){
|
void SaveFile::LoadFile(){
|
||||||
utils::datafile loadFile;
|
utils::datafile loadFile;
|
||||||
|
utils::datafile loadSystemFile;
|
||||||
|
|
||||||
std::string loadFilename="save_file_path"_S+std::format("save.{:04}",saveFileID);
|
std::string loadFilename="save_file_path"_S+std::format("save.{:04}",saveFileID);
|
||||||
|
std::string loadSystemFilename="save_file_path"_S+"system.conf";
|
||||||
|
|
||||||
if(std::filesystem::exists(loadFilename)){
|
if(std::filesystem::exists(loadFilename)){
|
||||||
utils::datafile::Read(loadFile,"save_file_path"_S+std::format("save.{:04}",saveFileID));
|
utils::datafile::Read(loadFile,"save_file_path"_S+std::format("save.{:04}",saveFileID));
|
||||||
@ -287,7 +289,7 @@ void SaveFile::LoadFile(){
|
|||||||
if(loadFile.HasProperty("Controller Rumble"))GameSettings::SetRumble(loadFile["Controller Rumble"].GetBool());
|
if(loadFile.HasProperty("Controller Rumble"))GameSettings::SetRumble(loadFile["Controller Rumble"].GetBool());
|
||||||
if(loadFile.HasProperty("Terrain Collision Boxes"))GameSettings::SetTerrainCollisionBoxes(loadFile["Terrain Collision Boxes"].GetBool());
|
if(loadFile.HasProperty("Terrain Collision Boxes"))GameSettings::SetTerrainCollisionBoxes(loadFile["Terrain Collision Boxes"].GetBool());
|
||||||
if(loadFile.HasProperty("Keyboard Auto-Aim"))GameSettings::SetKeyboardAutoAim(loadFile["Keyboard Auto-Aim"].GetBool());
|
if(loadFile.HasProperty("Keyboard Auto-Aim"))GameSettings::SetKeyboardAutoAim(loadFile["Keyboard Auto-Aim"].GetBool());
|
||||||
if(loadFile.HasProperty("Fullscreen"))game->SetFullScreen(loadFile["Fullscreen"].GetBool());
|
if(loadFile.HasProperty("Fullscreen"))game->SetFullscreen(loadFile["Fullscreen"].GetBool(),{});
|
||||||
|
|
||||||
#pragma region Load Keyboard/Controller mappings
|
#pragma region Load Keyboard/Controller mappings
|
||||||
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
|
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
|
||||||
@ -329,6 +331,14 @@ void SaveFile::LoadFile(){
|
|||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Load System Settings
|
||||||
|
if(std::filesystem::exists(loadSystemFilename)){
|
||||||
|
utils::datafile::Read(loadSystemFile,loadSystemFilename);
|
||||||
|
//if(loadSystemFile.HasProperty("Window Pos"))
|
||||||
|
//if(loadSystemFile.HasProperty("Window Size"))
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
GameState::ChangeState(States::OVERWORLD_MAP,0.5f);
|
GameState::ChangeState(States::OVERWORLD_MAP,0.5f);
|
||||||
}else{
|
}else{
|
||||||
std::cout<<std::format("WARNING! File {} does not exist for loading!","save_file_path"_S+std::format("save.{:04}",saveFileID))<<std::endl;
|
std::cout<<std::format("WARNING! File {} does not exist for loading!","save_file_path"_S+std::format("save.{:04}",saveFileID))<<std::endl;
|
||||||
|
@ -115,6 +115,7 @@ void Menu::InitializeSettingsWindow(){
|
|||||||
settingsWindow->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,104},{windowSize.x/2-24.f,16.f}},"Aim Assist\n(No Mouse Players)",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
|
settingsWindow->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,104},{windowSize.x/2-24.f,16.f}},"Aim Assist\n(No Mouse Players)",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
settingsWindow->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,124},{16.f,16.f}},[](ToggleFuncData data){
|
settingsWindow->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,124},{16.f,16.f}},[](ToggleFuncData data){
|
||||||
|
game->SetFullscreen(data.checked,{});
|
||||||
return true;
|
return true;
|
||||||
},false)END;
|
},false)END;
|
||||||
settingsWindow->ADD("Fullscreen Toggle Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,124},{windowSize.x/2-24.f,16.f}},"Fullscreen",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
|
settingsWindow->ADD("Fullscreen Toggle Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,124},{windowSize.x/2-24.f,16.f}},"Fullscreen",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
|
||||||
|
@ -53,6 +53,8 @@ void State_MainMenu::OnUserUpdate(AiL*game){
|
|||||||
if(AiL::KEY_CONFIRM.Released()){
|
if(AiL::KEY_CONFIRM.Released()){
|
||||||
TitleScreen::Skip();
|
TitleScreen::Skip();
|
||||||
}
|
}
|
||||||
|
if(game->GetKey(W).bPressed)game->SetWindowPos({5200,60});
|
||||||
|
if(game->GetKey(S).bPressed)game->SetWindowSize({400,400});
|
||||||
};
|
};
|
||||||
void State_MainMenu::Draw(AiL*game){
|
void State_MainMenu::Draw(AiL*game){
|
||||||
TitleScreen::Draw();
|
TitleScreen::Draw();
|
||||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 7344
|
#define VERSION_BUILD 7357
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -957,6 +957,9 @@ namespace olc
|
|||||||
virtual olc::rcode CreateGraphics(bool bFullScreen, bool bEnableVSYNC, const olc::vi2d& vViewPos, const olc::vi2d& vViewSize) = 0;
|
virtual olc::rcode CreateGraphics(bool bFullScreen, bool bEnableVSYNC, const olc::vi2d& vViewPos, const olc::vi2d& vViewSize) = 0;
|
||||||
virtual olc::rcode CreateWindowPane(const olc::vi2d& vWindowPos, olc::vi2d& vWindowSize, bool bFullScreen) = 0;
|
virtual olc::rcode CreateWindowPane(const olc::vi2d& vWindowPos, olc::vi2d& vWindowSize, bool bFullScreen) = 0;
|
||||||
virtual olc::rcode SetWindowTitle(const std::string& s) = 0;
|
virtual olc::rcode SetWindowTitle(const std::string& s) = 0;
|
||||||
|
virtual olc::rcode SetFullscreen(const bool bFullscreen, const vi2d windowPos = {})=0;
|
||||||
|
virtual void SetWindowPos(vi2d pos) = 0;
|
||||||
|
virtual void SetWindowSize(vi2d size) = 0;
|
||||||
virtual olc::rcode StartSystemEventLoop() = 0;
|
virtual olc::rcode StartSystemEventLoop() = 0;
|
||||||
virtual olc::rcode HandleSystemEvent() = 0;
|
virtual olc::rcode HandleSystemEvent() = 0;
|
||||||
virtual olc::rcode SendRequest(std::string_view url,std::string_view data){return olc::rcode::OK;};
|
virtual olc::rcode SendRequest(std::string_view url,std::string_view data){return olc::rcode::OK;};
|
||||||
@ -1068,11 +1071,13 @@ namespace olc
|
|||||||
// Gets "screen" size
|
// Gets "screen" size
|
||||||
const olc::vi2d& GetScreenSize() const;
|
const olc::vi2d& GetScreenSize() const;
|
||||||
const bool IsFullscreen()const;
|
const bool IsFullscreen()const;
|
||||||
void SetFullScreen(bool bFullscreen);
|
|
||||||
// Gets any files dropped this frame
|
// Gets any files dropped this frame
|
||||||
const std::vector<std::string>& GetDroppedFiles() const;
|
const std::vector<std::string>& GetDroppedFiles() const;
|
||||||
const olc::vi2d& GetDroppedFilesPoint() const;
|
const olc::vi2d& GetDroppedFilesPoint() const;
|
||||||
|
|
||||||
|
void SetWindowPos(vi2d pos);
|
||||||
|
void SetWindowSize(vi2d size);
|
||||||
|
|
||||||
public: // CONFIGURATION ROUTINES
|
public: // CONFIGURATION ROUTINES
|
||||||
// Layer targeting functions
|
// Layer targeting functions
|
||||||
void SetDrawTarget(uint8_t layer, bool bDirty = true);
|
void SetDrawTarget(uint8_t layer, bool bDirty = true);
|
||||||
@ -1098,7 +1103,7 @@ namespace olc
|
|||||||
// Change the blend factor from between 0.0f to 1.0f;
|
// Change the blend factor from between 0.0f to 1.0f;
|
||||||
void SetPixelBlend(float fBlend);
|
void SetPixelBlend(float fBlend);
|
||||||
|
|
||||||
|
void SetFullscreen(const bool bFullscreen, const vi2d windowPos = {});
|
||||||
|
|
||||||
public: // DRAWING ROUTINES
|
public: // DRAWING ROUTINES
|
||||||
// Draws a single Pixel
|
// Draws a single Pixel
|
||||||
@ -2274,10 +2279,6 @@ namespace olc
|
|||||||
return bFullScreen;
|
return bFullScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelGameEngine::SetFullScreen(bool bFullscreen){
|
|
||||||
//TODO: Implement fullscreen capabilities.
|
|
||||||
}
|
|
||||||
|
|
||||||
const olc::vi2d& PixelGameEngine::GetWindowMouse() const
|
const olc::vi2d& PixelGameEngine::GetWindowMouse() const
|
||||||
{ return vMouseWindowPos; }
|
{ return vMouseWindowPos; }
|
||||||
|
|
||||||
@ -4229,6 +4230,11 @@ namespace olc
|
|||||||
if (fBlendFactor > 1.0f) fBlendFactor = 1.0f;
|
if (fBlendFactor > 1.0f) fBlendFactor = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PixelGameEngine::SetFullscreen(const bool bFullscreen, const vi2d windowPos){
|
||||||
|
this->bFullScreen=bFullscreen;
|
||||||
|
platform->SetFullscreen(bFullscreen,windowPos);
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream& PixelGameEngine::ConsoleOut()
|
std::stringstream& PixelGameEngine::ConsoleOut()
|
||||||
{ return ssConsoleOutput; }
|
{ return ssConsoleOutput; }
|
||||||
|
|
||||||
@ -4331,6 +4337,12 @@ namespace olc
|
|||||||
const olc::vi2d& PixelGameEngine::GetDroppedFilesPoint() const
|
const olc::vi2d& PixelGameEngine::GetDroppedFilesPoint() const
|
||||||
{ return vDroppedFilesPoint; }
|
{ return vDroppedFilesPoint; }
|
||||||
|
|
||||||
|
void PixelGameEngine::SetWindowPos(vi2d pos){
|
||||||
|
platform->SetWindowPos(pos);
|
||||||
|
}
|
||||||
|
void PixelGameEngine::SetWindowSize(vi2d size){
|
||||||
|
platform->SetWindowSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
void PixelGameEngine::TextEntryEnable(const bool bEnable, const std::string& sText)
|
void PixelGameEngine::TextEntryEnable(const bool bEnable, const std::string& sText)
|
||||||
{
|
{
|
||||||
@ -6369,6 +6381,58 @@ namespace olc
|
|||||||
return olc::OK;
|
return olc::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual olc::rcode SetFullscreen(const bool bFullscreen,const vi2d windowPos)override{
|
||||||
|
// Define window furniture
|
||||||
|
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
||||||
|
DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME;
|
||||||
|
if (bFullscreen)
|
||||||
|
{
|
||||||
|
dwExStyle = 0;
|
||||||
|
dwStyle = WS_VISIBLE | WS_POPUP;
|
||||||
|
HMONITOR hmon = MonitorFromWindow(olc_hWnd, MONITOR_DEFAULTTONEAREST);
|
||||||
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
|
if (!GetMonitorInfo(hmon, &mi)) return olc::rcode::FAIL;
|
||||||
|
//AdjustWindowRectEx(&rWndRect, dwStyle, FALSE, dwExStyle);
|
||||||
|
SetWindowLongPtrA(olc_hWnd,GWL_EXSTYLE,dwExStyle);
|
||||||
|
SetWindowLongPtrA(olc_hWnd,GWL_STYLE,dwStyle);
|
||||||
|
MoveWindow(olc_hWnd,0,0,mi.rcMonitor.right,mi.rcMonitor.bottom,true);
|
||||||
|
}else{
|
||||||
|
RECT rWndRect = { 0, 0, ptrPGE->GetScreenSize().x*ptrPGE->GetPixelSize().x, ptrPGE->GetScreenSize().y*ptrPGE->GetPixelSize().y };
|
||||||
|
SetWindowLongPtrA(olc_hWnd,GWL_EXSTYLE,dwExStyle);
|
||||||
|
SetWindowLongPtrA(olc_hWnd,GWL_STYLE,dwStyle);
|
||||||
|
AdjustWindowRectEx(&rWndRect, dwStyle, FALSE, dwExStyle);
|
||||||
|
int width = rWndRect.right - rWndRect.left;
|
||||||
|
int height = rWndRect.bottom - rWndRect.top;
|
||||||
|
MoveWindow(olc_hWnd,windowPos.x, windowPos.y, width, height,true);
|
||||||
|
}
|
||||||
|
return olc::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void SetWindowPos(vi2d pos)override{
|
||||||
|
if(!ptrPGE->IsFullscreen()){
|
||||||
|
RECT rWndRect = { 0, 0, ptrPGE->GetWindowSize().x, ptrPGE->GetWindowSize().y };
|
||||||
|
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
||||||
|
DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME;
|
||||||
|
AdjustWindowRectEx(&rWndRect, dwStyle, FALSE, dwExStyle);
|
||||||
|
int width = rWndRect.right - rWndRect.left;
|
||||||
|
int height = rWndRect.bottom - rWndRect.top;
|
||||||
|
MoveWindow(olc_hWnd,pos.x, pos.y, width, height,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void SetWindowSize(vi2d size)override{
|
||||||
|
if(!ptrPGE->IsFullscreen()){
|
||||||
|
RECT rWndRect = { 0, 0, size.x, size.y };
|
||||||
|
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
||||||
|
DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME;
|
||||||
|
WINDOWPLACEMENT placement;
|
||||||
|
GetWindowPlacement(olc_hWnd,&placement);
|
||||||
|
int width = rWndRect.right - rWndRect.left;
|
||||||
|
int height = rWndRect.bottom - rWndRect.top;
|
||||||
|
MoveWindow(olc_hWnd,placement.rcNormalPosition.left, placement.rcNormalPosition.top, width*ptrPGE->GetPixelSize().x, height*ptrPGE->GetPixelSize().y,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual olc::rcode StartSystemEventLoop() override
|
virtual olc::rcode StartSystemEventLoop() override
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
@ -6639,6 +6703,35 @@ namespace olc
|
|||||||
return olc::OK;
|
return olc::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual olc::rcode SetFullscreen(const bool bFullscreen, const vi2d windowPos)override{
|
||||||
|
using namespace X11;
|
||||||
|
Atom wm_state;
|
||||||
|
Atom fullscreen;
|
||||||
|
wm_state = XInternAtom(olc_Display, "_NET_WM_STATE", False);
|
||||||
|
fullscreen = XInternAtom(olc_Display, "_NET_WM_STATE_FULLSCREEN", False);
|
||||||
|
XEvent xev{ 0 };
|
||||||
|
xev.type = ClientMessage;
|
||||||
|
xev.xclient.window = olc_Window;
|
||||||
|
xev.xclient.message_type = wm_state;
|
||||||
|
xev.xclient.format = 32;
|
||||||
|
xev.xclient.data.l[0] = bFullscreen?1:0; // the action (0: off, 1: on, 2: toggle)
|
||||||
|
xev.xclient.data.l[1] = fullscreen; // first property to alter
|
||||||
|
xev.xclient.data.l[2] = 0; // second property to alter
|
||||||
|
xev.xclient.data.l[3] = 0; // source indication
|
||||||
|
XMapWindow(olc_Display, olc_Window);
|
||||||
|
XSendEvent(olc_Display, DefaultRootWindow(olc_Display), False,
|
||||||
|
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
||||||
|
XFlush(olc_Display);
|
||||||
|
XWindowAttributes gwa;
|
||||||
|
XGetWindowAttributes(olc_Display, olc_Window, &gwa);
|
||||||
|
|
||||||
|
if(!bFullscreen){
|
||||||
|
XMoveWindow(olc_Display, olc_Window, windowPos.x, windowPos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return olc::OK;
|
||||||
|
}
|
||||||
|
|
||||||
virtual olc::rcode StartSystemEventLoop() override
|
virtual olc::rcode StartSystemEventLoop() override
|
||||||
{
|
{
|
||||||
return olc::OK;
|
return olc::OK;
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user