mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
yeah...that was never a class. improve performance and add current process function
This commit is contained in:
parent
49432f689d
commit
fcb525df36
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace Host
|
namespace Host
|
||||||
{
|
{
|
||||||
using ProcessEventHandler = std::function<void(DWORD)>;
|
using ProcessEventHandler = void(*)(DWORD);
|
||||||
using ThreadEventHandler = std::function<void(TextThread&)>;
|
using ThreadEventHandler = std::function<void(TextThread&)>;
|
||||||
using HookEventHandler = std::function<void(HookParam, std::wstring text)>;
|
using HookEventHandler = std::function<void(HookParam, std::wstring text)>;
|
||||||
void Start(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output);
|
void Start(ProcessEventHandler Connect, ProcessEventHandler Disconnect, ThreadEventHandler Create, ThreadEventHandler Destroy, TextThread::OutputCallback Output);
|
||||||
|
@ -77,7 +77,7 @@ void TextThread::Flush()
|
|||||||
if (storage->size() > maxHistorySize) storage->erase(0, storage->size() - maxHistorySize); // https://github.com/Artikash/Textractor/issues/127#issuecomment-486882983
|
if (storage->size() > maxHistorySize) storage->erase(0, storage->size() - maxHistorySize); // https://github.com/Artikash/Textractor/issues/127#issuecomment-486882983
|
||||||
}
|
}
|
||||||
|
|
||||||
std::deque<std::wstring> sentences;
|
std::vector<std::wstring> sentences;
|
||||||
queuedSentences->swap(sentences);
|
queuedSentences->swap(sentences);
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
for (auto& sentence : sentences)
|
for (auto& sentence : sentences)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
class TextThread
|
class TextThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using OutputCallback = std::function<bool(TextThread&, std::wstring&)>;
|
using OutputCallback = bool(*)(TextThread&, std::wstring&);
|
||||||
inline static OutputCallback Output;
|
inline static OutputCallback Output;
|
||||||
|
|
||||||
inline static bool filterRepetition = true;
|
inline static bool filterRepetition = true;
|
||||||
@ -37,7 +37,7 @@ private:
|
|||||||
std::unordered_set<wchar_t> repeatingChars;
|
std::unordered_set<wchar_t> repeatingChars;
|
||||||
std::mutex bufferMutex;
|
std::mutex bufferMutex;
|
||||||
DWORD lastPushTime = 0;
|
DWORD lastPushTime = 0;
|
||||||
Synchronized<std::deque<std::wstring>> queuedSentences;
|
Synchronized<std::vector<std::wstring>> queuedSentences;
|
||||||
struct TimerDeleter { void operator()(HANDLE h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
|
struct TimerDeleter { void operator()(HANDLE h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
|
||||||
AutoHandle<TimerDeleter> timer = NULL;
|
AutoHandle<TimerDeleter> timer = NULL;
|
||||||
};
|
};
|
||||||
|
1036
GUI/mainwindow.cpp
1036
GUI/mainwindow.cpp
File diff suppressed because it is too large
Load Diff
@ -1,56 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "extenwindow.h"
|
|
||||||
#include "host/host.h"
|
|
||||||
|
|
||||||
namespace Ui
|
|
||||||
{
|
|
||||||
class MainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static constexpr auto HOOK_SAVE_FILE = u8"SavedHooks.txt";
|
void closeEvent(QCloseEvent*);
|
||||||
inline static constexpr auto GAME_SAVE_FILE = u8"SavedGames.txt";
|
|
||||||
|
|
||||||
void closeEvent(QCloseEvent*) override;
|
|
||||||
void ProcessConnected(DWORD processId);
|
|
||||||
void ProcessDisconnected(DWORD processId);
|
|
||||||
void ThreadAdded(TextThread& thread);
|
|
||||||
void ThreadRemoved(TextThread& thread);
|
|
||||||
bool SentenceReceived(TextThread& thread, std::wstring& sentence);
|
|
||||||
void OutputContextMenu(QPoint point);
|
|
||||||
QString TextThreadString(TextThread& thread);
|
|
||||||
ThreadParam ParseTextThreadString(QString ttString);
|
|
||||||
DWORD GetSelectedProcessId();
|
|
||||||
std::array<InfoForExtension, 10> GetSentenceInfo(TextThread& thread);
|
|
||||||
std::optional<std::wstring> UserSelectedProcess();
|
|
||||||
void AttachProcess();
|
|
||||||
void LaunchProcess();
|
|
||||||
void DetachProcess();
|
|
||||||
void ForgetProcess();
|
|
||||||
void AddHook();
|
|
||||||
void AddHook(QString hook);
|
|
||||||
void RemoveHooks();
|
|
||||||
void SaveHooks();
|
|
||||||
void FindHooks();
|
|
||||||
void Settings();
|
|
||||||
void Extensions();
|
|
||||||
void ViewThread(int index);
|
|
||||||
void SetOutputFont(QString font);
|
|
||||||
|
|
||||||
Ui::MainWindow* ui;
|
|
||||||
ExtenWindow* extenWindow;
|
|
||||||
std::unordered_set<DWORD> alreadyAttached;
|
|
||||||
bool autoAttach = false, autoAttachSavedOnly = true;
|
|
||||||
bool showSystemProcesses = false;
|
|
||||||
uint64_t savedThreadCtx = 0, savedThreadCtx2 = 0;
|
|
||||||
wchar_t savedThreadCode[1000] = {};
|
|
||||||
TextThread* current = nullptr;
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user