mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
reorganize config files
This commit is contained in:
parent
aa4b980422
commit
3ff31e0ac6
@ -1,6 +1,5 @@
|
|||||||
#include "extenwindow.h"
|
#include "extenwindow.h"
|
||||||
#include "ui_extenwindow.h"
|
#include "ui_extenwindow.h"
|
||||||
#include "defs.h"
|
|
||||||
#include <concrt.h>
|
#include <concrt.h>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -159,7 +159,7 @@ namespace
|
|||||||
std::wstring path = std::wstring(process).erase(process.rfind(L'\\'));
|
std::wstring path = std::wstring(process).erase(process.rfind(L'\\'));
|
||||||
|
|
||||||
PROCESS_INFORMATION info = {};
|
PROCESS_INFORMATION info = {};
|
||||||
auto useLocale = QSettings(CONFIG_FILE, QSettings::IniFormat).value(CONFIG_JP_LOCALE, PROMPT).toInt();
|
auto useLocale = openSettings().value(CONFIG_JP_LOCALE, PROMPT).toInt();
|
||||||
if (!x64 && (useLocale == ALWAYS || (useLocale == PROMPT && QMessageBox::question(This, SELECT_PROCESS, USE_JP_LOCALE) == QMessageBox::Yes)))
|
if (!x64 && (useLocale == ALWAYS || (useLocale == PROMPT && QMessageBox::question(This, SELECT_PROCESS, USE_JP_LOCALE) == QMessageBox::Yes)))
|
||||||
{
|
{
|
||||||
if (HMODULE localeEmulator = LoadLibraryW(L"LoaderDll"))
|
if (HMODULE localeEmulator = LoadLibraryW(L"LoaderDll"))
|
||||||
@ -196,7 +196,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if (auto processName = GetModuleFilename(selectedProcessId)) if (int last = processName->rfind(L'\\') + 1)
|
if (auto processName = GetModuleFilename(selectedProcessId)) if (int last = processName->rfind(L'\\') + 1)
|
||||||
{
|
{
|
||||||
std::wstring configFile = std::wstring(processName.value()).replace(last, std::wstring::npos, L"TextractorConfig.txt");
|
std::wstring configFile = std::wstring(processName.value()).replace(last, std::wstring::npos, GAME_CONFIG_FILE);
|
||||||
if (!std::filesystem::exists(configFile)) QTextFile(S(configFile), QFile::WriteOnly).write("see https://github.com/Artikash/Textractor/wiki/Game-configuration-file");
|
if (!std::filesystem::exists(configFile)) QTextFile(S(configFile), QFile::WriteOnly).write("see https://github.com/Artikash/Textractor/wiki/Game-configuration-file");
|
||||||
_wspawnlp(_P_DETACH, L"notepad", L"notepad", configFile.c_str(), NULL);
|
_wspawnlp(_P_DETACH, L"notepad", L"notepad", configFile.c_str(), NULL);
|
||||||
}
|
}
|
||||||
@ -665,7 +665,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
QSettings(CONFIG_FILE, QSettings::IniFormat).setValue(WINDOW, geometry());
|
openSettings().setValue(WINDOW, geometry());
|
||||||
CleanupExtensions();
|
CleanupExtensions();
|
||||||
SetErrorMode(SEM_NOGPFAULTERRORBOX);
|
SetErrorMode(SEM_NOGPFAULTERRORBOX);
|
||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "ui_extrawindow.h"
|
#include "ui_extrawindow.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "blockmarkup.h"
|
#include "blockmarkup.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
@ -77,7 +76,7 @@ struct PrettyWindow : QDialog
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QMenu menu{ ui.display };
|
QMenu menu{ ui.display };
|
||||||
QSettings settings{ CONFIG_FILE, QSettings::IniFormat, this };
|
QSettings settings{ openSettings(this) };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RequestFont()
|
void RequestFont()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "blockmarkup.h"
|
#include "blockmarkup.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -21,7 +20,6 @@ const char* LANGUAGE = u8"Language";
|
|||||||
const std::string TRANSLATION_CACHE_FILE = FormatString("%sCache.txt", TRANSLATION_PROVIDER);
|
const std::string TRANSLATION_CACHE_FILE = FormatString("%sCache.txt", TRANSLATION_PROVIDER);
|
||||||
|
|
||||||
Synchronized<std::wstring> translateTo = L"en";
|
Synchronized<std::wstring> translateTo = L"en";
|
||||||
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
|
|
||||||
|
|
||||||
Synchronized<std::map<std::wstring, std::wstring>> translationCache;
|
Synchronized<std::map<std::wstring, std::wstring>> translationCache;
|
||||||
int savedSize;
|
int savedSize;
|
||||||
@ -41,6 +39,7 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
|
|||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
{
|
{
|
||||||
|
static QSettings settings = openSettings();
|
||||||
settings.beginGroup(TRANSLATION_PROVIDER);
|
settings.beginGroup(TRANSLATION_PROVIDER);
|
||||||
if (settings.contains(LANGUAGE)) translateTo->assign(S(settings.value(LANGUAGE).toString()));
|
if (settings.contains(LANGUAGE)) translateTo->assign(S(settings.value(LANGUAGE).toString()));
|
||||||
else QTimer::singleShot(0, []
|
else QTimer::singleShot(0, []
|
||||||
|
@ -24,10 +24,6 @@ constexpr auto PIPE_AVAILABLE_EVENT = L"TEXTRACTOR_PIPE_AVAILABLE";
|
|||||||
// Files
|
// Files
|
||||||
|
|
||||||
constexpr auto ITH_DLL = L"texthook"; // .dll but LoadLibrary automatically adds that
|
constexpr auto ITH_DLL = L"texthook"; // .dll but LoadLibrary automatically adds that
|
||||||
constexpr auto CONFIG_FILE = u8"Textractor.ini";
|
constexpr auto& GAME_CONFIG_FILE = L"TextractorConfig.txt";
|
||||||
|
|
||||||
// Misc
|
|
||||||
|
|
||||||
constexpr auto WINDOW = u8"Window";
|
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
|
|
||||||
static thread_local bool ok;
|
static thread_local bool ok;
|
||||||
|
|
||||||
|
constexpr auto CONFIG_FILE = u8"Textractor.ini";
|
||||||
|
constexpr auto WINDOW = u8"Window";
|
||||||
|
inline QSettings openSettings(QObject* parent = nullptr) { return { CONFIG_FILE, QSettings::IniFormat, parent }; }
|
||||||
|
|
||||||
struct QTextFile : QFile { QTextFile(QString name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } };
|
struct QTextFile : QFile { QTextFile(QString name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } };
|
||||||
inline std::wstring S(const QString& s) { return { s.toStdWString() }; }
|
inline std::wstring S(const QString& s) { return { s.toStdWString() }; }
|
||||||
inline QString S(const std::string& s) { return QString::fromStdString(s); }
|
inline QString S(const std::string& s) { return QString::fromStdString(s); }
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "match.h"
|
#include "match.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "defs.h"
|
||||||
#include "native/pchooks.h"
|
#include "native/pchooks.h"
|
||||||
|
|
||||||
extern const char* HIJACK_ERROR;
|
extern const char* HIJACK_ERROR;
|
||||||
@ -43,9 +44,9 @@ namespace Engine
|
|||||||
{
|
{
|
||||||
GetModuleFileNameW(nullptr, processPath, MAX_PATH);
|
GetModuleFileNameW(nullptr, processPath, MAX_PATH);
|
||||||
processName = wcsrchr(processPath, L'\\') + 1;
|
processName = wcsrchr(processPath, L'\\') + 1;
|
||||||
wchar_t configFilename[MAX_PATH + sizeof(L"TextractorConfig.txt")];
|
wchar_t configFilename[MAX_PATH + std::size(GAME_CONFIG_FILE)];
|
||||||
wcsncpy_s(configFilename, processPath, MAX_PATH - 1);
|
wcsncpy_s(configFilename, processPath, MAX_PATH - 1);
|
||||||
wcscpy_s(wcsrchr(configFilename, L'\\') + 1, sizeof(L"TextractorConfig.txt"), L"TextractorConfig.txt");
|
wcscpy_s(wcsrchr(configFilename, L'\\') + 1, std::size(GAME_CONFIG_FILE), GAME_CONFIG_FILE);
|
||||||
if (AutoHandle<> configFile = CreateFileW(configFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))
|
if (AutoHandle<> configFile = CreateFileW(configFilename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))
|
||||||
{
|
{
|
||||||
if (ReadFile(configFile, configFileData, sizeof(configFileData) - 1, DUMMY, nullptr)) ConsoleOutput("Textractor: game configuration loaded");
|
if (ReadFile(configFile, configFileData, sizeof(configFileData) - 1, DUMMY, nullptr)) ConsoleOutput("Textractor: game configuration loaded");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user