mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
- added the ZDoom console and made all needed changes to get it compiled.
This commit is contained in:
parent
ffa16b2a53
commit
d943fe036d
17 changed files with 59482 additions and 150 deletions
|
@ -781,6 +781,8 @@ set (PCH_SOURCES
|
||||||
common/fonts/fontchars.cpp
|
common/fonts/fontchars.cpp
|
||||||
|
|
||||||
common/console/c_cvars.cpp
|
common/console/c_cvars.cpp
|
||||||
|
common/console/c_console.cpp
|
||||||
|
common/console/c_consolebuffer.cpp
|
||||||
common/console/c_bind.cpp
|
common/console/c_bind.cpp
|
||||||
common/console/c_buttons.cpp
|
common/console/c_buttons.cpp
|
||||||
common/console/c_commandline.cpp
|
common/console/c_commandline.cpp
|
||||||
|
|
|
@ -78,7 +78,7 @@ static VoiceNode VoicePool;
|
||||||
|
|
||||||
static int MV_MixPage;
|
static int MV_MixPage;
|
||||||
|
|
||||||
void (*MV_Printf)(const char *fmt, ...) = initprintf;
|
void (*MV_Printf)(const char *fmt, ...) = OSD_Printf;
|
||||||
static void (*MV_CallBackFunc)(intptr_t);
|
static void (*MV_CallBackFunc)(intptr_t);
|
||||||
|
|
||||||
char *MV_MixDestination;
|
char *MV_MixDestination;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
#include "inputstate.h"
|
#include "inputstate.h"
|
||||||
|
#include "printf.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUGGINGAIDS
|
#ifdef DEBUGGINGAIDS
|
||||||
|
@ -133,11 +134,6 @@ void uninitsystem(void);
|
||||||
void system_getcvars(void);
|
void system_getcvars(void);
|
||||||
|
|
||||||
extern int32_t g_logFlushWindow;
|
extern int32_t g_logFlushWindow;
|
||||||
void initputs(const char *);
|
|
||||||
#define buildputs initputs
|
|
||||||
void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2)));
|
|
||||||
#define buildprintf initprintf
|
|
||||||
void debugprintf(const char *,...) ATTRIBUTE((format(printf,1,2)));
|
|
||||||
|
|
||||||
int32_t handleevents(void);
|
int32_t handleevents(void);
|
||||||
int32_t handleevents_peekkeys(void);
|
int32_t handleevents_peekkeys(void);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
|
#include "printf.h"
|
||||||
|
|
||||||
struct osdfuncparm_t
|
struct osdfuncparm_t
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,42 +69,6 @@ static hashtable_t h_cvars = { OSDMAXSYMBOLS >> 1, NULL };
|
||||||
bool m32_osd_tryscript = false; // whether to try executing m32script on unkown command in the osd
|
bool m32_osd_tryscript = false; // whether to try executing m32script on unkown command in the osd
|
||||||
|
|
||||||
|
|
||||||
// color code format is as follows:
|
|
||||||
// ^## sets a color, where ## is the palette number
|
|
||||||
// ^S# sets a shade, range is 0-7 equiv to shades 0-14
|
|
||||||
// ^O resets formatting to defaults
|
|
||||||
|
|
||||||
const char * OSD_StripColors(char *outBuf, const char *inBuf)
|
|
||||||
{
|
|
||||||
const char *ptr = outBuf;
|
|
||||||
|
|
||||||
while (*inBuf)
|
|
||||||
{
|
|
||||||
if (*inBuf == '^')
|
|
||||||
{
|
|
||||||
if (isdigit(*(inBuf+1)))
|
|
||||||
{
|
|
||||||
inBuf += 2 + !!isdigit(*(inBuf+2));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if ((Btoupper(*(inBuf+1)) == 'O'))
|
|
||||||
{
|
|
||||||
inBuf += 2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if ((Btoupper(*(inBuf+1)) == 'S') && isdigit(*(inBuf+2)))
|
|
||||||
{
|
|
||||||
inBuf += 3;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*(outBuf++) = *(inBuf++);
|
|
||||||
}
|
|
||||||
|
|
||||||
*outBuf = '\0';
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OSD_ParsingScript(void) { return osd->execdepth; }
|
int OSD_ParsingScript(void) { return osd->execdepth; }
|
||||||
int OSD_OSDKey(void) { return osd->keycode; }
|
int OSD_OSDKey(void) { return osd->keycode; }
|
||||||
int OSD_GetCols(void) { return osd->draw.cols; }
|
int OSD_GetCols(void) { return osd->draw.cols; }
|
||||||
|
@ -973,18 +937,6 @@ void OSD_Draw(void)
|
||||||
// and write it to the log file
|
// and write it to the log file
|
||||||
//
|
//
|
||||||
|
|
||||||
void OSD_Printf(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
static char tmpstr[8192];
|
|
||||||
va_list va;
|
|
||||||
|
|
||||||
va_start(va, fmt);
|
|
||||||
Bvsnprintf(tmpstr, sizeof(tmpstr), fmt, va);
|
|
||||||
va_end(va);
|
|
||||||
|
|
||||||
OSD_Puts(tmpstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// OSD_Puts() -- Print a string to the onscreen display
|
// OSD_Puts() -- Print a string to the onscreen display
|
||||||
|
|
|
@ -658,79 +658,7 @@ void system_getcvars(void)
|
||||||
vid_vsync = videoSetVsync(vid_vsync);
|
vid_vsync = videoSetVsync(vid_vsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// initprintf() -- prints a formatted string to the intitialization window
|
|
||||||
//
|
|
||||||
void initprintf(const char *f, ...)
|
|
||||||
{
|
|
||||||
va_list va;
|
|
||||||
char buf[2048];
|
|
||||||
|
|
||||||
va_start(va, f);
|
|
||||||
Bvsnprintf(buf, sizeof(buf), f, va);
|
|
||||||
va_end(va);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (IsDebuggerPresent())
|
|
||||||
OutputDebugStringA(buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
initputs(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// initputs() -- prints a string to the intitialization window
|
|
||||||
//
|
|
||||||
void initputs(const char *buf)
|
|
||||||
{
|
|
||||||
static char dabuf[2048];
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
__android_log_print(ANDROID_LOG_INFO,"DUKE", "%s",buf);
|
|
||||||
#endif
|
|
||||||
OSD_Puts(buf);
|
|
||||||
// Bprintf("%s", buf);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
mutex_lock(&m_initprintf);
|
|
||||||
if (Bstrlen(dabuf) + Bstrlen(buf) > 1022)
|
|
||||||
{
|
|
||||||
startwin_puts(dabuf);
|
|
||||||
Bmemset(dabuf, 0, sizeof(dabuf));
|
|
||||||
}
|
|
||||||
|
|
||||||
Bstrcat(dabuf,buf);
|
|
||||||
|
|
||||||
if (g_logFlushWindow || Bstrlen(dabuf) > 768)
|
|
||||||
{
|
|
||||||
startwin_puts(dabuf);
|
|
||||||
#ifndef _WIN32
|
|
||||||
startwin_idle(NULL);
|
|
||||||
#else
|
|
||||||
handleevents();
|
|
||||||
#endif
|
|
||||||
Bmemset(dabuf, 0, sizeof(dabuf));
|
|
||||||
}
|
|
||||||
mutex_unlock(&m_initprintf);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// debugprintf() -- prints a formatted debug string to stderr
|
|
||||||
//
|
|
||||||
void debugprintf(const char *f, ...)
|
|
||||||
{
|
|
||||||
#if defined DEBUGGINGAIDS && !(defined __APPLE__ && defined __BIG_ENDIAN__)
|
|
||||||
va_list va;
|
|
||||||
|
|
||||||
va_start(va,f);
|
|
||||||
Bvfprintf(stderr, f, va);
|
|
||||||
va_end(va);
|
|
||||||
#else
|
|
||||||
UNREFERENCED_PARAMETER(f);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
//#include "g_levellocals.h"
|
//#include "g_levellocals.h"
|
||||||
//#include "vm.h"
|
//#include "vm.h"
|
||||||
|
|
||||||
|
F2DDrawer twod;
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
|
@ -115,10 +115,7 @@ public:
|
||||||
DAngle rotation, int colormap, PalEntry flatcolor, int lightlevel, uint32_t *indices, size_t indexcount);
|
DAngle rotation, int colormap, PalEntry flatcolor, int lightlevel, uint32_t *indices, size_t indexcount);
|
||||||
void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin);
|
void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin);
|
||||||
|
|
||||||
void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style);
|
void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr);
|
||||||
|
|
||||||
void AddDim(PalEntry color, float damount, int x1, int y1, int w, int h);
|
|
||||||
void AddClear(int left, int top, int right, int bottom, int palcolor, uint32_t color);
|
|
||||||
|
|
||||||
|
|
||||||
void AddLine(int x1, int y1, int x2, int y2, uint32_t color, uint8_t alpha = 255);
|
void AddLine(int x1, int y1, int x2, int y2, uint32_t color, uint8_t alpha = 255);
|
||||||
|
@ -130,5 +127,6 @@ public:
|
||||||
bool mIsFirstPass = true;
|
bool mIsFirstPass = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern F2DDrawer twod;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "drawparms.h"
|
#include "drawparms.h"
|
||||||
|
|
||||||
|
#ifdef DrawText
|
||||||
|
#undef DrawText
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int32_t xdim, ydim;
|
||||||
struct ScreenDummy
|
struct ScreenDummy
|
||||||
{
|
{
|
||||||
static int GetWidth() { return 1360; }
|
static int GetWidth() { return xdim; }
|
||||||
static int GetHeight() { return 768; }
|
static int GetHeight() { return ydim; }
|
||||||
};
|
};
|
||||||
extern ScreenDummy* screen;
|
extern ScreenDummy* screen;
|
||||||
|
|
||||||
|
@ -34,3 +40,8 @@ double AspectPspriteOffset(float aspect);
|
||||||
int AspectMultiplier(float aspect);
|
int AspectMultiplier(float aspect);
|
||||||
bool AspectTallerThanWide(float aspect);
|
bool AspectTallerThanWide(float aspect);
|
||||||
void ScaleWithAspect(int& w, int& h, int Width, int Height);
|
void ScaleWithAspect(int& w, int& h, int Width, int Height);
|
||||||
|
|
||||||
|
void DrawTexture(F2DDrawer *drawer, FTexture* img, double x, double y, int tags_first, ...);
|
||||||
|
void DrawChar (F2DDrawer* drawer, FFont *font, int normalcolor, double x, double y, int character, int tag_first, ...);
|
||||||
|
void DrawText(F2DDrawer* drawer, FFont *font, int normalcolor, double x, double y, const char *string, int tag_first, ...);
|
||||||
|
void DrawText(F2DDrawer* drawer, FFont *font, int normalcolor, double x, double y, const char32_t *string, int tag_first, ...);
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#define __V_TEXT_H__
|
#define __V_TEXT_H__
|
||||||
|
|
||||||
#include "zstring.h"
|
#include "zstring.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
|
||||||
class FFont;
|
class FFont;
|
||||||
|
|
||||||
struct FBrokenLines
|
struct FBrokenLines
|
||||||
|
|
2117
source/common/console/c_console.cpp
Normal file
2117
source/common/console/c_console.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -35,20 +35,10 @@
|
||||||
#define __C_CONSOLE__
|
#define __C_CONSOLE__
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
//#include "basictypes.h"
|
#include "basics.h"
|
||||||
|
|
||||||
// Dummies for missing features to make the code compile.
|
|
||||||
|
|
||||||
inline void C_AddTabCommand (const char *name) {}
|
|
||||||
inline void C_RemoveTabCommand (const char *name) {}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
struct event_t;
|
struct event_t;
|
||||||
|
|
||||||
#define C_BLINKRATE (TICRATE/2)
|
|
||||||
|
|
||||||
typedef enum cstate_t
|
typedef enum cstate_t
|
||||||
{
|
{
|
||||||
c_up=0, c_down=1, c_falling=2, c_rising=3
|
c_up=0, c_down=1, c_falling=2, c_rising=3
|
||||||
|
@ -97,5 +87,3 @@ void C_ClearTabCommands(); // Removes all tab commands
|
||||||
extern const char *console_bar;
|
extern const char *console_bar;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
179
source/common/console/c_consolebuffer.cpp
Normal file
179
source/common/console/c_consolebuffer.cpp
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
/*
|
||||||
|
** consolebuffer.cpp
|
||||||
|
**
|
||||||
|
** manages the text for the console
|
||||||
|
**
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
** Copyright 2014 Christoph Oelckers
|
||||||
|
** All rights reserved.
|
||||||
|
**
|
||||||
|
** Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions
|
||||||
|
** are met:
|
||||||
|
**
|
||||||
|
** 1. Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in the
|
||||||
|
** documentation and/or other materials provided with the distribution.
|
||||||
|
** 3. The name of the author may not be used to endorse or promote products
|
||||||
|
** derived from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "c_console.h"
|
||||||
|
#include "c_consolebuffer.h"
|
||||||
|
#include "printf.h"
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
FConsoleBuffer::FConsoleBuffer()
|
||||||
|
{
|
||||||
|
mLogFile = NULL;
|
||||||
|
mAddType = NEWLINE;
|
||||||
|
mLastFont = NULL;
|
||||||
|
mLastDisplayWidth = -1;
|
||||||
|
mLastLineNeedsUpdate = false;
|
||||||
|
mTextLines = 0;
|
||||||
|
mBufferWasCleared = true;
|
||||||
|
mBrokenStart.Push(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Adds a new line of text to the console
|
||||||
|
// This is kept as simple as possible. This function does not:
|
||||||
|
// - remove old text if the buffer gets larger than the specified size
|
||||||
|
// - format the text for the current screen layout
|
||||||
|
//
|
||||||
|
// These tasks will only be be performed once per frame because they are
|
||||||
|
// relatively expensive. The old console did them each time text was added
|
||||||
|
// resulting in extremely bad performance with a high output rate.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FConsoleBuffer::AddText(int printlevel, const char *text)
|
||||||
|
{
|
||||||
|
FString build = TEXTCOLOR_TAN;
|
||||||
|
|
||||||
|
if (mAddType == REPLACELINE)
|
||||||
|
{
|
||||||
|
// Just wondering: Do we actually need this case? If so, it may need some work.
|
||||||
|
mConsoleText.Pop(); // remove the line to be replaced
|
||||||
|
mLastLineNeedsUpdate = true;
|
||||||
|
}
|
||||||
|
else if (mAddType == APPENDLINE)
|
||||||
|
{
|
||||||
|
mConsoleText.Pop(build);
|
||||||
|
printlevel = -1;
|
||||||
|
mLastLineNeedsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printlevel >= 0 && printlevel != PRINT_HIGH)
|
||||||
|
{
|
||||||
|
if (printlevel == 200) build = TEXTCOLOR_GREEN;
|
||||||
|
else if (printlevel < PRINTLEVELS) build.Format("%c%c", TEXTCOLOR_ESCAPE, PrintColors[printlevel]+'A');
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t textsize = strlen(text);
|
||||||
|
|
||||||
|
if (text[textsize-1] == '\r')
|
||||||
|
{
|
||||||
|
textsize--;
|
||||||
|
mAddType = REPLACELINE;
|
||||||
|
}
|
||||||
|
else if (text[textsize-1] == '\n')
|
||||||
|
{
|
||||||
|
textsize--;
|
||||||
|
mAddType = NEWLINE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mAddType = APPENDLINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't bother with linefeeds etc. inside the text, we'll let the formatter sort this out later.
|
||||||
|
build.AppendCStrPart(text, textsize);
|
||||||
|
mConsoleText.Push(build);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Format the text for output
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FConsoleBuffer::FormatText(FFont *formatfont, int displaywidth)
|
||||||
|
{
|
||||||
|
if (formatfont != mLastFont || displaywidth != mLastDisplayWidth || mBufferWasCleared)
|
||||||
|
{
|
||||||
|
if (mBufferWasCleared)
|
||||||
|
mLastLineNeedsUpdate = false;
|
||||||
|
m_BrokenConsoleText.Clear();
|
||||||
|
mBrokenStart.Clear();
|
||||||
|
mBrokenStart.Push(0);
|
||||||
|
mBrokenLines.Clear();
|
||||||
|
mLastFont = formatfont;
|
||||||
|
mLastDisplayWidth = displaywidth;
|
||||||
|
mBufferWasCleared = false;
|
||||||
|
}
|
||||||
|
unsigned brokensize = m_BrokenConsoleText.Size();
|
||||||
|
if (brokensize == mConsoleText.Size())
|
||||||
|
{
|
||||||
|
// The last line got text appended.
|
||||||
|
if (mLastLineNeedsUpdate)
|
||||||
|
{
|
||||||
|
brokensize--;
|
||||||
|
m_BrokenConsoleText.Resize(brokensize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mBrokenLines.Resize(mBrokenStart[brokensize]);
|
||||||
|
mBrokenStart.Resize(brokensize);
|
||||||
|
for (unsigned i = brokensize; i < mConsoleText.Size(); i++)
|
||||||
|
{
|
||||||
|
auto bl = V_BreakLines(formatfont, displaywidth, mConsoleText[i], true);
|
||||||
|
m_BrokenConsoleText.Push(bl);
|
||||||
|
mBrokenStart.Push(mBrokenLines.Size());
|
||||||
|
for(auto &bline : bl)
|
||||||
|
{
|
||||||
|
mBrokenLines.Push(bline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mTextLines = mBrokenLines.Size();
|
||||||
|
mBrokenStart.Push(mTextLines);
|
||||||
|
mLastLineNeedsUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Delete old content if number of lines gets too large
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FConsoleBuffer::ResizeBuffer(unsigned newsize)
|
||||||
|
{
|
||||||
|
if (mConsoleText.Size() > newsize)
|
||||||
|
{
|
||||||
|
unsigned todelete = mConsoleText.Size() - newsize;
|
||||||
|
mConsoleText.Delete(0, todelete);
|
||||||
|
mBufferWasCleared = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
78
source/common/console/c_consolebuffer.h
Normal file
78
source/common/console/c_consolebuffer.h
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
** consolebuffer.h
|
||||||
|
**
|
||||||
|
** manages the text for the console
|
||||||
|
**
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
** Copyright 2014 Christoph Oelckers
|
||||||
|
** All rights reserved.
|
||||||
|
**
|
||||||
|
** Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions
|
||||||
|
** are met:
|
||||||
|
**
|
||||||
|
** 1. Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in the
|
||||||
|
** documentation and/or other materials provided with the distribution.
|
||||||
|
** 3. The name of the author may not be used to endorse or promote products
|
||||||
|
** derived from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "zstring.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
#include "v_text.h"
|
||||||
|
|
||||||
|
enum EAddType
|
||||||
|
{
|
||||||
|
NEWLINE,
|
||||||
|
APPENDLINE,
|
||||||
|
REPLACELINE
|
||||||
|
};
|
||||||
|
|
||||||
|
class FConsoleBuffer
|
||||||
|
{
|
||||||
|
TArray<FString> mConsoleText;
|
||||||
|
TArray<TArray<FBrokenLines>> m_BrokenConsoleText; // This holds the structures returned by V_BreakLines and is used for memory management.
|
||||||
|
TArray<unsigned int> mBrokenStart;
|
||||||
|
TArray<FBrokenLines> mBrokenLines; // This holds the single lines, indexed by mBrokenStart and is used for printing.
|
||||||
|
FILE * mLogFile;
|
||||||
|
EAddType mAddType;
|
||||||
|
int mTextLines;
|
||||||
|
bool mBufferWasCleared;
|
||||||
|
|
||||||
|
FFont *mLastFont;
|
||||||
|
int mLastDisplayWidth;
|
||||||
|
bool mLastLineNeedsUpdate;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
FConsoleBuffer();
|
||||||
|
void AddText(int printlevel, const char *string);
|
||||||
|
void FormatText(FFont *formatfont, int displaywidth);
|
||||||
|
void ResizeBuffer(unsigned newsize);
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
mBufferWasCleared = true;
|
||||||
|
mConsoleText.Clear();
|
||||||
|
}
|
||||||
|
int GetFormattedLineCount() { return mTextLines; }
|
||||||
|
FBrokenLines *GetLines() { return &mBrokenLines[0]; }
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Just to let the ZDoom-based code print to the Build console without changing it all
|
// This header collects all things printf.
|
||||||
|
// EDuke32 had two totally separate output paths and all the added code from G/ZDoom uses yet another means.
|
||||||
|
// Everything goes to the console now, but to avoid changing everything, this redirects all output to the console, with the proper settings.
|
||||||
|
// Changing all this would mean altering over 1000 lines of code which would add a needless complication to merging from upstream.
|
||||||
|
|
||||||
|
|
||||||
#if defined __GNUC__ || defined __clang__
|
#if defined __GNUC__ || defined __clang__
|
||||||
# define ATTRIBUTE(attrlist) __attribute__(attrlist)
|
# define ATTRIBUTE(attrlist) __attribute__(attrlist)
|
||||||
|
@ -8,8 +12,60 @@
|
||||||
# define ATTRIBUTE(attrlist)
|
# define ATTRIBUTE(attrlist)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void OSD_Printf(const char *fmt, ...) ATTRIBUTE((format(printf,1,2)));
|
// game print flags
|
||||||
#define Printf OSD_Printf
|
enum
|
||||||
|
{
|
||||||
|
PRINT_LOW, // pickup messages
|
||||||
|
PRINT_MEDIUM, // death messages
|
||||||
|
PRINT_HIGH, // critical messages
|
||||||
|
PRINT_CHAT, // chat messages
|
||||||
|
PRINT_TEAMCHAT, // chat messages from a teammate
|
||||||
|
PRINT_LOG, // only to logfile
|
||||||
|
PRINT_BOLD = 200, // What Printf_Bold used
|
||||||
|
PRINT_TYPES = 1023, // Bitmask.
|
||||||
|
PRINT_NONOTIFY = 1024, // Flag - do not add to notify buffer
|
||||||
|
PRINT_NOLOG = 2048, // Flag - do not print to log file
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
DMSG_OFF, // no developer messages.
|
||||||
|
DMSG_ERROR, // general notification messages
|
||||||
|
DMSG_WARNING, // warnings
|
||||||
|
DMSG_NOTIFY, // general notification messages
|
||||||
|
DMSG_SPAMMY, // for those who want to see everything, regardless of its usefulness.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void I_Error(const char *fmt, ...) ATTRIBUTE((format(printf,1,2)));
|
void I_Error(const char *fmt, ...) ATTRIBUTE((format(printf,1,2)));
|
||||||
|
|
||||||
|
int PrintString (int iprintlevel, const char *outline);
|
||||||
|
int Printf (int printlevel, const char *format, ...) ATTRIBUTE((format(printf,2,3)));
|
||||||
|
int Printf (const char *format, ...) ATTRIBUTE((format(printf,1,2)));
|
||||||
|
int DPrintf (int level, const char *format, ...) ATTRIBUTE((format(printf,2,3)));
|
||||||
|
|
||||||
|
|
||||||
|
void OSD_Printf(const char *format, ...) ATTRIBUTE((format(printf,1,2)));
|
||||||
|
|
||||||
|
template<class... Args>
|
||||||
|
inline void initprintf(const char *format, Args&&... args) ATTRIBUTE((format(printf,1,2)))
|
||||||
|
{
|
||||||
|
OSD_Printf(format, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This was a define before - which should be avoided. Used by Shadow Warrior
|
||||||
|
template<class... Args>
|
||||||
|
inline void buildprintf(const char *format, Args&&... args) ATTRIBUTE((format(printf,1,2)))
|
||||||
|
{
|
||||||
|
OSD_Printf(format, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void initputs(const char *s)
|
||||||
|
{
|
||||||
|
PrintString(PRINT_HIGH, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void buildputs(const char *s)
|
||||||
|
{
|
||||||
|
PrintString(PRINT_HIGH, s);
|
||||||
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ void S_SoundStartup(void)
|
||||||
|
|
||||||
snd_reversestereo.Callback();
|
snd_reversestereo.Callback();
|
||||||
FX_SetCallBack(S_Callback);
|
FX_SetCallBack(S_Callback);
|
||||||
FX_SetPrintf(initprintf);
|
FX_SetPrintf(OSD_Printf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_SoundShutdown(void)
|
void S_SoundShutdown(void)
|
||||||
|
|
57022
wadsrc/static/demolition/newconsolefont.hex
Normal file
57022
wadsrc/static/demolition/newconsolefont.hex
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue