Keep Curses Headers to the Console Module (#539)
This commit is contained in:
parent
a4980f7bb6
commit
c946e26467
4
deps/premake/mongoose.lua
vendored
4
deps/premake/mongoose.lua
vendored
@ -20,8 +20,8 @@ function mongoose.project()
|
|||||||
|
|
||||||
files
|
files
|
||||||
{
|
{
|
||||||
path.join(mongoose.source, "*.c"),
|
path.join(mongoose.source, "mongoose.c"),
|
||||||
path.join(mongoose.source, "*.h"),
|
path.join(mongoose.source, "mongoose.h"),
|
||||||
}
|
}
|
||||||
|
|
||||||
warnings "Off"
|
warnings "Off"
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#include <STDInclude.hpp>
|
#include <STDInclude.hpp>
|
||||||
|
#undef MOUSE_MOVED
|
||||||
|
#include <curses.h>
|
||||||
|
|
||||||
#define REMOVE_HEADERBAR 1
|
#define REMOVE_HEADERBAR 1
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
WINDOW* Console::OutputWindow;
|
static WINDOW* OutputWindow;
|
||||||
WINDOW* Console::InputWindow;
|
static WINDOW* InputWindow;
|
||||||
WINDOW* Console::InfoWindow;
|
static WINDOW* InfoWindow;
|
||||||
|
|
||||||
int Console::OutputTop = 0;
|
int Console::OutputTop = 0;
|
||||||
int Console::OutBuffer = 0;
|
int Console::OutBuffer = 0;
|
||||||
@ -79,9 +81,9 @@ namespace Components
|
|||||||
clientCount = Game::PartyHost_CountMembers(reinterpret_cast<Game::PartyData*>(0x1081C00));
|
clientCount = Game::PartyHost_CountMembers(reinterpret_cast<Game::PartyData*>(0x1081C00));
|
||||||
}
|
}
|
||||||
|
|
||||||
wclear(Console::InfoWindow);
|
wclear(InfoWindow);
|
||||||
wprintw(Console::InfoWindow, "%s : %d/%d players : map %s", hostname.data(), clientCount, maxclientCount, (!mapname.empty()) ? mapname.data() : "none");
|
wprintw(InfoWindow, "%s : %d/%d players : map %s", hostname.data(), clientCount, maxclientCount, (!mapname.empty()) ? mapname.data() : "none");
|
||||||
wnoutrefresh(Console::InfoWindow);
|
wnoutrefresh(InfoWindow);
|
||||||
}
|
}
|
||||||
else if (IsWindow(Console::GetWindow()) != FALSE)
|
else if (IsWindow(Console::GetWindow()) != FALSE)
|
||||||
{
|
{
|
||||||
@ -91,13 +93,13 @@ namespace Components
|
|||||||
|
|
||||||
void Console::ShowPrompt()
|
void Console::ShowPrompt()
|
||||||
{
|
{
|
||||||
wattron(Console::InputWindow, COLOR_PAIR(10) | A_BOLD);
|
wattron(InputWindow, COLOR_PAIR(10) | A_BOLD);
|
||||||
wprintw(Console::InputWindow, "%s> ", VERSION);
|
wprintw(InputWindow, "%s> ", VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::RefreshOutput()
|
void Console::RefreshOutput()
|
||||||
{
|
{
|
||||||
prefresh(Console::OutputWindow, ((Console::OutputTop > 0) ? (Console::OutputTop - 1) : 0), 0, 1, 0, Console::Height - 2, Console::Width - 1);
|
prefresh(OutputWindow, ((Console::OutputTop > 0) ? (Console::OutputTop - 1) : 0), 0, 1, 0, Console::Height - 2, Console::Width - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::ScrollOutput(int amount)
|
void Console::ScrollOutput(int amount)
|
||||||
@ -173,7 +175,7 @@ namespace Components
|
|||||||
if (!Console::HasConsole)
|
if (!Console::HasConsole)
|
||||||
{
|
{
|
||||||
Console::ShowPrompt();
|
Console::ShowPrompt();
|
||||||
wrefresh(Console::InputWindow);
|
wrefresh(InputWindow);
|
||||||
Console::HasConsole = true;
|
Console::HasConsole = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +186,7 @@ namespace Components
|
|||||||
Console::LastRefresh = currentTime;
|
Console::LastRefresh = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
int c = wgetch(Console::InputWindow);
|
int c = wgetch(InputWindow);
|
||||||
|
|
||||||
if (c == ERR)
|
if (c == ERR)
|
||||||
{
|
{
|
||||||
@ -196,21 +198,21 @@ namespace Components
|
|||||||
case '\r':
|
case '\r':
|
||||||
case 459: // keypad enter
|
case 459: // keypad enter
|
||||||
{
|
{
|
||||||
wattron(Console::OutputWindow, COLOR_PAIR(10) | A_BOLD);
|
wattron(OutputWindow, COLOR_PAIR(10) | A_BOLD);
|
||||||
wprintw(Console::OutputWindow, "%s", "]");
|
wprintw(OutputWindow, "%s", "]");
|
||||||
|
|
||||||
if (Console::LineBufferIndex)
|
if (Console::LineBufferIndex)
|
||||||
{
|
{
|
||||||
wprintw(Console::OutputWindow, "%s", Console::LineBuffer);
|
wprintw(OutputWindow, "%s", Console::LineBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintw(Console::OutputWindow, "%s", "\n");
|
wprintw(OutputWindow, "%s", "\n");
|
||||||
wattroff(Console::OutputWindow, A_BOLD);
|
wattroff(OutputWindow, A_BOLD);
|
||||||
wclear(Console::InputWindow);
|
wclear(InputWindow);
|
||||||
|
|
||||||
Console::ShowPrompt();
|
Console::ShowPrompt();
|
||||||
|
|
||||||
wrefresh(Console::InputWindow);
|
wrefresh(InputWindow);
|
||||||
|
|
||||||
Console::ScrollOutput(1);
|
Console::ScrollOutput(1);
|
||||||
Console::RefreshOutput();
|
Console::RefreshOutput();
|
||||||
@ -231,11 +233,11 @@ namespace Components
|
|||||||
Console::LineBuffer[0] = '\0';
|
Console::LineBuffer[0] = '\0';
|
||||||
Console::LineBufferIndex = 0;
|
Console::LineBufferIndex = 0;
|
||||||
|
|
||||||
wclear(Console::InputWindow);
|
wclear(InputWindow);
|
||||||
|
|
||||||
Console::ShowPrompt();
|
Console::ShowPrompt();
|
||||||
|
|
||||||
wrefresh(Console::InputWindow);
|
wrefresh(InputWindow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 8: // backspace
|
case 8: // backspace
|
||||||
@ -245,8 +247,8 @@ namespace Components
|
|||||||
Console::LineBufferIndex--;
|
Console::LineBufferIndex--;
|
||||||
Console::LineBuffer[Console::LineBufferIndex] = '\0';
|
Console::LineBuffer[Console::LineBufferIndex] = '\0';
|
||||||
|
|
||||||
wprintw(Console::InputWindow, "%c %c", static_cast<char>(c), static_cast<char>(c));
|
wprintw(InputWindow, "%c %c", static_cast<char>(c), static_cast<char>(c));
|
||||||
wrefresh(Console::InputWindow);
|
wrefresh(InputWindow);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -264,10 +266,10 @@ namespace Components
|
|||||||
}
|
}
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
{
|
{
|
||||||
wclear(Console::InputWindow);
|
wclear(InputWindow);
|
||||||
Console::ShowPrompt();
|
Console::ShowPrompt();
|
||||||
wprintw(Console::InputWindow, "%s", Console::LineBuffer2);
|
wprintw(InputWindow, "%s", Console::LineBuffer2);
|
||||||
wrefresh(Console::InputWindow);
|
wrefresh(InputWindow);
|
||||||
|
|
||||||
strcpy_s(Console::LineBuffer, Console::LineBuffer2);
|
strcpy_s(Console::LineBuffer, Console::LineBuffer2);
|
||||||
Console::LineBufferIndex = strlen(Console::LineBuffer);
|
Console::LineBufferIndex = strlen(Console::LineBuffer);
|
||||||
@ -281,8 +283,8 @@ namespace Components
|
|||||||
|
|
||||||
Console::LineBuffer[Console::LineBufferIndex++] = static_cast<char>(c);
|
Console::LineBuffer[Console::LineBufferIndex++] = static_cast<char>(c);
|
||||||
Console::LineBuffer[Console::LineBufferIndex] = '\0';
|
Console::LineBuffer[Console::LineBufferIndex] = '\0';
|
||||||
wprintw(Console::InputWindow, "%c", static_cast<char>(c));
|
wprintw(InputWindow, "%c", static_cast<char>(c));
|
||||||
wrefresh(Console::InputWindow);
|
wrefresh(InputWindow);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -294,17 +296,17 @@ namespace Components
|
|||||||
{
|
{
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
delwin(Console::OutputWindow);
|
delwin(OutputWindow);
|
||||||
delwin(Console::InputWindow);
|
delwin(InputWindow);
|
||||||
delwin(Console::InfoWindow);
|
delwin(InfoWindow);
|
||||||
endwin();
|
endwin();
|
||||||
delscreen(SP);
|
delscreen(SP);
|
||||||
}
|
}
|
||||||
__finally {}
|
__finally {}
|
||||||
|
|
||||||
Console::OutputWindow = nullptr;
|
OutputWindow = nullptr;
|
||||||
Console::InputWindow = nullptr;
|
InputWindow = nullptr;
|
||||||
Console::InfoWindow = nullptr;
|
InfoWindow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::Create()
|
void Console::Create()
|
||||||
@ -331,15 +333,15 @@ namespace Components
|
|||||||
raw();
|
raw();
|
||||||
noecho();
|
noecho();
|
||||||
|
|
||||||
Console::OutputWindow = newpad(Console::Height - 1, Console::Width);
|
OutputWindow = newpad(Console::Height - 1, Console::Width);
|
||||||
Console::InputWindow = newwin(1, Console::Width, Console::Height - 1, 0);
|
InputWindow = newwin(1, Console::Width, Console::Height - 1, 0);
|
||||||
Console::InfoWindow = newwin(1, Console::Width, 0, 0);
|
InfoWindow = newwin(1, Console::Width, 0, 0);
|
||||||
|
|
||||||
scrollok(Console::OutputWindow, true);
|
scrollok(OutputWindow, true);
|
||||||
idlok(Console::OutputWindow, true);
|
idlok(OutputWindow, true);
|
||||||
scrollok(Console::InputWindow, true);
|
scrollok(InputWindow, true);
|
||||||
nodelay(Console::InputWindow, true);
|
nodelay(InputWindow, true);
|
||||||
keypad(Console::InputWindow, true);
|
keypad(InputWindow, true);
|
||||||
|
|
||||||
if (has_colors())
|
if (has_colors())
|
||||||
{
|
{
|
||||||
@ -356,10 +358,10 @@ namespace Components
|
|||||||
init_pair(10, COLOR_WHITE, COLOR_BLACK);
|
init_pair(10, COLOR_WHITE, COLOR_BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
wbkgd(Console::InfoWindow, COLOR_PAIR(1));
|
wbkgd(InfoWindow, COLOR_PAIR(1));
|
||||||
|
|
||||||
wrefresh(Console::InfoWindow);
|
wrefresh(InfoWindow);
|
||||||
wrefresh(Console::InputWindow);
|
wrefresh(InputWindow);
|
||||||
|
|
||||||
Console::RefreshOutput();
|
Console::RefreshOutput();
|
||||||
}
|
}
|
||||||
@ -390,7 +392,7 @@ namespace Components
|
|||||||
|
|
||||||
void Console::Print(const char* message)
|
void Console::Print(const char* message)
|
||||||
{
|
{
|
||||||
if (!Console::OutputWindow) return;
|
if (!OutputWindow) return;
|
||||||
|
|
||||||
const char* p = message;
|
const char* p = message;
|
||||||
while (*p != '\0')
|
while (*p != '\0')
|
||||||
@ -404,30 +406,18 @@ namespace Components
|
|||||||
|
|
||||||
if (color < 9 && color > 0)
|
if (color < 9 && color > 0)
|
||||||
{
|
{
|
||||||
wattron(Console::OutputWindow, COLOR_PAIR(color + 2));
|
wattron(OutputWindow, COLOR_PAIR(color + 2));
|
||||||
++p;
|
++p;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waddch(Console::OutputWindow, *p);
|
waddch(OutputWindow, *p);
|
||||||
|
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
wattron(Console::OutputWindow, COLOR_PAIR(9));
|
wattron(OutputWindow, COLOR_PAIR(9));
|
||||||
|
|
||||||
// int currentTime = static_cast<int>(GetTickCount64()); // Make our compiler happy
|
|
||||||
//
|
|
||||||
// if (!Console::HasConsole)
|
|
||||||
// {
|
|
||||||
// Console::RefreshOutput();
|
|
||||||
// }
|
|
||||||
// else if ((currentTime - Console::LastRefresh) > 100)
|
|
||||||
// {
|
|
||||||
// Console::RefreshOutput();
|
|
||||||
// Console::LastRefresh = currentTime;
|
|
||||||
// }
|
|
||||||
|
|
||||||
Console::RefreshOutput();
|
Console::RefreshOutput();
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,6 @@ namespace Components
|
|||||||
static constexpr int OUTPUT_BOX = 0x64;
|
static constexpr int OUTPUT_BOX = 0x64;
|
||||||
static constexpr int INPUT_BOX = 0x65;
|
static constexpr int INPUT_BOX = 0x65;
|
||||||
|
|
||||||
// Text-based console stuff
|
|
||||||
static WINDOW* OutputWindow;
|
|
||||||
static WINDOW* InputWindow;
|
|
||||||
static WINDOW* InfoWindow;
|
|
||||||
|
|
||||||
static int Width;
|
static int Width;
|
||||||
static int Height;
|
static int Height;
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ namespace Components
|
|||||||
if (!Data.contains(key))
|
if (!Data.contains(key))
|
||||||
{
|
{
|
||||||
Game::Scr_Error(Utils::String::VA("^1StorageGet: Store does not have key '%s'!\n", key));
|
Game::Scr_Error(Utils::String::VA("^1StorageGet: Store does not have key '%s'!\n", key));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& data = Data.at(key);
|
const auto& data = Data.at(key);
|
||||||
@ -91,7 +90,6 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Data.clear();
|
Data.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptStorage::ScriptStorage()
|
ScriptStorage::ScriptStorage()
|
||||||
|
@ -79,7 +79,6 @@
|
|||||||
#pragma warning(disable: 6387)
|
#pragma warning(disable: 6387)
|
||||||
#pragma warning(disable: 26812)
|
#pragma warning(disable: 26812)
|
||||||
|
|
||||||
#include <curses.h>
|
|
||||||
#include <gsl/gsl>
|
#include <gsl/gsl>
|
||||||
#include <tomcrypt.h>
|
#include <tomcrypt.h>
|
||||||
#include <udis86.h>
|
#include <udis86.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user