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")
#endif
#define QT_UI
//#undef QT_GUI_LIB
//#define DISABLE_RANDOM_MOVE
//#define UCI_AUTO_RE_GO

View File

@ -272,7 +272,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<ObjectFileName>$(IntDir)</ObjectFileName>
<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>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<SuppressStartupBanner>true</SuppressStartupBanner>

View File

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

View File

@ -29,7 +29,7 @@
#include "tt.h"
#include "uci.h"
#ifndef QT_UI
#ifndef QT_GUI_LIB
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.
Thread::Thread(size_t n
#ifdef QT_UI
#ifdef QT_GUI_LIB
, QObject *parent
#endif
) :
idx(n), stdThread(&Thread::idle_loop, this),
#ifdef QT_UI
#ifdef QT_GUI_LIB
QObject(parent),
#endif
timeLimit(3600)
@ -181,7 +181,7 @@ void Thread::setAi(Position *p, int tl)
void Thread::emitCommand()
{
#ifdef QT_UI
#ifdef QT_GUI_LIB
emit command(strCommand);
#else
sync_cout << "bestmove " << strCommand.c_str();
@ -195,7 +195,7 @@ void Thread::emitCommand()
#ifdef ANALYZE_POSITION
analyze(rootPos->side_to_move());
#endif
#endif // QT_UI
#endif // QT_GUI_LIB
}
#ifdef OPENING_BOOK
@ -242,10 +242,10 @@ void Thread::analyze(Color c)
static int nbwin = 0;
static int nwwin = 0;
static int ndraw = 0;
#ifndef QT_UI
#ifndef QT_GUI_LIB
int total;
float bwinrate, wwinrate, drawrate;
#endif // !QT_UI
#endif // !QT_GUI_LIB
int d = (int)originDepth;
int v = (int)bestvalue;
@ -356,7 +356,7 @@ void Thread::analyze(Color c)
cout << "轮到白方行棋" << endl;
}
#ifndef QT_UI
#ifndef QT_GUI_LIB
total = nbwin + nwwin + ndraw;
if (total == 0) {
@ -371,7 +371,7 @@ void Thread::analyze(Color c)
cout << "比分: " << nbwin << " : " << nwwin << " : " << ndraw << "\ttotal: " << total << endl;
cout << fixed << setprecision(2) << bwinrate << "% : " << wwinrate << "% : " << drawrate << "%" << endl;
#endif // !QT_UI
#endif // !QT_GUI_LIB
out:
cout << endl << endl;

View File

@ -33,16 +33,16 @@
#include "thread_win32_osx.h"
#include "config.h"
#ifdef QT_UI
#ifdef QT_GUI_LIB
#include <QObject>
#endif // QT_UI
#endif // QT_GUI_LIB
/// Thread class keeps together all the thread-related stuff. We use
/// 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
/// to care about someone changing the entry under our feet.
class Thread
#ifdef QT_UI
#ifdef QT_GUI_LIB
: public QObject
#endif
{
@ -54,7 +54,7 @@ public:
NativeThread stdThread;
explicit Thread(size_t n
#ifdef QT_UI
#ifdef QT_GUI_LIB
, QObject *parent = nullptr
#endif
);
@ -129,7 +129,7 @@ public:
private:
int timeLimit;
#ifdef QT_UI
#ifdef QT_GUI_LIB
Q_OBJECT
public:
@ -139,7 +139,7 @@ signals:
#else
public:
void emitCommand();
#endif // QT_UI
#endif // QT_GUI_LIB
void command(const string &cmdline, bool update = true);
};

View File

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

View File

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