- trying to fix issue #71 alt-enter toggle

This commit is contained in:
SoftCoder 2015-10-28 16:07:15 -07:00
parent 8499d25bde
commit d5edf6f973
6 changed files with 70 additions and 10 deletions

View File

@ -826,6 +826,31 @@ MainWindow::~MainWindow(){
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
int MainWindow::getDesiredScreenWidth() {
Config &config= Config::getInstance();
return config.getInt("ScreenWidth");
}
int MainWindow::getDesiredScreenHeight() {
Config &config= Config::getInstance();
return config.getInt("ScreenHeight");
}
void MainWindow::eventToggleFullScreen(bool isFullscreen) {
WindowGl::eventToggleFullScreen(isFullscreen);
if(isFullscreen) {
Metrics::reload(this->program->getWindow()->getScreenWidth(),
this->program->getWindow()->getScreenHeight());
}
else {
Config &config= Config::getInstance();
Metrics::reload(config.getInt("ScreenWidth"),config.getInt("ScreenHeight"));
//window->setText(config.getString("WindowTitle","MegaGlest"));
//this->mainMenu->init();
}
}
void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
const Metrics &metrics = Metrics::getInstance();
int vx = metrics.toVirtualX(x);

View File

@ -62,6 +62,11 @@ public:
bool getTriggerLanguageToggle() const { return triggerLanguageToggle; }
string getTriggerLanguage() const { return triggerLanguage; }
virtual int getDesiredScreenWidth();
virtual int getDesiredScreenHeight();
protected:
virtual void eventToggleFullScreen(bool isFullscreen);
};
}}//end namespace

View File

@ -213,6 +213,7 @@ protected:
virtual void eventMenu(int menuId) {}
virtual void eventClose() {};
virtual void eventDestroy() {};
virtual void eventToggleFullScreen(bool isFullscreen) {};
private:
/// needed to detect double clicks

View File

@ -45,11 +45,16 @@ public:
SDL_Surface * getScreenSurface();
virtual int getScreenWidth();
virtual int getScreenHeight();
virtual int getDesiredScreenWidth() { return getScreenWidth(); }
virtual int getDesiredScreenHeight() { return getScreenHeight(); }
virtual bool ChangeVideoMode(bool preserveContext, int resWidth, int resHeight,
bool fullscreenWindow, int colorBits, int depthBits, int stencilBits,
bool hardware_acceleration, bool fullscreen_anti_aliasing,
float gammaValue);
protected:
virtual void eventToggleFullScreen(bool isFullscreen);
};
}}//end namespace

View File

@ -617,16 +617,8 @@ void Window::toggleFullscreen() {
Window::isFullScreen = !Window::isFullScreen;
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
//SDL_Surface *cur_surface = SDL_GetVideoSurface();
if(sdlWindow != NULL) {
if(isFullScreen){
SDL_SetWindowFullscreen(sdlWindow,SDL_WINDOW_FULLSCREEN);
}
else {
SDL_SetWindowFullscreen(sdlWindow,0);
}
}
if(global_window) {
global_window->eventToggleFullScreen(Window::isFullScreen);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);

View File

@ -96,6 +96,38 @@ void WindowGl::swapBuffersGl(){
context.swapBuffers();
}
void WindowGl::eventToggleFullScreen(bool isFullscreen) {
Window::eventToggleFullScreen(isFullscreen);
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
//SDL_Surface *cur_surface = SDL_GetVideoSurface();
if(getScreenWindow() != NULL) {
if(getIsFullScreen()){
SDL_SetWindowFullscreen(getScreenWindow(),SDL_WINDOW_FULLSCREEN_DESKTOP);
}
else {
SDL_SetWindowFullscreen(getScreenWindow(),0);
}
}
if(isFullscreen) {
changeVideoModeFullScreen(isFullscreen);
ChangeVideoMode(true, getScreenWidth(), getScreenHeight(),
true,context.getColorBits(), context.getDepthBits(), context.getStencilBits(),
context.getHardware_acceleration(),context.getFullscreen_anti_aliasing(),
context.getGammaValue());
}
else {
changeVideoModeFullScreen(false);
ChangeVideoMode(true, getDesiredScreenWidth(), getDesiredScreenHeight(),
false,context.getColorBits(), context.getDepthBits(), context.getStencilBits(),
context.getHardware_acceleration(),context.getFullscreen_anti_aliasing(),
context.getGammaValue());
}
}
}
// changes display resolution at any time
bool WindowGl::ChangeVideoMode(bool preserveContext, int resWidth, int resHeight,
bool fullscreenWindow,