2016-01-16 18:22:08 -05:00
|
|
|
|
#include "STDInclude.hpp"
|
2015-12-23 08:45:53 -05:00
|
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
|
{
|
2015-12-27 08:05:08 -05:00
|
|
|
|
char** Console::GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType)
|
|
|
|
|
{
|
2016-01-08 13:34:00 -05:00
|
|
|
|
if (path == (char*)0xBAADF00D || path == (char*)0xCDCDCDCD || IsBadReadPtr(path, 1)) return nullptr;
|
2015-12-27 08:05:08 -05:00
|
|
|
|
return Game::FS_ListFiles(path, extension, behavior, numfiles, allocTrackType);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-23 08:45:53 -05:00
|
|
|
|
void Console::ToggleConsole()
|
|
|
|
|
{
|
|
|
|
|
// possibly cls.keyCatchers?
|
2015-12-23 09:00:01 -05:00
|
|
|
|
Utils::Hook::Xor<DWORD>(0xB2C538, 1);
|
2015-12-23 08:45:53 -05:00
|
|
|
|
|
|
|
|
|
// g_consoleField
|
|
|
|
|
Game::Field_Clear((void*)0xA1B6B0);
|
|
|
|
|
|
|
|
|
|
// show console output?
|
|
|
|
|
Utils::Hook::Set<BYTE>(0xA15F38, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console::Console()
|
|
|
|
|
{
|
2016-01-16 18:22:08 -05:00
|
|
|
|
// if (!Dedicated::IsDedicated())
|
|
|
|
|
// {
|
|
|
|
|
// FreeConsole();
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// initscr();
|
|
|
|
|
// raw();
|
|
|
|
|
// noecho();
|
|
|
|
|
//
|
|
|
|
|
// // patch functions
|
|
|
|
|
// #define WIDTH 80
|
|
|
|
|
// #define HEIGHT 25
|
|
|
|
|
// #define OUTPUT_HEIGHT 250
|
|
|
|
|
// #define OUTPUT_MAX_TOP (OUTPUT_HEIGHT - (HEIGHT - 2))
|
|
|
|
|
//
|
|
|
|
|
// WINDOW* outputWindow = newpad(OUTPUT_HEIGHT, WIDTH);
|
|
|
|
|
// WINDOW* inputWindow = newwin(1, WIDTH, HEIGHT - 1, 0);
|
|
|
|
|
// WINDOW* infoWindow = newwin(1, WIDTH, 0, 0);
|
|
|
|
|
//
|
|
|
|
|
// scrollok(outputWindow, true);
|
|
|
|
|
// scrollok(inputWindow, true);
|
|
|
|
|
// nodelay(inputWindow, true);
|
|
|
|
|
// keypad(inputWindow, true);
|
|
|
|
|
//
|
|
|
|
|
// if (has_colors())
|
|
|
|
|
// {
|
|
|
|
|
// start_color();
|
|
|
|
|
// init_pair(1, COLOR_BLACK, COLOR_WHITE);
|
|
|
|
|
// init_pair(2, COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
// init_pair(3, COLOR_RED, COLOR_BLACK);
|
|
|
|
|
// init_pair(4, COLOR_GREEN, COLOR_BLACK);
|
|
|
|
|
// init_pair(5, COLOR_YELLOW, COLOR_BLACK);
|
|
|
|
|
// init_pair(6, COLOR_BLUE, COLOR_BLACK);
|
|
|
|
|
// init_pair(7, COLOR_CYAN, COLOR_BLACK);
|
|
|
|
|
// init_pair(8, COLOR_RED, COLOR_BLACK);
|
|
|
|
|
// init_pair(9, COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
// init_pair(10, COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
// //init_pair(2, COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// wbkgd(infoWindow, COLOR_PAIR(1));
|
|
|
|
|
//
|
|
|
|
|
// wrefresh(infoWindow);
|
|
|
|
|
// //wrefresh(outputWindow);
|
|
|
|
|
// wrefresh(inputWindow);
|
|
|
|
|
//
|
|
|
|
|
// //prefresh(outputWindow, (currentOutputTop >= 1) ? currentOutputTop - 1 : 0, 0, 1, 0, HEIGHT - 2, WIDTH);
|
|
|
|
|
//
|
|
|
|
|
// waddch(outputWindow, 'g');
|
|
|
|
|
// waddch(outputWindow, 'i');
|
|
|
|
|
//
|
|
|
|
|
// prefresh(outputWindow, 0, 0, 1, 0, HEIGHT - 2, WIDTH);
|
|
|
|
|
|
2015-12-23 08:45:53 -05:00
|
|
|
|
// External console
|
2016-01-05 19:23:43 -05:00
|
|
|
|
if (Flags::HasFlag("console") || Dedicated::IsDedicated() || ZoneBuilder::IsEnabled())
|
2016-01-04 07:59:30 -05:00
|
|
|
|
{
|
|
|
|
|
Utils::Hook::Nop(0x60BB58, 11);
|
|
|
|
|
}
|
2015-12-23 08:45:53 -05:00
|
|
|
|
|
2015-12-30 22:53:48 -05:00
|
|
|
|
// Console '%s: %s> ' string
|
|
|
|
|
Utils::Hook::Set<char*>(0x5A44B4, "IW4x: r" REVISION_STR "> ");
|
2015-12-23 08:45:53 -05:00
|
|
|
|
|
|
|
|
|
// Internal console
|
|
|
|
|
Utils::Hook(0x4F690C, Console::ToggleConsole, HOOK_CALL).Install()->Quick();
|
|
|
|
|
Utils::Hook(0x4F65A5, Console::ToggleConsole, HOOK_JUMP).Install()->Quick();
|
2015-12-27 08:05:08 -05:00
|
|
|
|
|
|
|
|
|
// Check for bad food ;)
|
|
|
|
|
Utils::Hook(0x4CB9F4, Console::GetAutoCompleteFileList, HOOK_CALL).Install()->Quick();
|
2015-12-23 08:45:53 -05:00
|
|
|
|
}
|
|
|
|
|
}
|