mirror of
https://github.com/ZDoom/Raze.git
synced 2025-06-02 02:01:31 +00:00
- backend update from GZDoom.
This commit is contained in:
parent
5b6aa372ea
commit
c96e04e6c9
28 changed files with 352 additions and 119 deletions
|
@ -45,9 +45,9 @@
|
|||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include "x86.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "cmdlib.h"
|
||||
|
@ -57,6 +57,7 @@
|
|||
#include "v_font.h"
|
||||
#include "c_cvars.h"
|
||||
#include "palutil.h"
|
||||
#include "st_start.h"
|
||||
|
||||
|
||||
#ifndef NO_GTK
|
||||
|
@ -71,6 +72,8 @@ double PerfToSec, PerfToMillisec;
|
|||
CVAR(Bool, con_printansi, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE);
|
||||
CVAR(Bool, con_4bitansi, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE);
|
||||
|
||||
extern FStartupScreen *StartScreen;
|
||||
|
||||
void I_SetIWADInfo()
|
||||
{
|
||||
}
|
||||
|
@ -132,6 +135,42 @@ void CalculateCPUSpeed()
|
|||
{
|
||||
}
|
||||
|
||||
void CleanProgressBar()
|
||||
{
|
||||
if (!isatty(STDOUT_FILENO)) return;
|
||||
struct winsize sizeOfWindow;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &sizeOfWindow);
|
||||
fprintf(stdout,"\0337\033[%d;%dH\033[0J\0338",sizeOfWindow.ws_row, 0);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static int ProgressBarCurPos, ProgressBarMaxPos;
|
||||
|
||||
void RedrawProgressBar(int CurPos, int MaxPos)
|
||||
{
|
||||
if (!isatty(STDOUT_FILENO)) return;
|
||||
CleanProgressBar();
|
||||
struct winsize sizeOfWindow;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &sizeOfWindow);
|
||||
double progVal = std::clamp((double)CurPos / (double)MaxPos,0.0,1.0);
|
||||
int curProgVal = std::clamp(int(sizeOfWindow.ws_col * progVal),0,(int)sizeOfWindow.ws_col);
|
||||
|
||||
char progressBuffer[512];
|
||||
memset(progressBuffer,'.',512);
|
||||
progressBuffer[sizeOfWindow.ws_col - 1] = 0;
|
||||
int lengthOfStr = 0;
|
||||
|
||||
while (curProgVal-- > 0)
|
||||
{
|
||||
progressBuffer[lengthOfStr++] = '=';
|
||||
if (lengthOfStr >= sizeOfWindow.ws_col - 1) break;
|
||||
}
|
||||
fprintf(stdout, "\0337\033[%d;%dH\033[2K[%s\033[%d;%dH]\0338", sizeOfWindow.ws_row, 0, progressBuffer, sizeOfWindow.ws_row, sizeOfWindow.ws_col);
|
||||
fflush(stdout);
|
||||
ProgressBarCurPos = CurPos;
|
||||
ProgressBarMaxPos = MaxPos;
|
||||
}
|
||||
|
||||
void I_PrintStr(const char *cp)
|
||||
{
|
||||
const char * srcp = cp;
|
||||
|
@ -183,8 +222,10 @@ void I_PrintStr(const char *cp)
|
|||
}
|
||||
}
|
||||
|
||||
if (StartScreen) CleanProgressBar();
|
||||
fputs(printData.GetChars(),stdout);
|
||||
fputs("\033[0m",stdout);
|
||||
if (StartScreen) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos);
|
||||
}
|
||||
|
||||
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue