Initial public release of rem-essentials
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
#include "features/flplusplus.h"
|
||||
|
||||
#include "codec.h"
|
||||
#include "config.h"
|
||||
#include "consolewindow.h"
|
||||
#include "cursor.h"
|
||||
#include "fontresource.h"
|
||||
#include "graphics.h"
|
||||
#include "log.h"
|
||||
#include "rem/runtime.h"
|
||||
#include "rem/log.h"
|
||||
#include "restart.h"
|
||||
#include "savegame.h"
|
||||
#include "screenshot.h"
|
||||
#include "shippreviewscroll.h"
|
||||
#include "startlocation.h"
|
||||
#include "startup.h"
|
||||
#include "thnplayer.h"
|
||||
#include "touchpad.h"
|
||||
|
||||
#include <shlwapi.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
char g_dataPath[MAX_PATH]{};
|
||||
bool g_pathsInitialized = false;
|
||||
|
||||
void EnsureConfig()
|
||||
{
|
||||
config::EnsureInitialized();
|
||||
}
|
||||
|
||||
const char* GetDataPath()
|
||||
{
|
||||
if (g_pathsInitialized)
|
||||
return g_dataPath;
|
||||
|
||||
char exePath[MAX_PATH]{};
|
||||
GetModuleFileNameA(nullptr, exePath, MAX_PATH);
|
||||
PathRemoveFileSpecA(exePath);
|
||||
|
||||
strcpy_s(g_dataPath, exePath);
|
||||
PathRemoveFileSpecA(g_dataPath);
|
||||
PathAppendA(g_dataPath, "DATA\\");
|
||||
|
||||
g_pathsInitialized = true;
|
||||
return g_dataPath;
|
||||
}
|
||||
|
||||
void ReadFontFiles()
|
||||
{
|
||||
char fontsIniPath[MAX_PATH]{};
|
||||
strcpy_s(fontsIniPath, GetDataPath());
|
||||
PathAppendA(fontsIniPath, "FONTS\\fonts.ini");
|
||||
|
||||
if (PathFileExistsA(fontsIniPath))
|
||||
config::read_font_files(fontsIniPath);
|
||||
}
|
||||
}
|
||||
|
||||
namespace rem::features
|
||||
{
|
||||
void InitFlplusplusTimestampedLogs()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!logger::enable_fdump(true, false))
|
||||
rem::log::ProcMissing("timestamped_logs", "FDUMP");
|
||||
if (rem::IsServer())
|
||||
if (!logger::patch_serverlogf())
|
||||
rem::log::ProcMissing("timestamped_logs", "ServerLogF");
|
||||
}
|
||||
|
||||
void InitFlplusplusConsoleLog()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (config::get_config().logtoconsole)
|
||||
{
|
||||
RedirectIOToConsole();
|
||||
if (!logger::enable_fdump(false, true))
|
||||
rem::log::ProcMissing("log_to_console", "FDUMP");
|
||||
}
|
||||
}
|
||||
|
||||
void InitFlplusplusSavePath()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!savegame::init())
|
||||
rem::log::ProcMissing("save_path_feature", "?GetUserDataPath@@YA_NQAD@Z");
|
||||
}
|
||||
|
||||
void InitFlplusplusRestartRegeneration()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!restart::init())
|
||||
rem::log::ModuleMissing("always_regenerate_restart_file", "server.dll");
|
||||
}
|
||||
|
||||
void InitFlplusplusGraphicsBaseFixes()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!graphics::init_base_fixes())
|
||||
rem::log::ModuleMissing("graphics_base_fixes", "common.dll");
|
||||
}
|
||||
|
||||
void InitFlplusplusDetailScaling()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!graphics::init_detail_scaling())
|
||||
rem::log::ModuleMissing("graphics_detail_scaling", "common.dll");
|
||||
}
|
||||
|
||||
void InitFlplusplusPngScreenshots()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!screenshot::init_png())
|
||||
rem::log::Error("png_screenshots failed to initialize");
|
||||
}
|
||||
|
||||
void InitFlplusplusScreenshotPath()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!screenshot::init_path())
|
||||
rem::log::ProcMissing("screenshot_path_feature", "?GetScreenShotPath@@YA_NQAD@Z");
|
||||
}
|
||||
|
||||
void InitFlplusplusWineMp3CodecWarningFix()
|
||||
{
|
||||
EnsureConfig();
|
||||
codec::init();
|
||||
}
|
||||
|
||||
void InitFlplusplusStartLocationWarningFix()
|
||||
{
|
||||
EnsureConfig();
|
||||
startlocation::init();
|
||||
}
|
||||
|
||||
void InitFlplusplusFontFileLoading()
|
||||
{
|
||||
EnsureConfig();
|
||||
ReadFontFiles();
|
||||
fontresource::init(GetDataPath());
|
||||
}
|
||||
|
||||
void InitFlplusplusThnPlayer()
|
||||
{
|
||||
EnsureConfig();
|
||||
if (!thnplayer::init())
|
||||
rem::log::ProcMissing("thn_player", "THN runtime exports");
|
||||
}
|
||||
|
||||
void InitFlplusplusShipPreviewScroll()
|
||||
{
|
||||
EnsureConfig();
|
||||
shippreviewscroll::init();
|
||||
}
|
||||
|
||||
void InitFlplusplusFailedSaveDirIds()
|
||||
{
|
||||
EnsureConfig();
|
||||
startup::init();
|
||||
}
|
||||
|
||||
void InitFlplusplusTouchpadSupport()
|
||||
{
|
||||
EnsureConfig();
|
||||
touchpad::init();
|
||||
}
|
||||
|
||||
void InitFlplusplusCursorConfinement()
|
||||
{
|
||||
EnsureConfig();
|
||||
cursor::init();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user