Add display monitor improvements (#29)
This commit is contained in:
parent
f5060c301b
commit
25c1eeee5c
|
@ -10,11 +10,14 @@
|
||||||
#include "geometry.h"
|
#include "geometry.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "sfall_config.h"
|
||||||
#include "text_font.h"
|
#include "text_font.h"
|
||||||
#include "window_manager.h"
|
#include "window_manager.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
// The maximum number of lines display monitor can hold. Once this value
|
// The maximum number of lines display monitor can hold. Once this value
|
||||||
// is reached earlier messages are thrown away.
|
// is reached earlier messages are thrown away.
|
||||||
#define DISPLAY_MONITOR_LINES_CAPACITY (100)
|
#define DISPLAY_MONITOR_LINES_CAPACITY (100)
|
||||||
|
@ -40,6 +43,12 @@ static void displayMonitorScrollUpOnMouseEnter(int btn, int keyCode);
|
||||||
static void displayMonitorScrollDownOnMouseEnter(int btn, int keyCode);
|
static void displayMonitorScrollDownOnMouseEnter(int btn, int keyCode);
|
||||||
static void displayMonitorOnMouseExit(int btn, int keyCode);
|
static void displayMonitorOnMouseExit(int btn, int keyCode);
|
||||||
|
|
||||||
|
static void consoleFileInit();
|
||||||
|
static void consoleFileReset();
|
||||||
|
static void consoleFileExit();
|
||||||
|
static void consoleFileAddMessage(const char* message);
|
||||||
|
static void consoleFileFlush();
|
||||||
|
|
||||||
// 0x51850C
|
// 0x51850C
|
||||||
static bool gDisplayMonitorInitialized = false;
|
static bool gDisplayMonitorInitialized = false;
|
||||||
|
|
||||||
|
@ -86,6 +95,9 @@ static int _disp_start;
|
||||||
// 0x56FB58
|
// 0x56FB58
|
||||||
static unsigned int gDisplayMonitorLastBeepTimestamp;
|
static unsigned int gDisplayMonitorLastBeepTimestamp;
|
||||||
|
|
||||||
|
static std::ofstream gConsoleFileStream;
|
||||||
|
static int gConsoleFilePrintCount = 0;
|
||||||
|
|
||||||
// 0x431610
|
// 0x431610
|
||||||
int displayMonitorInit()
|
int displayMonitorInit()
|
||||||
{
|
{
|
||||||
|
@ -176,6 +188,9 @@ int displayMonitorInit()
|
||||||
_disp_curr = 0;
|
_disp_curr = 0;
|
||||||
|
|
||||||
displayMonitorRefresh();
|
displayMonitorRefresh();
|
||||||
|
|
||||||
|
// SFALL
|
||||||
|
consoleFileInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -192,6 +207,9 @@ int displayMonitorReset()
|
||||||
_disp_start = 0;
|
_disp_start = 0;
|
||||||
_disp_curr = 0;
|
_disp_curr = 0;
|
||||||
displayMonitorRefresh();
|
displayMonitorRefresh();
|
||||||
|
|
||||||
|
// SFALL
|
||||||
|
consoleFileReset();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -200,6 +218,9 @@ int displayMonitorReset()
|
||||||
void displayMonitorExit()
|
void displayMonitorExit()
|
||||||
{
|
{
|
||||||
if (gDisplayMonitorInitialized) {
|
if (gDisplayMonitorInitialized) {
|
||||||
|
// SFALL
|
||||||
|
consoleFileExit();
|
||||||
|
|
||||||
internal_free(gDisplayMonitorBackgroundFrmData);
|
internal_free(gDisplayMonitorBackgroundFrmData);
|
||||||
gDisplayMonitorInitialized = false;
|
gDisplayMonitorInitialized = false;
|
||||||
}
|
}
|
||||||
|
@ -212,6 +233,9 @@ void displayMonitorAddMessage(char* str)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SFALL
|
||||||
|
consoleFileAddMessage(str);
|
||||||
|
|
||||||
int oldFont = fontGetCurrent();
|
int oldFont = fontGetCurrent();
|
||||||
fontSetCurrent(DISPLAY_MONITOR_FONT);
|
fontSetCurrent(DISPLAY_MONITOR_FONT);
|
||||||
|
|
||||||
|
@ -389,3 +413,51 @@ void displayMonitorEnable()
|
||||||
gDisplayMonitorEnabled = true;
|
gDisplayMonitorEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void consoleFileInit()
|
||||||
|
{
|
||||||
|
char* consoleFilePath;
|
||||||
|
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONSOLE_OUTPUT_FILE_KEY, &consoleFilePath);
|
||||||
|
if (consoleFilePath != NULL && *consoleFilePath == '\0') {
|
||||||
|
consoleFilePath = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (consoleFilePath != NULL) {
|
||||||
|
gConsoleFileStream.open(consoleFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void consoleFileReset()
|
||||||
|
{
|
||||||
|
if (gConsoleFileStream.is_open()) {
|
||||||
|
gConsoleFilePrintCount = 0;
|
||||||
|
gConsoleFileStream.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void consoleFileExit()
|
||||||
|
{
|
||||||
|
if (gConsoleFileStream.is_open()) {
|
||||||
|
gConsoleFileStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void consoleFileAddMessage(const char* message)
|
||||||
|
{
|
||||||
|
if (gConsoleFileStream.is_open()) {
|
||||||
|
gConsoleFileStream << message << '\n';
|
||||||
|
|
||||||
|
gConsoleFilePrintCount++;
|
||||||
|
if (gConsoleFilePrintCount >= 20) {
|
||||||
|
consoleFileFlush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void consoleFileFlush()
|
||||||
|
{
|
||||||
|
if (gConsoleFileStream.is_open()) {
|
||||||
|
gConsoleFilePrintCount = 0;
|
||||||
|
gConsoleFileStream.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ bool sfallConfigInit(int argc, char** argv)
|
||||||
configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_REMOVE_CRITICALS_TIME_LIMITS_KEY, false);
|
configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_REMOVE_CRITICALS_TIME_LIMITS_KEY, false);
|
||||||
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BOOKS_FILE_KEY, "");
|
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BOOKS_FILE_KEY, "");
|
||||||
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_ELEVATORS_FILE_KEY, "");
|
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_ELEVATORS_FILE_KEY, "");
|
||||||
|
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONSOLE_OUTPUT_FILE_KEY, "");
|
||||||
|
|
||||||
char path[COMPAT_MAX_PATH];
|
char path[COMPAT_MAX_PATH];
|
||||||
char* executable = argv[0];
|
char* executable = argv[0];
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#define SFALL_CONFIG_REMOVE_CRITICALS_TIME_LIMITS_KEY "RemoveCriticalTimelimits"
|
#define SFALL_CONFIG_REMOVE_CRITICALS_TIME_LIMITS_KEY "RemoveCriticalTimelimits"
|
||||||
#define SFALL_CONFIG_BOOKS_FILE_KEY "BooksFile"
|
#define SFALL_CONFIG_BOOKS_FILE_KEY "BooksFile"
|
||||||
#define SFALL_CONFIG_ELEVATORS_FILE_KEY "ElevatorsFile"
|
#define SFALL_CONFIG_ELEVATORS_FILE_KEY "ElevatorsFile"
|
||||||
|
#define SFALL_CONFIG_CONSOLE_OUTPUT_FILE_KEY "ConsoleOutputPath"
|
||||||
|
|
||||||
extern bool gSfallConfigInitialized;
|
extern bool gSfallConfigInitialized;
|
||||||
extern Config gSfallConfig;
|
extern Config gSfallConfig;
|
||||||
|
|
Loading…
Reference in New Issue