Qt: QT_UI 宏控制替换为 QT_GUI_LIB 编译器预定义的宏控制

This commit is contained in:
Calcitem 2020-11-13 23:35:51 +08:00
parent 210c10393f
commit abb15582b3
8 changed files with 25 additions and 25 deletions

View File

@ -26,7 +26,7 @@
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
#endif #endif
#define QT_UI //#undef QT_GUI_LIB
//#define DISABLE_RANDOM_MOVE //#define DISABLE_RANDOM_MOVE
//#define UCI_AUTO_RE_GO //#define UCI_AUTO_RE_GO

View File

@ -272,7 +272,7 @@
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;_CRT_SECURE_NO_WARNINGS;QT_CORE_LIB;QT_GUI_LIB;QT_MULTIMEDIA_LIB;QT_MULTIMEDIAWIDGETS_LIB;QT_NETWORK_LIB;QT_NETWORKAUTH_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>QT_UI;_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;_CRT_SECURE_NO_WARNINGS;QT_CORE_LIB;QT_GUI_LIB;QT_MULTIMEDIA_LIB;QT_MULTIMEDIAWIDGETS_LIB;QT_NETWORK_LIB;QT_NETWORKAUTH_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile> <PreprocessToFile>false</PreprocessToFile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>

View File

@ -23,7 +23,7 @@
#include "config.h" #include "config.h"
#include <cstdio> #include <cstdio>
#ifdef QT_UI #ifdef QT_GUI_LIB
#include <QDebug> #include <QDebug>
#endif #endif
@ -34,7 +34,7 @@
#ifdef CSTYLE_DEBUG_OUTPUT #ifdef CSTYLE_DEBUG_OUTPUT
#define loggerDebug printf #define loggerDebug printf
#else #else
#ifdef QT_UI #ifdef QT_GUI_LIB
#define loggerDebug qDebug #define loggerDebug qDebug
#endif #endif
#endif /* CSTYLE_DEBUG_OUTPUT */ #endif /* CSTYLE_DEBUG_OUTPUT */

View File

@ -29,7 +29,7 @@
#include "tt.h" #include "tt.h"
#include "uci.h" #include "uci.h"
#ifndef QT_UI #ifndef QT_GUI_LIB
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {

View File

@ -45,12 +45,12 @@ using namespace std;
/// in idle_loop(). Note that 'searching' and 'exit' should be already set. /// in idle_loop(). Note that 'searching' and 'exit' should be already set.
Thread::Thread(size_t n Thread::Thread(size_t n
#ifdef QT_UI #ifdef QT_GUI_LIB
, QObject *parent , QObject *parent
#endif #endif
) : ) :
idx(n), stdThread(&Thread::idle_loop, this), idx(n), stdThread(&Thread::idle_loop, this),
#ifdef QT_UI #ifdef QT_GUI_LIB
QObject(parent), QObject(parent),
#endif #endif
timeLimit(3600) timeLimit(3600)
@ -181,7 +181,7 @@ void Thread::setAi(Position *p, int tl)
void Thread::emitCommand() void Thread::emitCommand()
{ {
#ifdef QT_UI #ifdef QT_GUI_LIB
emit command(strCommand); emit command(strCommand);
#else #else
sync_cout << "bestmove " << strCommand.c_str(); sync_cout << "bestmove " << strCommand.c_str();
@ -195,7 +195,7 @@ void Thread::emitCommand()
#ifdef ANALYZE_POSITION #ifdef ANALYZE_POSITION
analyze(rootPos->side_to_move()); analyze(rootPos->side_to_move());
#endif #endif
#endif // QT_UI #endif // QT_GUI_LIB
} }
#ifdef OPENING_BOOK #ifdef OPENING_BOOK
@ -242,10 +242,10 @@ void Thread::analyze(Color c)
static int nbwin = 0; static int nbwin = 0;
static int nwwin = 0; static int nwwin = 0;
static int ndraw = 0; static int ndraw = 0;
#ifndef QT_UI #ifndef QT_GUI_LIB
int total; int total;
float bwinrate, wwinrate, drawrate; float bwinrate, wwinrate, drawrate;
#endif // !QT_UI #endif // !QT_GUI_LIB
int d = (int)originDepth; int d = (int)originDepth;
int v = (int)bestvalue; int v = (int)bestvalue;
@ -356,7 +356,7 @@ void Thread::analyze(Color c)
cout << "轮到白方行棋" << endl; cout << "轮到白方行棋" << endl;
} }
#ifndef QT_UI #ifndef QT_GUI_LIB
total = nbwin + nwwin + ndraw; total = nbwin + nwwin + ndraw;
if (total == 0) { if (total == 0) {
@ -371,7 +371,7 @@ void Thread::analyze(Color c)
cout << "比分: " << nbwin << " : " << nwwin << " : " << ndraw << "\ttotal: " << total << endl; cout << "比分: " << nbwin << " : " << nwwin << " : " << ndraw << "\ttotal: " << total << endl;
cout << fixed << setprecision(2) << bwinrate << "% : " << wwinrate << "% : " << drawrate << "%" << endl; cout << fixed << setprecision(2) << bwinrate << "% : " << wwinrate << "% : " << drawrate << "%" << endl;
#endif // !QT_UI #endif // !QT_GUI_LIB
out: out:
cout << endl << endl; cout << endl << endl;

View File

@ -33,16 +33,16 @@
#include "thread_win32_osx.h" #include "thread_win32_osx.h"
#include "config.h" #include "config.h"
#ifdef QT_UI #ifdef QT_GUI_LIB
#include <QObject> #include <QObject>
#endif // QT_UI #endif // QT_GUI_LIB
/// Thread class keeps together all the thread-related stuff. We use /// Thread class keeps together all the thread-related stuff. We use
/// per-thread pawn and material hash tables so that once we get a /// per-thread pawn and material hash tables so that once we get a
/// pointer to an entry its life time is unlimited and we don't have /// pointer to an entry its life time is unlimited and we don't have
/// to care about someone changing the entry under our feet. /// to care about someone changing the entry under our feet.
class Thread class Thread
#ifdef QT_UI #ifdef QT_GUI_LIB
: public QObject : public QObject
#endif #endif
{ {
@ -54,7 +54,7 @@ public:
NativeThread stdThread; NativeThread stdThread;
explicit Thread(size_t n explicit Thread(size_t n
#ifdef QT_UI #ifdef QT_GUI_LIB
, QObject *parent = nullptr , QObject *parent = nullptr
#endif #endif
); );
@ -129,7 +129,7 @@ public:
private: private:
int timeLimit; int timeLimit;
#ifdef QT_UI #ifdef QT_GUI_LIB
Q_OBJECT Q_OBJECT
public: public:
@ -139,7 +139,7 @@ signals:
#else #else
public: public:
void emitCommand(); void emitCommand();
#endif // QT_UI #endif // QT_GUI_LIB
void command(const string &cmdline, bool update = true); void command(const string &cmdline, bool update = true);
}; };

View File

@ -83,7 +83,7 @@ GameController::GameController(
qRegisterMetaType<std::string>("string"); qRegisterMetaType<std::string>("string");
#ifdef QT_UI #ifdef QT_GUI_LIB
// 关联AI和控制器的着法命令行 // 关联AI和控制器的着法命令行
connect(aiThread[BLACK], SIGNAL(command(const string &, bool)), connect(aiThread[BLACK], SIGNAL(command(const string &, bool)),
this, SLOT(command(const string &, bool))); this, SLOT(command(const string &, bool)));
@ -92,7 +92,7 @@ GameController::GameController(
connect(this->gameTest, SIGNAL(command(const string &, bool)), connect(this->gameTest, SIGNAL(command(const string &, bool)),
this, SLOT(command(const string &, bool))); this, SLOT(command(const string &, bool)));
#endif // QT_UI #endif // QT_GUI_LIB
#ifdef NET_FIGHT_SUPPORT #ifdef NET_FIGHT_SUPPORT
#ifndef TRAINING_MODE #ifndef TRAINING_MODE
@ -984,14 +984,14 @@ bool GameController::command(const string &cmd, bool update /* = true */)
Q_UNUSED(hasSound) Q_UNUSED(hasSound)
#endif #endif
#ifdef QT_UI #ifdef QT_GUI_LIB
// 防止接收滞后结束的线程发送的指令 // 防止接收滞后结束的线程发送的指令
if (sender() == aiThread[BLACK] && !isAiPlayer[BLACK]) if (sender() == aiThread[BLACK] && !isAiPlayer[BLACK])
return false; return false;
if (sender() == aiThread[WHITE] && !isAiPlayer[WHITE]) if (sender() == aiThread[WHITE] && !isAiPlayer[WHITE])
return false; return false;
#endif // QT_UI #endif // QT_GUI_LIB
#ifndef TRAINING_MODE #ifndef TRAINING_MODE
// 声音 // 声音

View File

@ -24,7 +24,7 @@
QString APP_FILENAME_DEFAULT = "MillGame"; QString APP_FILENAME_DEFAULT = "MillGame";
#ifdef QT_UI #ifdef QT_GUI_LIB
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QCoreApplication> #include <QCoreApplication>
@ -61,4 +61,4 @@ int main(int argc, char *argv[])
#endif // !UCT_DEMO #endif // !UCT_DEMO
#endif // !TRAINING_MODE #endif // !TRAINING_MODE
#endif // QT_UI #endif // QT_GUI_LIB