From 97f3f51758c8477cc965ab26b2c03a295ecb0d8c Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Fri, 14 Dec 2018 22:26:49 -0500 Subject: [PATCH] more consistent/organized text --- GUI/extenwindow.cpp | 2 +- GUI/mainwindow.cpp | 22 +++++++- GUI/mainwindow.ui | 53 +------------------ GUI/setdialog.cpp | 1 + extensions/bingtranslate/bingtranslate.cpp | 2 +- .../googletranslate/googletranslate.cpp | 2 +- include/defs.h | 7 --- include/text.h | 13 ++++- 8 files changed, 38 insertions(+), 64 deletions(-) diff --git a/GUI/extenwindow.cpp b/GUI/extenwindow.cpp index 61bcf94..d201045 100644 --- a/GUI/extenwindow.cpp +++ b/GUI/extenwindow.cpp @@ -138,7 +138,7 @@ void ExtenWindow::dropEvent(QDropEvent* event) void ExtenWindow::on_addButton_clicked() { - Add(QFileDialog::getOpenFileName(this, SELECT_EXTENSION, "C:\\", EXTENSIONS)); + Add(QFileDialog::getOpenFileName(this, SELECT_EXTENSION, "C:\\", EXTENSION_FILES)); } void ExtenWindow::on_rmvButton_clicked() diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index 96eba15..96d56b3 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -7,6 +7,9 @@ #include "host/util.h" #include #include +#include +#include +#include #include MainWindow::MainWindow(QWidget *parent) : @@ -15,7 +18,24 @@ MainWindow::MainWindow(QWidget *parent) : extenWindow(new ExtenWindow(this)) { ui->setupUi(this); - + QFrame* processFrame = findChild("processFrame"); + QVBoxLayout* processLayout = findChild("processLayout"); + for (auto[text, slot] : std::initializer_list>{ + { ATTACH, &MainWindow::on_attachButton_clicked }, + { DETACH, &MainWindow::on_detachButton_clicked }, + { ADD_HOOK, &MainWindow::on_hookButton_clicked }, + { SAVE_HOOKS, &MainWindow::on_saveButton_clicked }, + { SETTINGS, &MainWindow::on_setButton_clicked }, + { EXTENSIONS, &MainWindow::on_extenButton_clicked } + }) + { + QPushButton* button = new QPushButton(processFrame); + connect(button, &QPushButton::clicked, this, slot); + button->setText(text); + processLayout->addWidget(button); + } + processLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); + processCombo = findChild("processCombo"); ttCombo = findChild("ttCombo"); textOutput = findChild("textOutput"); diff --git a/GUI/mainwindow.ui b/GUI/mainwindow.ui index 8afd627..6cf2e48 100644 --- a/GUI/mainwindow.ui +++ b/GUI/mainwindow.ui @@ -36,11 +36,11 @@ - + true - + 0 @@ -66,55 +66,6 @@ - - - - Attach to game - - - - - - - Detach from game - - - - - - - Add hook - - - - - - - Save hook(s) - - - - - - - Settings - - - - - - - Extensions - - - - - - - Qt::Vertical - - - diff --git a/GUI/setdialog.cpp b/GUI/setdialog.cpp index 731551c..66cdaa6 100644 --- a/GUI/setdialog.cpp +++ b/GUI/setdialog.cpp @@ -1,6 +1,7 @@ #include "setdialog.h" #include "ui_setdialog.h" #include "defs.h" +#include "text.h" #include "host/host.h" #include diff --git a/extensions/bingtranslate/bingtranslate.cpp b/extensions/bingtranslate/bingtranslate.cpp index 1675ee3..7b2bf1b 100644 --- a/extensions/bingtranslate/bingtranslate.cpp +++ b/extensions/bingtranslate/bingtranslate.cpp @@ -139,7 +139,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) requestTimes.erase(std::remove_if(requestTimes.begin(), requestTimes.end(), [&](DWORD requestTime) { return GetTickCount() - requestTime > 60 * 1000; }), requestTimes.end()); if (!sentenceInfo["current select"] && requestTimes.size() > 30) { - sentence += L"\r\nToo many translation requests: refuse to make more."; + sentence += L"\r\nToo many translation requests: refuse to make more"; return true; } } diff --git a/extensions/googletranslate/googletranslate.cpp b/extensions/googletranslate/googletranslate.cpp index bb80501..93dc96b 100644 --- a/extensions/googletranslate/googletranslate.cpp +++ b/extensions/googletranslate/googletranslate.cpp @@ -143,7 +143,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) requestTimes.erase(std::remove_if(requestTimes.begin(), requestTimes.end(), [&](DWORD requestTime) { return GetTickCount() - requestTime > 60 * 1000; }), requestTimes.end()); if (!sentenceInfo["current select"] && requestTimes.size() > 30) { - sentence += L"\r\nToo many translation requests: refuse to make more."; + sentence += L"\r\nToo many translation requests: refuse to make more"; return true; } } diff --git a/include/defs.h b/include/defs.h index fe34324..f43ca58 100644 --- a/include/defs.h +++ b/include/defs.h @@ -24,11 +24,4 @@ constexpr auto CONFIG_FILE = u8"Textractor.ini"; constexpr auto HOOK_SAVE_FILE = u8"SavedHooks.txt"; constexpr auto EXTEN_SAVE_FILE = u8"Extensions.txt"; -// Settings - -constexpr auto WINDOW = u8"Window"; -constexpr auto DEFAULT_CODEPAGE = u8"Default Codepage"; -constexpr auto FLUSH_DELAY = u8"Flush Delay"; -constexpr auto MAX_BUFFER_SIZE = u8"Max Buffer Size"; - // EOF diff --git a/include/text.h b/include/text.h index 9f85fae..0e2486a 100644 --- a/include/text.h +++ b/include/text.h @@ -1,10 +1,15 @@ #pragma once #define CURRENT_VERSION "3.6.0" +constexpr auto ATTACH = u8"Attach to game"; +constexpr auto DETACH = u8"Detach from game"; +constexpr auto ADD_HOOK = u8"Add hook"; +constexpr auto SAVE_HOOKS = u8"Save hook(s)"; +constexpr auto SETTINGS = u8"Settings"; +constexpr auto EXTENSIONS = u8"Extensions"; constexpr auto SELECT_PROCESS = u8"Select Process"; constexpr auto ATTACH_INFO = u8"If you don't see the process you want to attach, try running with admin rights\r\n" "You can also type in the process id"; -constexpr auto ADD_HOOK = u8"Add hook"; constexpr auto CODE_INFODUMP = u8"Enter hook code\r\n" "/H{A|B|W|S|Q|V}[N][codepage#]data_offset[*deref_offset1][:split_offset[*deref_offset2]]@addr[:module[:func]]\r\n" "OR\r\n" @@ -20,7 +25,11 @@ constexpr auto CODE_INFODUMP = u8"Enter hook code\r\n" constexpr auto UNHOOK = u8"Unhook"; constexpr auto REMOVE_HOOK = u8"Which hook to remove?"; constexpr auto SELECT_EXTENSION = u8"Select Extension"; -constexpr auto EXTENSIONS = u8"Extensions (*.dll)"; +constexpr auto EXTENSION_FILES = u8"Extensions (*.dll)"; +constexpr auto WINDOW = u8"Window"; +constexpr auto DEFAULT_CODEPAGE = u8"Default Codepage"; +constexpr auto FLUSH_DELAY = u8"Flush Delay"; +constexpr auto MAX_BUFFER_SIZE = u8"Max Buffer Size"; constexpr auto ABOUT = L"Textractor beta v" CURRENT_VERSION " (project homepage: https://github.com/Artikash/Textractor)\r\n" "Made by me: Artikash (email: akashmozumdar@gmail.com)\r\n" "Please contact me with any problems, feature requests, or questions relating to Textractor\r\n"