2021-07-01 18:02:16 +02:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <vcl.h>
|
|
|
|
#pragma hdrstop
|
2023-08-15 15:38:50 +02:00
|
|
|
#include <IniFiles.hpp>
|
2023-11-12 23:58:10 +01:00
|
|
|
#include <IOUtils.hpp>
|
2023-08-15 15:38:50 +02:00
|
|
|
#include <System.Hash.hpp>
|
2021-07-01 18:02:16 +02:00
|
|
|
#include <tchar.h>
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#include <Vcl.Styles.hpp>
|
|
|
|
#include <Vcl.Themes.hpp>
|
|
|
|
USEFORM("ConfigFormUnit.cpp", ConfigForm);
|
|
|
|
//---------------------------------------------------------------------------
|
2023-11-12 23:58:10 +01:00
|
|
|
|
|
|
|
#define GAME_PATH (TPath::GetDirectoryName(Application->ExeName) + "\\")
|
|
|
|
|
2021-07-01 18:02:16 +02:00
|
|
|
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Application->Initialize();
|
|
|
|
Application->MainFormOnTaskBar = true;
|
2023-08-13 17:15:59 +02:00
|
|
|
|
2023-08-15 15:38:50 +02:00
|
|
|
HWND hwnd =
|
|
|
|
FindWindow(
|
|
|
|
THashSHA1::GetHashString(Application->ExeName).w_str(), NULL);
|
|
|
|
|
2023-08-15 16:16:49 +02:00
|
|
|
if (hwnd && ParamStr(1) != L"-restart") {
|
2023-08-15 15:38:50 +02:00
|
|
|
|
|
|
|
if (IsIconic(hwnd)) {
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetForegroundWindow(hwnd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-12-08 00:51:16 +01:00
|
|
|
auto iniPath = System::Sysutils::GetEnvironmentVariable(
|
|
|
|
"CNC_DDRAW_CONFIG_FILE");
|
|
|
|
|
|
|
|
auto *ini =
|
|
|
|
new TIniFile(iniPath.Length() ? iniPath : GAME_PATH + "ddraw.ini");
|
|
|
|
|
2023-08-13 17:15:59 +02:00
|
|
|
auto theme = ini->ReadString("ddraw", "configtheme", "Windows10");
|
|
|
|
|
|
|
|
TStyleManager::TrySetStyle(
|
|
|
|
theme == "Cobalt XEMedia" ? "Cobalt XEMedia" : "Windows10");
|
|
|
|
|
|
|
|
delete ini;
|
|
|
|
|
2021-07-01 18:02:16 +02:00
|
|
|
Application->CreateForm(__classid(TConfigForm), &ConfigForm);
|
|
|
|
Application->Run();
|
|
|
|
}
|
|
|
|
catch (Exception &exception)
|
|
|
|
{
|
|
|
|
Application->ShowException(&exception);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
throw Exception("");
|
|
|
|
}
|
|
|
|
catch (Exception &exception)
|
|
|
|
{
|
|
|
|
Application->ShowException(&exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|