From 0f69b2f47a87c58ea01c4a4ae4157b4ee92a9d89 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Wed, 20 Mar 2019 02:00:56 +0100 Subject: Added forced screen size and mute to cRender for testing --- src/cRender.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/cRender.cpp') diff --git a/src/cRender.cpp b/src/cRender.cpp index 71c4d76..3b4573a 100644 --- a/src/cRender.cpp +++ b/src/cRender.cpp @@ -15,6 +15,9 @@ cRender::cRender(char _backound, WORD _color, unsigned int _sx, unsigned int _sy lastFrameTime = 0; lastRenderTime = 0; + bMute = false; + bLockScreenSize = false; + #ifdef __linux__ //In Linux, setting Console size is not supported, so it gets Size of Console (Window) instead. wDefColor = _COL_DEFAULT; @@ -23,7 +26,7 @@ cRender::cRender(char _backound, WORD _color, unsigned int _sx, unsigned int _sy setAlternateBufferScreen(true); setConsoleCursor(false); - setBufferSize( getConsoleWindowSize() ); + //setBufferSize( getConsoleWindowSize() ); if(sizeX < _sx || sizeY < _sy) //Notify Program tha screen is too small for desired Size iLastError = _ERR_SCREEN_TOO_SMALL_; @@ -40,7 +43,7 @@ cRender::cRender(char _backound, WORD _color, unsigned int _sx, unsigned int _sy #endif //_WIN32 setConsoleEcho(false); - clear(true); //Init backround array + //clear(true); //Init backround array }//render() @@ -240,7 +243,9 @@ int cRender::render(void) int cbuf = sprintf(buffer,"\e[%u;%uH\e[%sm%c\e[0m", i + 1, o + 1, colorstr, cScreen[o][i]); // Position Color Origin is at 1,1 //int cbuf = sprintf(buffer,"\e[%u;%uH%c", i + 1, o + 1, cScreen[o][i]); - write (STDOUT_FILENO, buffer, cbuf); + + if(!bMute) + write (STDOUT_FILENO, buffer, cbuf); #endif //__linux__ } @@ -361,6 +366,9 @@ void cRender::setConsoleCursor(bool _enable) void cRender::setBufferSize(sPos _size) { + if(bLockScreenSize) + return; + if(_size.x == (int)sizeX && _size.y == (int)sizeY) return; @@ -481,3 +489,21 @@ void cRender::waitForFrametime() } + +void cRender::forceScreenSize(sPos _size) +{ + if(_size.x || _size.y) + { + setBufferSize(_size); + bLockScreenSize = true; + } + else + { + bLockScreenSize = false; + } +} + +void cRender::mute(bool _mute) +{ + bMute = _mute; +} -- cgit v1.2.3