2024-06-17 19:37:10 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Doom 3 GPL Source Code
Copyright ( C ) 1999 - 2011 id Software LLC , a ZeniMax Media company .
2024-06-21 16:01:12 +00:00
Copyright ( C ) 2024 Robert Beckebans
2024-06-17 19:37:10 +00:00
This file is part of the Doom 3 GPL Source Code ( ? Doom 3 Source Code ? ) .
Doom 3 Source Code is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Doom 3 Source Code is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code . If not , see < http : //www.gnu.org/licenses/>.
In addition , the Doom 3 Source Code is also subject to certain additional terms . You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code . If not , please request a copy in writing from id Software at the address below .
If you have questions concerning this license or the applicable additional terms , you may contact in writing id Software LLC , c / o ZeniMax Media Inc . , Suite 120 , Rockville , Maryland 20850 USA .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2024-06-15 19:33:49 +00:00
# include "precompiled.h"
2024-06-19 19:33:41 +00:00
# pragma hdrstop
2024-06-15 19:33:49 +00:00
# include "../sys/sys_local.h"
# include "../framework/EventLoop.h"
# include "../framework/DeclManager.h"
# include <direct.h>
# include <io.h>
2024-06-20 20:53:46 +00:00
# include "imtui/imtui.h"
# include "imtui/imtui-impl-ncurses.h"
# include "imtui/imtui-demo.h"
2024-06-15 19:33:49 +00:00
idEventLoop * eventLoop ;
2024-06-18 15:26:33 +00:00
2024-06-20 20:53:46 +00:00
//-----------------------------------------------------------------------------
// [SECTION] Example App: Debug Log / ShowExampleAppLog()
//-----------------------------------------------------------------------------
// Usage:
// static ExampleAppLog my_log;
// my_log.AddLog("Hello %d world\n", 123);
// my_log.Draw("title");
2024-06-21 16:01:12 +00:00
struct MyAppLog
2024-06-20 20:53:46 +00:00
{
ImGuiTextBuffer Buf ;
ImGuiTextFilter Filter ;
ImVector < int > LineOffsets ; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines
2024-06-21 16:01:12 +00:00
MyAppLog ( )
2024-06-20 20:53:46 +00:00
{
Clear ( ) ;
}
void Clear ( )
{
Buf . clear ( ) ;
LineOffsets . clear ( ) ;
LineOffsets . push_back ( 0 ) ;
}
void AddLog ( const char * fmt , . . . ) IM_FMTARGS ( 2 )
{
int old_size = Buf . size ( ) ;
va_list args ;
va_start ( args , fmt ) ;
Buf . appendfv ( fmt , args ) ;
va_end ( args ) ;
for ( int new_size = Buf . size ( ) ; old_size < new_size ; old_size + + )
if ( Buf [ old_size ] = = ' \n ' )
{
LineOffsets . push_back ( old_size + 1 ) ;
}
}
void Draw ( const char * title , bool * p_open = NULL )
{
2024-06-21 16:01:12 +00:00
{
auto wSize = ImGui : : GetIO ( ) . DisplaySize ;
ImGui : : SetNextWindowPos ( ImVec2 ( 0 , 1 ) , ImGuiCond_Always ) ;
ImGui : : SetNextWindowSize ( ImVec2 ( wSize . x , wSize . y - 5 ) , ImGuiCond_Always ) ;
}
if ( ! ImGui : : Begin ( title , p_open , ImGuiWindowFlags_NoDecoration ) )
2024-06-20 20:53:46 +00:00
{
ImGui : : End ( ) ;
return ;
}
2024-06-21 16:01:12 +00:00
bool copy = ImGui : : Button ( " Copy to Clipboard " ) ;
2024-06-20 20:53:46 +00:00
ImGui : : SameLine ( ) ;
ImGui : : Separator ( ) ;
ImGui : : BeginChild ( " scrolling " , ImVec2 ( 0 , 0 ) , false , ImGuiWindowFlags_HorizontalScrollbar ) ;
if ( copy )
{
ImGui : : LogToClipboard ( ) ;
}
ImGui : : PushStyleVar ( ImGuiStyleVar_ItemSpacing , ImVec2 ( 0 , 0 ) ) ;
const char * buf = Buf . begin ( ) ;
const char * buf_end = Buf . end ( ) ;
2024-06-21 16:01:12 +00:00
#if 0
2024-06-20 20:53:46 +00:00
if ( Filter . IsActive ( ) )
{
// In this example we don't use the clipper when Filter is enabled.
// This is because we don't have a random access on the result on our filter.
// A real application processing logs with ten of thousands of entries may want to store the result of search/filter.
// especially if the filtering function is not trivial (e.g. reg-exp).
for ( int line_no = 0 ; line_no < LineOffsets . Size ; line_no + + )
{
const char * line_start = buf + LineOffsets [ line_no ] ;
const char * line_end = ( line_no + 1 < LineOffsets . Size ) ? ( buf + LineOffsets [ line_no + 1 ] - 1 ) : buf_end ;
if ( Filter . PassFilter ( line_start , line_end ) )
{
ImGui : : TextUnformatted ( line_start , line_end ) ;
}
}
}
else
2024-06-21 16:01:12 +00:00
# endif
2024-06-20 20:53:46 +00:00
{
// The simplest and easy way to display the entire buffer:
// ImGui::TextUnformatted(buf_begin, buf_end);
// And it'll just work. TextUnformatted() has specialization for large blob of text and will fast-forward to skip non-visible lines.
// Here we instead demonstrate using the clipper to only process lines that are within the visible area.
// If you have tens of thousands of items and their processing cost is non-negligible, coarse clipping them on your side is recommended.
// Using ImGuiListClipper requires A) random access into your data, and B) items all being the same height,
// both of which we can handle since we an array pointing to the beginning of each line of text.
// When using the filter (in the block of code above) we don't have random access into the data to display anymore, which is why we don't use the clipper.
// Storing or skimming through the search result would make it possible (and would be recommended if you want to search through tens of thousands of entries)
ImGuiListClipper clipper ;
clipper . Begin ( LineOffsets . Size ) ;
while ( clipper . Step ( ) )
{
for ( int line_no = clipper . DisplayStart ; line_no < clipper . DisplayEnd ; line_no + + )
{
const char * line_start = buf + LineOffsets [ line_no ] ;
const char * line_end = ( line_no + 1 < LineOffsets . Size ) ? ( buf + LineOffsets [ line_no + 1 ] - 1 ) : buf_end ;
ImGui : : TextUnformatted ( line_start , line_end ) ;
}
}
clipper . End ( ) ;
}
ImGui : : PopStyleVar ( ) ;
2024-06-21 16:01:12 +00:00
//if( ImGui::GetScrollY() >= ImGui::GetScrollMaxY() )
2024-06-20 20:53:46 +00:00
{
ImGui : : SetScrollHereY ( 1.0f ) ;
}
ImGui : : EndChild ( ) ;
ImGui : : End ( ) ;
}
} ;
2024-06-21 16:01:12 +00:00
static MyAppLog tuiLog ;
2024-06-20 20:53:46 +00:00
2024-06-18 15:26:33 +00:00
# define MAXPRINTMSG 4096
2024-06-15 19:33:49 +00:00
# define STDIO_PRINT( pre, post ) \
2024-06-18 15:26:33 +00:00
char msg [ MAXPRINTMSG ] ; \
2024-06-15 19:33:49 +00:00
va_list argptr ; \
va_start ( argptr , fmt ) ; \
2024-06-18 15:26:33 +00:00
idStr : : vsnPrintf ( msg , MAXPRINTMSG - 1 , fmt , argptr ) ; \
msg [ sizeof ( msg ) - 1 ] = ' \0 ' ; \
va_end ( argptr ) ; \
Sys_DebugPrintf ( " %s%s%s " , pre , msg , post ) ; \
2024-06-15 19:33:49 +00:00
2024-06-21 16:01:12 +00:00
idCVar com_developer ( " developer " , " 0 " , CVAR_BOOL | CVAR_SYSTEM , " developer mode " ) ;
2024-06-18 15:26:33 +00:00
idCVar com_productionMode ( " com_productionMode " , " 0 " , CVAR_SYSTEM | CVAR_BOOL , " 0 - no special behavior, 1 - building a production build, 2 - running a production build " ) ;
2024-06-15 19:33:49 +00:00
2024-06-17 19:37:10 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSys
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2024-06-18 15:26:33 +00:00
/*
= = = = = = = = = = = = = =
Sys_DebugPrintf
= = = = = = = = = = = = = =
*/
void Sys_DebugPrintf ( const char * fmt , . . . )
{
char msg [ MAXPRINTMSG ] ;
va_list argptr ;
va_start ( argptr , fmt ) ;
idStr : : vsnPrintf ( msg , MAXPRINTMSG - 1 , fmt , argptr ) ;
msg [ sizeof ( msg ) - 1 ] = ' \0 ' ;
va_end ( argptr ) ;
printf ( msg ) ;
OutputDebugString ( msg ) ;
2024-06-20 20:53:46 +00:00
tuiLog . AddLog ( " %s " , msg ) ;
2024-06-18 15:26:33 +00:00
}
2024-06-19 19:33:41 +00:00
/*
= = = = = = = = = = = = = =
Sys_DebugVPrintf
= = = = = = = = = = = = = =
*/
void Sys_DebugVPrintf ( const char * fmt , va_list arg )
{
char msg [ MAXPRINTMSG ] ;
idStr : : vsnPrintf ( msg , MAXPRINTMSG - 1 , fmt , arg ) ;
msg [ sizeof ( msg ) - 1 ] = ' \0 ' ;
printf ( msg ) ;
OutputDebugString ( msg ) ;
2024-06-20 20:53:46 +00:00
tuiLog . AddLog ( " %s " , msg ) ;
2024-06-19 19:33:41 +00:00
}
2024-06-18 15:26:33 +00:00
2024-06-15 19:33:49 +00:00
/*
= = = = = = = = = = = = = =
Sys_Mkdir
= = = = = = = = = = = = = =
*/
void Sys_Mkdir ( const char * path )
{
_mkdir ( path ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
Sys_Rmdir
= = = = = = = = = = = = = = = = = = = = = = = =
*/
bool Sys_Rmdir ( const char * path )
{
return _rmdir ( path ) = = 0 ;
}
/*
= = = = = = = = = = = = = =
Sys_EXEPath
= = = = = = = = = = = = = =
*/
const char * Sys_EXEPath ( )
{
static char exe [ MAX_OSPATH ] ;
GetModuleFileName ( NULL , exe , sizeof ( exe ) - 1 ) ;
return exe ;
}
/*
= = = = = = = = = = = = = =
Sys_ListFiles
= = = = = = = = = = = = = =
*/
int Sys_ListFiles ( const char * directory , const char * extension , idStrList & list )
{
idStr search ;
struct _finddata_t findinfo ;
// RB: 64 bit fixes, changed int to intptr_t
intptr_t findhandle ;
// RB end
int flag ;
if ( ! extension )
{
extension = " " ;
}
// passing a slash as extension will find directories
if ( extension [ 0 ] = = ' / ' & & extension [ 1 ] = = 0 )
{
extension = " " ;
flag = 0 ;
}
else
{
flag = _A_SUBDIR ;
}
sprintf ( search , " %s \\ *%s " , directory , extension ) ;
// search
list . Clear ( ) ;
findhandle = _findfirst ( search , & findinfo ) ;
if ( findhandle = = - 1 )
{
return - 1 ;
}
do
{
if ( flag ^ ( findinfo . attrib & _A_SUBDIR ) )
{
list . Append ( findinfo . name ) ;
}
}
while ( _findnext ( findhandle , & findinfo ) ! = - 1 ) ;
_findclose ( findhandle ) ;
return list . Num ( ) ;
}
int idEventLoop : : JournalLevel ( ) const
{
return 0 ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
Sys_IsFolder
= = = = = = = = = = = = = = = = = = = = = = = =
*/
sysFolder_t Sys_IsFolder ( const char * path )
{
struct _stat buffer ;
if ( _stat ( path , & buffer ) < 0 )
{
return FOLDER_ERROR ;
}
return ( buffer . st_mode & _S_IFDIR ) ! = 0 ? FOLDER_YES : FOLDER_NO ;
}
const char * Sys_DefaultSavePath ( )
{
return " " ;
}
const char * Sys_Lang ( int )
{
return " " ;
}
/*
= = = = = = = = = = = = = = = = =
Sys_FileTimeStamp
= = = = = = = = = = = = = = = = =
*/
ID_TIME_T Sys_FileTimeStamp ( idFileHandle fp )
{
FILETIME writeTime ;
GetFileTime ( fp , NULL , NULL , & writeTime ) ;
/*
FILETIME = number of 100 - nanosecond ticks since midnight
1 Jan 1601 UTC . time_t = number of 1 - second ticks since
midnight 1 Jan 1970 UTC . To translate , we subtract a
FILETIME representation of midnight , 1 Jan 1970 from the
time in question and divide by the number of 100 - ns ticks
in one second .
*/
SYSTEMTIME base_st =
{
1970 , // wYear
1 , // wMonth
0 , // wDayOfWeek
1 , // wDay
0 , // wHour
0 , // wMinute
0 , // wSecond
0 // wMilliseconds
} ;
FILETIME base_ft ;
SystemTimeToFileTime ( & base_st , & base_ft ) ;
LARGE_INTEGER itime ;
itime . QuadPart = reinterpret_cast < LARGE_INTEGER & > ( writeTime ) . QuadPart ;
itime . QuadPart - = reinterpret_cast < LARGE_INTEGER & > ( base_ft ) . QuadPart ;
itime . QuadPart / = 10000000LL ;
return itime . QuadPart ;
}
2024-06-19 19:33:41 +00:00
/*
= = = = = = = = = = = = = = = =
Sys_GetClockTicks
= = = = = = = = = = = = = = = =
*/
double Sys_GetClockTicks ( )
{
LARGE_INTEGER li ;
QueryPerformanceCounter ( & li ) ;
return ( double ) li . LowPart + ( double ) 0xFFFFFFFF * li . HighPart ;
}
/*
= = = = = = = = = = = = = = = =
Sys_ClockTicksPerSecond
= = = = = = = = = = = = = = = =
*/
double Sys_ClockTicksPerSecond ( )
{
static double ticks = 0 ;
if ( ! ticks )
{
LARGE_INTEGER li ;
QueryPerformanceFrequency ( & li ) ;
ticks = li . QuadPart ;
}
return ticks ;
}
2024-06-15 19:33:49 +00:00
/*
= = = = = = = = = = = = = =
Sys_Cwd
= = = = = = = = = = = = = =
*/
const char * Sys_Cwd ( )
{
static char cwd [ MAX_OSPATH ] ;
_getcwd ( cwd , sizeof ( cwd ) - 1 ) ;
cwd [ MAX_OSPATH - 1 ] = 0 ;
return cwd ;
}
/*
= = = = = = = = = = = = = =
Sys_DefaultBasePath
= = = = = = = = = = = = = =
*/
const char * Sys_DefaultBasePath ( )
{
return Sys_Cwd ( ) ;
}
int Sys_NumLangs ( )
{
return 0 ;
}
/*
= = = = = = = = = = = = = = = =
Sys_Milliseconds
= = = = = = = = = = = = = = = =
*/
int Sys_Milliseconds ( )
{
static DWORD sys_timeBase = timeGetTime ( ) ;
return timeGetTime ( ) - sys_timeBase ;
}
2024-06-19 19:33:41 +00:00
class idSysCmdline : public idSys
{
public :
virtual void DebugPrintf ( VERIFY_FORMAT_STRING const char * fmt , . . . )
{
va_list argptr ;
va_start ( argptr , fmt ) ;
Sys_DebugVPrintf ( fmt , argptr ) ;
va_end ( argptr ) ;
}
virtual void DebugVPrintf ( const char * fmt , va_list arg )
{
Sys_DebugVPrintf ( fmt , arg ) ;
}
virtual double GetClockTicks ( )
{
return Sys_GetClockTicks ( ) ;
}
virtual double ClockTicksPerSecond ( )
{
return Sys_ClockTicksPerSecond ( ) ;
}
virtual cpuid_t GetProcessorId ( )
{
return CPUID_NONE ;
}
virtual const char * GetProcessorString ( )
{
return NULL ;
}
virtual const char * FPU_GetState ( )
{
return NULL ;
}
virtual bool FPU_StackIsEmpty ( )
{
return NULL ;
}
virtual void FPU_SetFTZ ( bool enable ) { }
virtual void FPU_SetDAZ ( bool enable ) { }
virtual void FPU_EnableExceptions ( int exceptions ) { }
virtual bool LockMemory ( void * ptr , int bytes )
{
return false ;
}
virtual bool UnlockMemory ( void * ptr , int bytes )
{
return false ;
}
virtual int DLL_Load ( const char * dllName )
{
return 0 ;
}
virtual void * DLL_GetProcAddress ( int dllHandle , const char * procName )
{
return NULL ;
}
virtual void DLL_Unload ( int dllHandle ) { }
virtual void DLL_GetFileName ( const char * baseName , char * dllName , int maxLength ) { }
virtual sysEvent_t GenerateMouseButtonEvent ( int button , bool down )
{
sysEvent_t ev ;
ev . evType = SE_NONE ;
return ev ;
}
virtual sysEvent_t GenerateMouseMoveEvent ( int deltax , int deltay )
{
sysEvent_t ev ;
ev . evType = SE_NONE ;
return ev ;
}
virtual void OpenURL ( const char * url , bool quit ) { }
virtual void StartProcess ( const char * exeName , bool quit ) { }
} ;
idSysCmdline idSysLocal ;
idSys * sys = & idSysLocal ;
2024-06-17 19:37:10 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idCommon
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2024-06-21 16:01:12 +00:00
/*
# include <array>
# include <map>
# include <vector>
# include <string>
# include <functional>
*/
namespace UI
{
enum class ColorScheme : int
{
Default ,
Dark ,
Green ,
Jungle ,
COUNT ,
} ;
struct State
{
int hoveredWindowId = 0 ;
int statusWindowHeight = 4 ;
ColorScheme colorScheme = ColorScheme : : Dark ;
bool showHelpWelcome = false ;
bool showHelpModal = false ;
bool showStatusWindow = true ;
# define STATUS_TEXT_SIZE 512
idStrStatic < STATUS_TEXT_SIZE > statusWindowHeader = " Initializing Doom Framework " ;
idStrStatic < STATUS_TEXT_SIZE > statusActiveTool = " - " ;
float progress = 1.0f ;
void ChangeColorScheme ( bool inc = true )
{
if ( inc )
{
colorScheme = ( ColorScheme ) ( ( ( int ) colorScheme + 1 ) % ( ( int ) ColorScheme : : COUNT ) ) ;
}
ImVec4 * colors = ImGui : : GetStyle ( ) . Colors ;
switch ( colorScheme )
{
case ColorScheme : : Default :
{
colors [ ImGuiCol_Text ] = ImVec4 ( 0.00f , 0.00f , 0.00f , 1.00f ) ;
colors [ ImGuiCol_TextDisabled ] = ImVec4 ( 0.60f , 0.60f , 0.60f , 1.00f ) ;
colors [ ImGuiCol_WindowBg ] = ImVec4 ( 0.96f , 0.96f , 0.94f , 1.00f ) ;
colors [ ImGuiCol_TitleBg ] = ImVec4 ( 1.00f , 0.40f , 0.00f , 1.00f ) ;
colors [ ImGuiCol_TitleBgActive ] = ImVec4 ( 1.00f , 0.40f , 0.00f , 1.00f ) ;
colors [ ImGuiCol_TitleBgCollapsed ] = ImVec4 ( 0.69f , 0.25f , 0.00f , 1.00f ) ;
colors [ ImGuiCol_ChildBg ] = ImVec4 ( 0.96f , 0.96f , 0.94f , 1.00f ) ;
colors [ ImGuiCol_PopupBg ] = ImVec4 ( 0.96f , 0.96f , 0.94f , 1.00f ) ;
colors [ ImGuiCol_ModalWindowDimBg ] = ImVec4 ( 0.00f , 0.00f , 0.00f , 0.00f ) ;
break ;
}
case ColorScheme : : Dark :
{
colors [ ImGuiCol_Text ] = ImVec4 ( 1.00f , 1.00f , 1.00f , 1.00f ) ;
colors [ ImGuiCol_TextDisabled ] = ImVec4 ( 0.60f , 0.60f , 0.60f , 1.00f ) ;
colors [ ImGuiCol_WindowBg ] = ImVec4 ( 0.10f , 0.10f , 0.10f , 1.00f ) ;
colors [ ImGuiCol_TitleBg ] = ImVec4 ( 1.00f , 0.40f , 0.00f , 0.50f ) ;
colors [ ImGuiCol_TitleBgActive ] = ImVec4 ( 1.00f , 0.40f , 0.00f , 0.50f ) ;
colors [ ImGuiCol_TitleBgCollapsed ] = ImVec4 ( 0.69f , 0.25f , 0.00f , 0.50f ) ;
colors [ ImGuiCol_ChildBg ] = ImVec4 ( 0.10f , 0.10f , 0.10f , 1.00f ) ;
colors [ ImGuiCol_PopupBg ] = ImVec4 ( 0.20f , 0.20f , 0.20f , 1.00f ) ;
colors [ ImGuiCol_ModalWindowDimBg ] = ImVec4 ( 0.00f , 0.00f , 0.00f , 0.00f ) ;
break ;
}
case ColorScheme : : Green :
{
colors [ ImGuiCol_Text ] = ImVec4 ( 0.00f , 1.00f , 0.00f , 1.00f ) ;
colors [ ImGuiCol_TextDisabled ] = ImVec4 ( 0.60f , 0.60f , 0.60f , 1.00f ) ;
colors [ ImGuiCol_WindowBg ] = ImVec4 ( 0.10f , 0.10f , 0.10f , 1.00f ) ;
colors [ ImGuiCol_TitleBg ] = ImVec4 ( 0.25f , 0.25f , 0.25f , 1.00f ) ;
colors [ ImGuiCol_TitleBgActive ] = ImVec4 ( 0.25f , 0.25f , 0.25f , 1.00f ) ;
colors [ ImGuiCol_TitleBgCollapsed ] = ImVec4 ( 0.50f , 1.00f , 0.50f , 1.00f ) ;
colors [ ImGuiCol_ChildBg ] = ImVec4 ( 0.10f , 0.10f , 0.10f , 1.00f ) ;
colors [ ImGuiCol_PopupBg ] = ImVec4 ( 0.00f , 0.00f , 0.00f , 1.00f ) ;
colors [ ImGuiCol_ModalWindowDimBg ] = ImVec4 ( 0.00f , 0.00f , 0.00f , 0.00f ) ;
break ;
}
case ColorScheme : : Jungle :
{
// based on BlackDevil style by Naeemullah1 from ImThemes
colors [ ImGuiCol_Text ] = ImVec4 ( 0.78f , 0.78f , 0.78f , 1.00f ) ;
colors [ ImGuiCol_TextDisabled ] = ImVec4 ( 0.44f , 0.41f , 0.31f , 1.00f ) ;
colors [ ImGuiCol_WindowBg ] = ImVec4 ( 0.12f , 0.14f , 0.16f , 0.87f ) ;
colors [ ImGuiCol_ChildBg ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_PopupBg ] = ImVec4 ( 0.08f , 0.08f , 0.08f , 0.78f ) ;
//colors[ImGuiCol_Border] = ImVec4(0.39f, 0.00f, 0.00f, 0.78f); the red is a bit too aggressive
colors [ ImGuiCol_Border ] = ImVec4 ( 0.24f , 0.27f , 0.32f , 0.78f ) ;
colors [ ImGuiCol_BorderShadow ] = ImVec4 ( 0.00f , 0.00f , 0.00f , 0.00f ) ;
colors [ ImGuiCol_FrameBg ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_FrameBgHovered ] = ImVec4 ( 0.12f , 0.24f , 0.35f , 0.78f ) ;
colors [ ImGuiCol_FrameBgActive ] = ImVec4 ( 0.35f , 0.35f , 0.12f , 0.78f ) ;
colors [ ImGuiCol_TitleBg ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_TitleBgActive ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_TitleBgCollapsed ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.20f ) ;
colors [ ImGuiCol_MenuBarBg ] = ImVec4 ( 0.08f , 0.08f , 0.08f , 0.78f ) ;
colors [ ImGuiCol_ScrollbarBg ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_ScrollbarGrab ] = ImVec4 ( 0.12f , 0.35f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_ScrollbarGrabHovered ] = ImVec4 ( 0.12f , 0.35f , 0.35f , 0.78f ) ;
colors [ ImGuiCol_ScrollbarGrabActive ] = ImVec4 ( 0.12f , 0.59f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_CheckMark ] = ImVec4 ( 0.12f , 0.59f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_SliderGrab ] = ImVec4 ( 0.12f , 0.35f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_SliderGrabActive ] = ImVec4 ( 0.12f , 0.59f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_Button ] = ImVec4 ( 0.35f , 0.35f , 0.12f , 0.78f ) ;
colors [ ImGuiCol_ButtonHovered ] = ImVec4 ( 0.35f , 0.47f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_ButtonActive ] = ImVec4 ( 0.59f , 0.35f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_Header ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_HeaderHovered ] = ImVec4 ( 0.12f , 0.35f , 0.35f , 0.78f ) ;
colors [ ImGuiCol_HeaderActive ] = ImVec4 ( 0.12f , 0.59f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_Separator ] = ImVec4 ( 0.35f , 0.35f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_SeparatorHovered ] = ImVec4 ( 0.12f , 0.35f , 0.35f , 0.78f ) ;
colors [ ImGuiCol_SeparatorActive ] = ImVec4 ( 0.59f , 0.35f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_ResizeGrip ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_ResizeGripHovered ] = ImVec4 ( 0.59f , 0.35f , 0.35f , 0.78f ) ;
colors [ ImGuiCol_ResizeGripActive ] = ImVec4 ( 0.59f , 0.24f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_Tab ] = ImVec4 ( 0.35f , 0.35f , 0.12f , 0.78f ) ;
colors [ ImGuiCol_TabHovered ] = ImVec4 ( 0.35f , 0.47f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_TabActive ] = ImVec4 ( 0.59f , 0.35f , 0.24f , 0.78f ) ;
colors [ ImGuiCol_TabUnfocused ] = ImVec4 ( 0.06f , 0.12f , 0.16f , 0.78f ) ;
colors [ ImGuiCol_TabUnfocusedActive ] = ImVec4 ( 0.59f , 0.35f , 0.35f , 0.78f ) ;
// colors[ImGuiCol_DockingPreview] = ImVec4( 0.26f, 0.59f, 0.98f, 0.70f );
// colors[ImGuiCol_DockingEmptyBg] = ImVec4( 0.20f, 0.20f, 0.20f, 1.00f );
colors [ ImGuiCol_PlotLines ] = ImVec4 ( 0.39f , 0.78f , 0.39f , 0.78f ) ;
colors [ ImGuiCol_PlotLinesHovered ] = ImVec4 ( 1.00f , 0.43f , 0.35f , 0.78f ) ;
colors [ ImGuiCol_PlotHistogram ] = ImVec4 ( 0.00f , 0.35f , 0.39f , 0.78f ) ;
colors [ ImGuiCol_PlotHistogramHovered ] = ImVec4 ( 0.20f , 0.59f , 0.59f , 0.78f ) ;
colors [ ImGuiCol_TableHeaderBg ] = ImVec4 ( 0.19f , 0.19f , 0.20f , 0.78f ) ;
colors [ ImGuiCol_TableBorderStrong ] = ImVec4 ( 0.31f , 0.31f , 0.35f , 0.78f ) ;
colors [ ImGuiCol_TableBorderLight ] = ImVec4 ( 0.23f , 0.23f , 0.25f , 0.78f ) ;
colors [ ImGuiCol_TableRowBg ] = ImVec4 ( 0.00f , 0.00f , 0.00f , 0.78f ) ;
colors [ ImGuiCol_TableRowBgAlt ] = ImVec4 ( 1.00f , 1.00f , 1.00f , 0.06f ) ;
colors [ ImGuiCol_TextSelectedBg ] = ImVec4 ( 0.39f , 0.35f , 0.39f , 0.39f ) ;
colors [ ImGuiCol_DragDropTarget ] = ImVec4 ( 1.00f , 1.00f , 0.00f , 0.90f ) ;
colors [ ImGuiCol_NavHighlight ] = ImVec4 ( 0.26f , 0.59f , 0.98f , 1.00f ) ;
colors [ ImGuiCol_NavWindowingHighlight ] = ImVec4 ( 1.00f , 1.00f , 1.00f , 0.70f ) ;
colors [ ImGuiCol_NavWindowingDimBg ] = ImVec4 ( 0.80f , 0.80f , 0.80f , 0.20f ) ;
colors [ ImGuiCol_ModalWindowDimBg ] = ImVec4 ( 0.80f , 0.80f , 0.80f , 0.35f ) ;
break ;
}
default :
{
}
}
}
} ;
}
// UI state
UI : : State stateUI ;
2024-06-15 19:33:49 +00:00
class idCommonLocal : public idCommon
{
2024-06-20 20:53:46 +00:00
private :
2024-06-21 16:01:12 +00:00
int count = 0 ;
int expectedCount = 0 ;
2024-06-20 20:53:46 +00:00
2024-06-15 19:33:49 +00:00
public :
2024-06-20 20:53:46 +00:00
bool com_refreshOnPrint = true ; // update the screen every print for dmap
ImTui : : TScreen * screen ;
2024-06-15 19:33:49 +00:00
// Initialize everything.
// if the OS allows, pass argc/argv directly (without executable name)
// otherwise pass the command line in a single string (without executable name)
virtual void Init ( int argc , const char * const * argv , const char * cmdline ) { } ;
// Shuts down everything.
2024-06-19 19:33:41 +00:00
virtual void Shutdown ( ) { }
2024-06-15 19:33:49 +00:00
virtual bool IsShuttingDown ( ) const
{
return false ;
} ;
2024-06-19 19:33:41 +00:00
virtual void CreateMainMenu ( ) { }
2024-06-15 19:33:49 +00:00
// Shuts down everything.
2024-06-19 19:33:41 +00:00
virtual void Quit ( ) { }
2024-06-15 19:33:49 +00:00
// Returns true if common initialization is complete.
virtual bool IsInitialized ( ) const
{
return true ;
} ;
// Called repeatedly as the foreground thread for rendering and game logic.
2024-06-19 19:33:41 +00:00
virtual void Frame ( ) { }
2024-06-15 19:33:49 +00:00
// Redraws the screen, handling games, guis, console, etc
// in a modal manner outside the normal frame loop
2024-06-20 20:53:46 +00:00
virtual void UpdateScreen ( bool captureToImage , bool releaseMouse = true ) ;
2024-06-15 19:33:49 +00:00
2024-06-19 19:33:41 +00:00
virtual void UpdateLevelLoadPacifier ( ) { }
2024-06-15 19:33:49 +00:00
// Checks for and removes command line "+set var arg" constructs.
// If match is NULL, all set commands will be executed, otherwise
// only a set with the exact name.
2024-06-19 19:33:41 +00:00
virtual void StartupVariable ( const char * match ) { }
2024-06-15 19:33:49 +00:00
// Begins redirection of console output to the given buffer.
virtual void BeginRedirect ( char * buffer , int buffersize , void ( * flush ) ( const char * ) ) { } ;
// Stops redirection of console output.
2024-06-19 19:33:41 +00:00
virtual void EndRedirect ( ) { }
2024-06-15 19:33:49 +00:00
// Update the screen with every message printed.
2024-06-20 20:53:46 +00:00
virtual void SetRefreshOnPrint ( bool set )
{
2024-06-21 16:01:12 +00:00
//com_refreshOnPrint = set;
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
virtual void Printf ( const char * fmt , . . . )
{
STDIO_PRINT ( " " , " " ) ;
2024-06-20 20:53:46 +00:00
if ( com_refreshOnPrint )
{
2024-06-21 16:01:12 +00:00
common - > UpdateScreen ( false ) ;
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
}
2024-06-21 16:01:12 +00:00
2024-06-15 19:33:49 +00:00
virtual void VPrintf ( const char * fmt , va_list arg )
{
2024-06-20 20:53:46 +00:00
Sys_DebugVPrintf ( fmt , arg ) ;
if ( com_refreshOnPrint )
{
2024-06-21 16:01:12 +00:00
common - > UpdateScreen ( false ) ;
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
}
2024-06-21 16:01:12 +00:00
2024-06-15 19:33:49 +00:00
virtual void DPrintf ( const char * fmt , . . . )
{
2024-06-21 16:01:12 +00:00
if ( com_developer . GetBool ( ) )
{
STDIO_PRINT ( " " , " " ) ;
2024-06-20 20:53:46 +00:00
2024-06-21 16:01:12 +00:00
if ( com_refreshOnPrint )
{
common - > UpdateScreen ( false ) ;
}
}
}
virtual void VerbosePrintf ( const char * fmt , . . . )
{
if ( dmap_verbose . GetBool ( ) )
2024-06-20 20:53:46 +00:00
{
2024-06-21 16:01:12 +00:00
STDIO_PRINT ( " " , " " ) ;
if ( com_refreshOnPrint )
{
common - > UpdateScreen ( false ) ;
}
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
}
2024-06-21 16:01:12 +00:00
2024-06-15 19:33:49 +00:00
virtual void Warning ( const char * fmt , . . . )
{
STDIO_PRINT ( " WARNING: " , " \n " ) ;
2024-06-20 20:53:46 +00:00
if ( com_refreshOnPrint )
{
2024-06-21 16:01:12 +00:00
common - > UpdateScreen ( false ) ;
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
}
2024-06-21 16:01:12 +00:00
2024-06-15 19:33:49 +00:00
virtual void DWarning ( const char * fmt , . . . )
{
2024-06-21 16:01:12 +00:00
if ( com_developer . GetBool ( ) )
2024-06-20 20:53:46 +00:00
{
2024-06-21 16:01:12 +00:00
STDIO_PRINT ( " WARNING: " , " \n " ) ;
if ( com_refreshOnPrint )
{
common - > UpdateScreen ( false ) ;
}
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
}
// Prints all queued warnings.
2024-06-19 19:33:41 +00:00
virtual void PrintWarnings ( ) { }
2024-06-15 19:33:49 +00:00
// Removes all queued warnings.
2024-06-19 19:33:41 +00:00
virtual void ClearWarnings ( const char * reason ) { }
2024-06-15 19:33:49 +00:00
virtual void Error ( const char * fmt , . . . )
{
STDIO_PRINT ( " ERROR: " , " \n " ) ;
2024-06-20 20:53:46 +00:00
if ( com_refreshOnPrint )
{
2024-06-21 16:01:12 +00:00
common - > UpdateScreen ( false ) ;
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
exit ( 0 ) ;
}
virtual void FatalError ( const char * fmt , . . . )
{
STDIO_PRINT ( " FATAL ERROR: " , " \n " ) ;
2024-06-20 20:53:46 +00:00
if ( com_refreshOnPrint )
{
2024-06-21 16:01:12 +00:00
common - > UpdateScreen ( false ) ;
2024-06-20 20:53:46 +00:00
}
2024-06-15 19:33:49 +00:00
exit ( 0 ) ;
}
// Returns key bound to the command
virtual const char * KeysFromBinding ( const char * bind )
{
return NULL ;
} ;
// Returns the binding bound to the key
virtual const char * BindingFromKey ( const char * key )
{
return NULL ;
} ;
// Directly sample a button.
virtual int ButtonState ( int key )
{
return 0 ;
} ;
// Directly sample a keystate.
virtual int KeyState ( int key )
{
return 0 ;
} ;
// Returns true if a multiplayer game is running.
// CVars and commands are checked differently in multiplayer mode.
virtual bool IsMultiplayer ( )
{
return false ;
} ;
virtual bool IsServer ( )
{
return false ;
} ;
virtual bool IsClient ( )
{
return false ;
} ;
// Returns true if the player has ever enabled the console
virtual bool GetConsoleUsed ( )
{
return false ;
} ;
// Returns the rate (in ms between snaps) that we want to generate snapshots
virtual int GetSnapRate ( )
{
return 0 ;
} ;
virtual void NetReceiveReliable ( int peer , int type , idBitMsg & msg ) { } ;
virtual void NetReceiveSnapshot ( class idSnapShot & ss ) { } ;
virtual void NetReceiveUsercmds ( int peer , idBitMsg & msg ) { } ;
// Processes the given event.
virtual bool ProcessEvent ( const sysEvent_t * event )
{
return false ;
} ;
virtual bool LoadGame ( const char * saveName )
{
return false ;
} ;
virtual bool SaveGame ( const char * saveName )
{
return false ;
} ;
virtual idGame * Game ( )
{
return NULL ;
} ;
virtual idRenderWorld * RW ( )
{
return NULL ;
} ;
virtual idSoundWorld * SW ( )
{
return NULL ;
} ;
virtual idSoundWorld * MenuSW ( )
{
return NULL ;
} ;
virtual idSession * Session ( )
{
return NULL ;
} ;
virtual idCommonDialog & Dialog ( )
{
static idCommonDialog useless ;
return useless ;
} ;
2024-06-19 19:33:41 +00:00
virtual void OnSaveCompleted ( idSaveLoadParms & parms ) { }
virtual void OnLoadCompleted ( idSaveLoadParms & parms ) { }
virtual void OnLoadFilesCompleted ( idSaveLoadParms & parms ) { }
virtual void OnEnumerationCompleted ( idSaveLoadParms & parms ) { }
virtual void OnDeleteCompleted ( idSaveLoadParms & parms ) { }
virtual void TriggerScreenWipe ( const char * _wipeMaterial , bool hold ) { }
2024-06-15 19:33:49 +00:00
2024-06-19 19:33:41 +00:00
virtual void OnStartHosting ( idMatchParameters & parms ) { }
2024-06-15 19:33:49 +00:00
virtual int GetGameFrame ( )
{
return 0 ;
} ;
virtual void LaunchExternalTitle ( int titleIndex , int device , const lobbyConnectInfo_t * const connectInfo ) { } ;
virtual void InitializeMPMapsModes ( ) { } ;
virtual const idStrList & GetModeList ( ) const
{
static idStrList useless ;
return useless ;
} ;
virtual const idStrList & GetModeDisplayList ( ) const
{
static idStrList useless ;
return useless ;
} ;
virtual const idList < mpMap_t > & GetMapList ( ) const
{
static idList < mpMap_t > useless ;
return useless ;
} ;
2024-06-19 19:33:41 +00:00
virtual void ResetPlayerInput ( int playerIndex ) { }
2024-06-15 19:33:49 +00:00
virtual bool JapaneseCensorship ( ) const
{
return false ;
} ;
virtual void QueueShowShell ( ) { } ; // Will activate the shell on the next frame.
2024-06-19 19:33:41 +00:00
void InitTool ( const toolFlag_t , const idDict * , idEntity * ) { }
2024-06-15 19:33:49 +00:00
2024-06-21 16:01:12 +00:00
void LoadPacifierBinarizeFilename ( const char * filename , const char * reason ) { }
void LoadPacifierBinarizeInfo ( const char * info ) { }
void LoadPacifierBinarizeMiplevel ( int level , int maxLevel ) { }
void LoadPacifierBinarizeProgress ( float progress ) { }
void LoadPacifierBinarizeEnd ( ) { } ;
void LoadPacifierBinarizeProgressTotal ( int total ) { }
void LoadPacifierBinarizeProgressIncrement ( int step ) { }
virtual void DmapPacifierFilename ( const char * filename , const char * reason )
{
stateUI . statusWindowHeader . Format ( " %s | %s " , filename , reason ) ;
}
virtual void DmapPacifierInfo ( VERIFY_FORMAT_STRING const char * fmt , . . . )
{
char msg [ STATUS_TEXT_SIZE ] ;
va_list argptr ;
va_start ( argptr , fmt ) ;
idStr : : vsnPrintf ( msg , STATUS_TEXT_SIZE - 1 , fmt , argptr ) ;
msg [ sizeof ( msg ) - 1 ] = ' \0 ' ;
va_end ( argptr ) ;
stateUI . statusActiveTool = msg ;
if ( com_refreshOnPrint )
{
UpdateScreen ( false ) ;
}
}
virtual void DmapPacifierCompileProgressTotal ( int total )
{
count = 0 ;
expectedCount = total ;
stateUI . progress = 0 ;
}
virtual void DmapPacifierCompileProgressIncrement ( int step )
{
count + = step ;
stateUI . progress = float ( count ) / expectedCount ;
}
2024-06-15 19:33:49 +00:00
} ;
idCommonLocal commonLocal ;
idCommon * common = & commonLocal ;
2024-06-17 19:37:10 +00:00
2024-06-19 19:33:41 +00:00
int com_editors = 0 ;
2024-06-17 19:37:10 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
main
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2024-06-21 18:45:35 +00:00
int Dmap_NoGui ( int argc , char * * argv )
2024-06-21 16:01:12 +00:00
{
2024-06-21 18:45:35 +00:00
commonLocal . com_refreshOnPrint = false ;
2024-06-21 16:01:12 +00:00
2024-06-17 19:37:10 +00:00
idLib : : common = common ;
idLib : : cvarSystem = cvarSystem ;
idLib : : fileSystem = fileSystem ;
idLib : : sys = sys ;
idLib : : Init ( ) ;
cmdSystem - > Init ( ) ;
cvarSystem - > Init ( ) ;
idCVar : : RegisterStaticVars ( ) ;
2024-06-19 20:44:30 +00:00
// set cvars before filesystem init to use mod paths
2024-06-17 19:37:10 +00:00
idCmdArgs args ;
for ( int i = 0 ; i < argc ; i + + )
{
2024-06-19 20:44:30 +00:00
if ( idStr : : Icmp ( argv [ i ] , " +set " ) = = 0 )
{
if ( ( i + 2 ) < argc )
{
cvarSystem - > SetCVarString ( argv [ i + 1 ] , argv [ i + 2 ] ) ;
}
i + = 2 ;
}
2024-06-21 18:45:35 +00:00
else if ( idStr : : Icmp ( argv [ i ] , " -t " ) = = 0 | | idStr : : Icmp ( argv [ i ] , " -nogui " ) = = 0 )
{
}
2024-06-19 20:44:30 +00:00
else
{
args . AppendArg ( argv [ i ] ) ;
}
2024-06-17 19:37:10 +00:00
}
2024-06-19 20:44:30 +00:00
fileSystem - > Init ( ) ;
declManager - > InitTool ( ) ;
2024-06-17 19:37:10 +00:00
Dmap_f ( args ) ;
2024-06-19 16:36:14 +00:00
return 0 ;
2024-06-17 19:37:10 +00:00
}
2024-06-20 18:31:05 +00:00
2024-06-21 18:45:35 +00:00
#if 0
void idCommonLocal : : UpdateScreen ( bool captureToImage , bool releaseMouse )
{
}
int main ( int argc , char * * argv )
{
return Dmap_NoGui ( argc , argv ) ;
}
2024-06-20 20:53:46 +00:00
# elif 1
void idCommonLocal : : UpdateScreen ( bool captureToImage , bool releaseMouse )
{
bool demo = true ;
bool conOpen = true ;
ImTui_ImplNcurses_NewFrame ( ) ;
ImTui_ImplText_NewFrame ( ) ;
ImGui : : NewFrame ( ) ;
{
auto wSize = ImGui : : GetIO ( ) . DisplaySize ;
if ( stateUI . showStatusWindow )
{
wSize . y - = stateUI . statusWindowHeight ;
}
wSize . x = int ( wSize . x ) ;
ImGui : : SetNextWindowPos ( ImVec2 ( 0 , 0 ) , ImGuiCond_Always ) ;
ImGui : : SetNextWindowSize ( wSize , ImGuiCond_Always ) ;
}
2024-06-21 16:01:12 +00:00
//idStr title = va( "RBDMAP version %s %s", ENGINE_VERSION, BUILD_STRING );
idStr title = va ( " RBDMAP version %s %s %s %s " , ENGINE_VERSION , BUILD_STRING , __DATE__ , __TIME__ ) ;
2024-06-20 20:53:46 +00:00
ImGui : : Begin ( title . c_str ( ) , nullptr ,
ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoScrollbar ) ;
tuiLog . Draw ( " Current Log: " , & conOpen ) ;
//ShowExampleAppConsole( &conOpen );
//ImTui::ShowDemoWindow( &demo );
ImGui : : End ( ) ;
{
auto wSize = ImGui : : GetIO ( ) . DisplaySize ;
ImGui : : SetNextWindowPos ( ImVec2 ( 0 , wSize . y - stateUI . statusWindowHeight ) , ImGuiCond_Always ) ;
ImGui : : SetNextWindowSize ( ImVec2 ( wSize . x , stateUI . statusWindowHeight ) , ImGuiCond_Always ) ;
}
2024-06-21 16:01:12 +00:00
2024-06-20 20:53:46 +00:00
ImGui : : Begin ( stateUI . statusWindowHeader , nullptr ,
ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove ) ;
2024-06-21 16:01:12 +00:00
if ( stateUI . progress < 1.0f )
{
ImGui : : ProgressBar ( stateUI . progress , ImVec2 ( 0.0f , 0.0f ) ) ;
}
else
{
ImGui : : Text ( " " ) ;
}
ImGui : : Text ( " %s " , stateUI . statusActiveTool . c_str ( ) ) ;
2024-06-20 20:53:46 +00:00
ImGui : : Text ( " Source code : https://github.com/RobertBeckebans/RBDOOM-3-BFG " ) ;
ImGui : : End ( ) ;
ImGui : : Render ( ) ;
ImTui_ImplText_RenderDrawData ( ImGui : : GetDrawData ( ) , screen ) ;
ImTui_ImplNcurses_DrawScreen ( ) ;
}
int main ( int argc , char * * argv )
{
2024-06-21 18:45:35 +00:00
for ( int i = 0 ; i < argc ; i + + )
{
if ( idStr : : Icmp ( argv [ i ] , " -t " ) = = 0 | | idStr : : Icmp ( argv [ i ] , " -nogui " ) = = 0 )
{
return Dmap_NoGui ( argc , argv ) ;
}
}
2024-06-20 20:53:46 +00:00
IMGUI_CHECKVERSION ( ) ;
ImGui : : CreateContext ( ) ;
commonLocal . screen = ImTui_ImplNcurses_Init ( true ) ;
ImTui_ImplText_Init ( ) ;
stateUI . ChangeColorScheme ( false ) ;
idLib : : common = common ;
idLib : : cvarSystem = cvarSystem ;
idLib : : fileSystem = fileSystem ;
idLib : : sys = sys ;
idLib : : Init ( ) ;
cmdSystem - > Init ( ) ;
cvarSystem - > Init ( ) ;
idCVar : : RegisterStaticVars ( ) ;
// set cvars before filesystem init to use mod paths
idCmdArgs args ;
for ( int i = 0 ; i < argc ; i + + )
{
if ( idStr : : Icmp ( argv [ i ] , " +set " ) = = 0 )
{
if ( ( i + 2 ) < argc )
{
cvarSystem - > SetCVarString ( argv [ i + 1 ] , argv [ i + 2 ] ) ;
}
i + = 2 ;
}
2024-06-21 18:45:35 +00:00
else if ( idStr : : Icmp ( argv [ i ] , " -t " ) = = 0 | | idStr : : Icmp ( argv [ i ] , " -nogui " ) = = 0 )
{
}
2024-06-20 20:53:46 +00:00
else
{
args . AppendArg ( argv [ i ] ) ;
}
}
fileSystem - > Init ( ) ;
declManager - > InitTool ( ) ;
Dmap_f ( args ) ;
2024-06-21 18:45:35 +00:00
#if 0
2024-06-20 20:53:46 +00:00
while ( true )
{
bool captureToImage = false ;
common - > UpdateScreen ( captureToImage ) ;
}
# endif
ImTui_ImplText_Shutdown ( ) ;
ImTui_ImplNcurses_Shutdown ( ) ;
return 0 ;
}
2024-06-20 18:31:05 +00:00
# else
# include "imtui/imtui.h"
# include "imtui/imtui-impl-ncurses.h"
# include "imtui/imtui-demo.h"
2024-06-21 16:01:12 +00:00
void idCommonLocal : : UpdateScreen ( bool captureToImage , bool releaseMouse )
{
}
2024-06-20 18:31:05 +00:00
int main ( )
{
IMGUI_CHECKVERSION ( ) ;
ImGui : : CreateContext ( ) ;
auto screen = ImTui_ImplNcurses_Init ( true ) ;
ImTui_ImplText_Init ( ) ;
2024-06-21 16:01:12 +00:00
stateUI . ChangeColorScheme ( false ) ;
2024-06-20 18:31:05 +00:00
bool demo = true ;
int nframes = 0 ;
float fval = 1.23f ;
while ( true )
{
ImTui_ImplNcurses_NewFrame ( ) ;
ImTui_ImplText_NewFrame ( ) ;
ImGui : : NewFrame ( ) ;
ImGui : : SetNextWindowPos ( ImVec2 ( 4 , 27 ) , ImGuiCond_Once ) ;
ImGui : : SetNextWindowSize ( ImVec2 ( 50.0 , 10.0 ) , ImGuiCond_Once ) ;
ImGui : : Begin ( " Hello, world! " ) ;
ImGui : : Text ( " NFrames = %d " , nframes + + ) ;
ImGui : : Text ( " Mouse Pos : x = %g, y = %g " , ImGui : : GetIO ( ) . MousePos . x , ImGui : : GetIO ( ) . MousePos . y ) ;
ImGui : : Text ( " Time per frame %.3f ms/frame (%.1f FPS) " , 1000.0f / ImGui : : GetIO ( ) . Framerate , ImGui : : GetIO ( ) . Framerate ) ;
ImGui : : Text ( " Float: " ) ;
ImGui : : SameLine ( ) ;
ImGui : : SliderFloat ( " ##float " , & fval , 0.0f , 10.0f ) ;
# ifndef __EMSCRIPTEN__
ImGui : : Text ( " %s " , " " ) ;
if ( ImGui : : Button ( " Exit program " , { ImGui : : GetContentRegionAvail ( ) . x , 2 } ) )
{
break ;
}
# endif
ImGui : : End ( ) ;
ImTui : : ShowDemoWindow ( & demo ) ;
ImGui : : Render ( ) ;
ImTui_ImplText_RenderDrawData ( ImGui : : GetDrawData ( ) , screen ) ;
ImTui_ImplNcurses_DrawScreen ( ) ;
}
ImTui_ImplText_Shutdown ( ) ;
ImTui_ImplNcurses_Shutdown ( ) ;
return 0 ;
}
# endif