reorganize includes
This commit is contained in:
parent
1f5edecbf6
commit
a64fa9b3dd
@ -1,10 +1,8 @@
|
|||||||
include(QtUtils)
|
include(QtUtils)
|
||||||
msvc_registry_search()
|
msvc_registry_search()
|
||||||
find_qt5(Core Widgets)
|
find_qt5(Core Widgets)
|
||||||
set(AUTOMOC OFF)
|
|
||||||
|
|
||||||
set(RESOURCE_FILES Textractor.rc Textractor.ico)
|
add_executable(${PROJECT_NAME} WIN32
|
||||||
set(gui_src
|
|
||||||
main.cpp
|
main.cpp
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
extenwindow.cpp
|
extenwindow.cpp
|
||||||
@ -12,9 +10,9 @@ set(gui_src
|
|||||||
host/host.cpp
|
host/host.cpp
|
||||||
host/textthread.cpp
|
host/textthread.cpp
|
||||||
host/util.cpp
|
host/util.cpp
|
||||||
${RESOURCE_FILES}
|
Textractor.rc
|
||||||
|
Textractor.ico
|
||||||
)
|
)
|
||||||
add_executable(${PROJECT_NAME} WIN32 ${gui_src})
|
target_link_libraries(${PROJECT_NAME} Qt5::Widgets shell32 winhttp)
|
||||||
target_link_libraries(${PROJECT_NAME} Qt5::Widgets winhttp)
|
|
||||||
|
|
||||||
install_qt5_libs(${PROJECT_NAME}) # can be commented out for consecutive builds
|
#install_qt5_libs(${PROJECT_NAME}) # can be commented out for consecutive builds
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include "ui_extenwindow.h"
|
#include "ui_extenwindow.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "types.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include <concrt.h>
|
#include <concrt.h>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
|
@ -22,6 +22,8 @@ public:
|
|||||||
~ExtenWindow();
|
~ExtenWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
inline static constexpr auto EXTEN_SAVE_FILE = u8"SavedExtensions.txt";
|
||||||
|
|
||||||
void Add(QFileInfo extenFile);
|
void Add(QFileInfo extenFile);
|
||||||
void Sync();
|
void Sync();
|
||||||
bool eventFilter(QObject* target, QEvent* event) override;
|
bool eventFilter(QObject* target, QEvent* event) override;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "const.h"
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "textthread.h"
|
#include "textthread.h"
|
||||||
#include "const.h"
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
|
@ -16,6 +16,9 @@ public:
|
|||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
inline static constexpr auto HOOK_SAVE_FILE = u8"SavedHooks.txt";
|
||||||
|
inline static constexpr auto GAME_SAVE_FILE = u8"SavedGames.txt";
|
||||||
|
|
||||||
inline static thread_local bool ok = false;
|
inline static thread_local bool ok = false;
|
||||||
|
|
||||||
void closeEvent(QCloseEvent*) override;
|
void closeEvent(QCloseEvent*) override;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "defs.h"
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
@ -9,6 +8,8 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
constexpr auto LUA_SAVE_FILE = u8"Textractor.lua";
|
||||||
|
|
||||||
extern "C" // Lua library
|
extern "C" // Lua library
|
||||||
{
|
{
|
||||||
enum LuaType { LUA_TNIL, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION, LUA_TUSERDATA, LUA_TTHREAD };
|
enum LuaType { LUA_TNIL, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION, LUA_TUSERDATA, LUA_TTHREAD };
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "defs.h"
|
|
||||||
|
|
||||||
void RemoveRepeatedChars(std::wstring& sentence)
|
void RemoveRepeatedChars(std::wstring& sentence)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include <cwctype>
|
#include <cwctype>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -7,6 +6,8 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
|
constexpr auto REPLACE_SAVE_FILE = u8"SavedReplacements.txt";
|
||||||
|
|
||||||
std::atomic<std::filesystem::file_time_type> replaceFileLastWrite;
|
std::atomic<std::filesystem::file_time_type> replaceFileLastWrite;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
class RateLimiter
|
class RateLimiter
|
||||||
{
|
{
|
||||||
|
@ -18,3 +18,54 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
template <typename T> using Array = T[];
|
||||||
|
|
||||||
|
template<typename E, typename M = std::mutex>
|
||||||
|
class ThreadSafe
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template <typename... Args>
|
||||||
|
ThreadSafe(Args&&... args) : contents(std::forward<Args>(args)...) {}
|
||||||
|
auto operator->()
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
E* operator->() { return ptr; }
|
||||||
|
std::unique_lock<M> lock;
|
||||||
|
E* ptr;
|
||||||
|
} lockedProxy{ std::unique_lock(mtx), &contents };
|
||||||
|
return lockedProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
E contents;
|
||||||
|
M mtx;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <auto F>
|
||||||
|
struct Functor
|
||||||
|
{
|
||||||
|
template <typename... Args>
|
||||||
|
auto operator()(Args&&... args) const { return std::invoke(F, std::forward<Args>(args)...); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename HandleCloser = Functor<CloseHandle>>
|
||||||
|
class AutoHandle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoHandle(HANDLE h) : h(h) {}
|
||||||
|
operator HANDLE() { return h.get(); }
|
||||||
|
PHANDLE operator&() { static_assert(sizeof(*this) == sizeof(HANDLE)); return (PHANDLE)this; }
|
||||||
|
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct HandleCleaner { void operator()(void* h) { if (h != INVALID_HANDLE_VALUE) HandleCloser()(h); } };
|
||||||
|
std::unique_ptr<void, HandleCleaner> h;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define TEST(...) inline AutoHandle<> TEST__RUNNER__DUMMY = CreateThread(nullptr, 0, [](auto) { __VA_ARGS__; return 0UL; }, NULL, 0, nullptr);
|
||||||
|
#else
|
||||||
|
#define TEST(...)
|
||||||
|
#endif
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
// vnrhook/defs.h
|
// vnrhook/defs.h
|
||||||
// 8/23/2013 jichi
|
// 8/23/2013 jichi
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
// Pipes
|
// Pipes
|
||||||
|
|
||||||
constexpr auto HOOK_PIPE = L"\\\\.\\pipe\\TEXTRACTOR_HOOK";
|
constexpr auto HOOK_PIPE = L"\\\\.\\pipe\\TEXTRACTOR_HOOK";
|
||||||
@ -27,38 +25,9 @@ constexpr auto PIPE_AVAILABLE_EVENT = L"TEXTRACTOR_PIPE_AVAILABLE";
|
|||||||
|
|
||||||
constexpr auto ITH_DLL = L"vnrhook"; // .dll but LoadLibrary automatically adds that
|
constexpr auto ITH_DLL = L"vnrhook"; // .dll but LoadLibrary automatically adds that
|
||||||
constexpr auto CONFIG_FILE = u8"Textractor.ini";
|
constexpr auto CONFIG_FILE = u8"Textractor.ini";
|
||||||
constexpr auto HOOK_SAVE_FILE = u8"SavedHooks.txt";
|
|
||||||
constexpr auto GAME_SAVE_FILE = u8"SavedGames.txt";
|
|
||||||
constexpr auto EXTEN_SAVE_FILE = u8"SavedExtensions.txt";
|
|
||||||
constexpr auto REPLACE_SAVE_FILE = u8"SavedReplacements.txt";
|
|
||||||
constexpr auto LUA_SAVE_FILE = u8"Textractor.lua";
|
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
|
|
||||||
constexpr auto DEFAULT_EXTENSIONS = u8"Remove Repetition>Lua>Copy to Clipboard>Bing Translate>Extra Window>Extra Newlines";
|
constexpr auto DEFAULT_EXTENSIONS = u8"Remove Repetition>Lua>Copy to Clipboard>Bing Translate>Extra Window>Extra Newlines";
|
||||||
|
|
||||||
inline SECURITY_ATTRIBUTES allAccess = std::invoke([] // allows non-admin processes to access kernel objects made by admin processes
|
|
||||||
{
|
|
||||||
static SECURITY_DESCRIPTOR sd = {};
|
|
||||||
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
|
|
||||||
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
|
|
||||||
return SECURITY_ATTRIBUTES{ sizeof(SECURITY_ATTRIBUTES), &sd, FALSE };
|
|
||||||
});
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void FORMAT_MESSAGE(const char* format, Args... args)
|
|
||||||
{
|
|
||||||
char buffer[250] = {};
|
|
||||||
sprintf_s<250>(buffer, format, args...);
|
|
||||||
MessageBoxA(NULL, buffer, "Textractor Message", MB_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define TEST(...) inline auto TEST__RUNNER__DUMMY = (CloseHandle(CreateThread(nullptr, 0, [](auto) { __VA_ARGS__; return 0UL; }, NULL, 0, nullptr)), 0);
|
|
||||||
#else
|
|
||||||
#define TEST(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -3,51 +3,6 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
template <typename T> using Array = T[];
|
|
||||||
|
|
||||||
template <auto F>
|
|
||||||
struct Functor
|
|
||||||
{
|
|
||||||
template <typename... Args>
|
|
||||||
auto operator()(Args&&... args) const { return std::invoke(F, std::forward<Args>(args)...); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename E, typename M = std::mutex>
|
|
||||||
class ThreadSafe
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template <typename... Args>
|
|
||||||
ThreadSafe(Args&&... args) : contents(std::forward<Args>(args)...) {}
|
|
||||||
auto operator->()
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
E* operator->() { return ptr; }
|
|
||||||
std::unique_lock<M> lock;
|
|
||||||
E* ptr;
|
|
||||||
} lockedProxy{ std::unique_lock(mtx), &contents };
|
|
||||||
return lockedProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
E contents;
|
|
||||||
M mtx;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename HandleCloser = Functor<CloseHandle>>
|
|
||||||
class AutoHandle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AutoHandle(HANDLE h) : h(h) {}
|
|
||||||
operator HANDLE() { return h.get(); }
|
|
||||||
PHANDLE operator&() { static_assert(sizeof(*this) == sizeof(HANDLE)); return (PHANDLE)this; }
|
|
||||||
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct HandleCleaner { void operator()(void* h) { if (h != INVALID_HANDLE_VALUE) HandleCloser()(h); } };
|
|
||||||
std::unique_ptr<void, HandleCleaner> h;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WinMutex // Like CMutex but works with scoped_lock
|
class WinMutex // Like CMutex but works with scoped_lock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -59,6 +14,14 @@ private:
|
|||||||
AutoHandle<> m;
|
AutoHandle<> m;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline SECURITY_ATTRIBUTES allAccess = std::invoke([] // allows non-admin processes to access kernel objects made by admin processes
|
||||||
|
{
|
||||||
|
static SECURITY_DESCRIPTOR sd = {};
|
||||||
|
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
|
||||||
|
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
|
||||||
|
return SECURITY_ATTRIBUTES{ sizeof(SECURITY_ATTRIBUTES), &sd, FALSE };
|
||||||
|
});
|
||||||
|
|
||||||
// jichi 3/7/2014: Add guessed comment
|
// jichi 3/7/2014: Add guessed comment
|
||||||
struct HookParam
|
struct HookParam
|
||||||
{
|
{
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#include "texthook.h"
|
#include "texthook.h"
|
||||||
#include "engine/match.h"
|
#include "engine/match.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "const.h"
|
|
||||||
#include "defs.h"
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "ithsys/ithsys.h"
|
#include "ithsys/ithsys.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user