Skip to content

Commit

Permalink
Merge 39d65c8 into 7b68f8a
Browse files Browse the repository at this point in the history
  • Loading branch information
vadi2 committed Aug 14, 2019
2 parents 7b68f8a + 39d65c8 commit f00f1d1
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 48 deletions.
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ else()
set(USE_UPDATER NO)
endif()

# Enable the 3D mapper by default on the three main supported OS
# unless environmental variable WITH_3DMAPPER is defined and set to "NO" (case
# insensitive).
# WITH_3DMAPPER is an environmental value/variable (so could be a number, a
# string, something else or not even exist).
set(3DMAPPER_TEST $ENV{WITH_3DMAPPER})
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
# We are on one of the supported platforms
if(DEFINED 3DMAPPER_TEST)
string(TOUPPER ${3DMAPPER_TEST} 3DMAPPER_TEST)
if(3DMAPPER_TEST STREQUAL "NO")
option(USE_3DMAPPER "Include 3D mapper" OFF)
else()
option(USE_3DMAPPER "Include 3D mapper" ON)
endif()
else()
# An environmental variable not detected, apply platform default of "yes, include the updater"
option(USE_3DMAPPER "Include 3D mapper" ON)
endif()
else()
# Option not available for other platforms
set(USE_3DMAPPER NO)
endif()

# Enable the inclusion of fonts currently carried in the source code by default
# unless the environmental variable WITH_FONTS is defined AND is set to a
# (case insensitive) value of "NO". Linux packagers will find it useful to do
Expand Down Expand Up @@ -274,6 +298,9 @@ if(USE_UPDATER)
endif()
endif()

if(USE_3DMAPPER)
add_definitions(-DINCLUDE_3DMAPPER)
endif()

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
Expand Down
17 changes: 15 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ set(mudlet_SRCS
EAction.cpp
exitstreewidget.cpp
FontManager.cpp
glwidget.cpp
Host.cpp
HostManager.cpp
ircmessageformatter.cpp
Expand Down Expand Up @@ -150,7 +149,6 @@ set(mudlet_MOC_HDRS
dlgVarsMainArea.h
EAction.h
exitstreewidget.h
glwidget.h
Host.h
mudlet.h
T2DMap.h
Expand Down Expand Up @@ -214,6 +212,12 @@ if(USE_UPDATER)
list(APPEND mudlet_MOC_HDRS updater.h)
endif(USE_UPDATER)


if(USE_3DMAPPER)
list(APPEND mudlet_SRCS glwidget.cpp)
list(APPEND mudlet_MOC_HDRS glwidget.h)
endif(USE_3DMAPPER)

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP") # parallel builds
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Zc:inline") # improve link times
Expand Down Expand Up @@ -363,6 +367,15 @@ else()
message(STATUS "The Updater code is excluded as on-line updating is not available on this platform")
endif()

if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
if(USE_3DMAPPER)
message(STATUS "The 3D mapper code is included in this configuration")
else(USE_3DMAPPER)
message(STATUS "The 3D mapper code is excluded from this configuration")
endif(USE_3DMAPPER)
else()
message(STATUS "The 3D mapper code is excluded as it might not be supported on this platform")
endif()

if(WIN32)
set(mudlet_RC_ICONS = icons/mudlet_main_512x512_6XS_icon.ico)
Expand Down
9 changes: 9 additions & 0 deletions src/T2DMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "dlgMapper.h"
#include "dlgRoomExits.h"
#include "mudlet.h"
#if defined(INCLUDE_3DMAPPER)
#include "glwidget.h"
#endif


#include "pre_guard.h"
#include <QtEvents>
Expand Down Expand Up @@ -3098,9 +3102,11 @@ void T2DMap::slot_createRoom()
mpHost->mpMap->setRoomCoordinates(roomID, mousePosition.first, mousePosition.second, mOz);

mpHost->mpMap->mMapGraphNeedsUpdate = true;
#if defined(INCLUDE_3DMAPPER)
if (mpHost->mpMap->mpM) {
mpHost->mpMap->mpM->update();
}
#endif
if (mpHost->mpMap->mpMapper->mp2dMap) {
mpHost->mpMap->mpMapper->mp2dMap->isCenterViewCall = true;
mpHost->mpMap->mpMapper->mp2dMap->update();
Expand Down Expand Up @@ -4197,9 +4203,12 @@ void T2DMap::slot_newMap()

mpHost->mpMap->mRoomIdHash[mpMap->mProfileName] = roomID;
mpHost->mpMap->mNewMove = true;

#if defined(INCLUDE_3DMAPPER)
if (mpHost->mpMap->mpM) {
mpHost->mpMap->mpM->update();
}
#endif

if (mpHost->mpMap->mpMapper->mp2dMap) {
mpHost->mpMap->mpMapper->mp2dMap->isCenterViewCall = true;
Expand Down
3 changes: 3 additions & 0 deletions src/TConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <QShortcut>
#include <QTextBoundaryFinder>
#include <QTextCodec>
#include <QPainter>
#include "post_guard.h"

const QString TConsole::cmLuaLineVariable("line");
Expand Down Expand Up @@ -2226,7 +2227,9 @@ void TConsole::createMapper(int x, int y, int width, int height)
{
if (!mpMapper) {
mpMapper = new dlgMapper(mpMainFrame, mpHost, mpHost->mpMap.data());
#if defined(INCLUDE_3DMAPPER)
mpHost->mpMap->mpM = mpMapper->glWidget;
#endif
mpHost->mpMap->mpHost = mpHost;
mpHost->mpMap->mpMapper = mpMapper;
qDebug() << "TConsole::createMapper() - restore map case 2.";
Expand Down
11 changes: 11 additions & 0 deletions src/TLuaInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#include "dlgMapper.h"
#include "dlgTriggerEditor.h"
#include "mudlet.h"
#if defined(INCLUDE_3DMAPPER)
#include "glwidget.h"
#endif

#include "pre_guard.h"
#include <QCollator>
Expand Down Expand Up @@ -1267,9 +1270,11 @@ int TLuaInterpreter::updateMap(lua_State* L)
{
Host& host = getHostFromLua(L);
if (host.mpMap) {
#if defined(INCLUDE_3DMAPPER)
if (host.mpMap->mpM) {
host.mpMap->mpM->update();
}
#endif
if (host.mpMap->mpMapper) {
if (host.mpMap->mpMapper->mp2dMap) {
host.mpMap->mpMapper->mp2dMap->mNewMoveAction = true;
Expand Down Expand Up @@ -1525,9 +1530,11 @@ int TLuaInterpreter::centerview(lua_State* L)
if (pR) {
host.mpMap->mRoomIdHash[host.getName()] = roomId;
host.mpMap->mNewMove = true;
#if defined(INCLUDE_3DMAPPER)
if (host.mpMap->mpM) {
host.mpMap->mpM->update();
}
#endif

if (host.mpMap->mpMapper->mp2dMap) {
host.mpMap->mpMapper->mp2dMap->isCenterViewCall = true;
Expand Down Expand Up @@ -10476,9 +10483,11 @@ int TLuaInterpreter::setRoomArea(lua_State* L)
if (host.mpMap->mpMapper) {
host.mpMap->mpMapper->mp2dMap->update();
}
#if defined(INCLUDE_3DMAPPER)
if (host.mpMap->mpM) {
host.mpMap->mpM->update();
}
#endif
}
lua_pushboolean(L, result);
return 1;
Expand Down Expand Up @@ -10515,9 +10524,11 @@ int TLuaInterpreter::resetRoomArea(lua_State* L)
if (host.mpMap->mpMapper) {
host.mpMap->mpMapper->mp2dMap->update();
}
#if defined(INCLUDE_3DMAPPER)
if (host.mpMap->mpM) {
host.mpMap->mpM->update();
}
#endif
}
lua_pushboolean(L, result);
return 1;
Expand Down
5 changes: 5 additions & 0 deletions src/TMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QProgressDialog>
#include <QPainter>
#include "post_guard.h"

TMap::TMap(Host* pH, const QString& profileName)
Expand All @@ -49,7 +50,9 @@ TMap::TMap(Host* pH, const QString& profileName)
, m2DPanXStart(0.0f)
, m2DPanYStart(0.0f)
, mTargetID(0)
#if defined(INCLUDE_3DMAPPER)
, mpM(Q_NULLPTR)
#endif
, mpMapper(Q_NULLPTR)
, mMapGraphNeedsUpdate(true)
, mNewMove(true)
Expand Down Expand Up @@ -2051,7 +2054,9 @@ void TMap::postMessage(const QString text)
// Used by the 2D mapper to send view center coordinates to 3D one
void TMap::set3DViewCenter(const int areaId, const int xPos, const int yPos, const int zPos)
{
#if defined(INCLUDE_3DMAPPER)
mpM->setViewCenter(areaId, xPos, yPos, zPos);
#endif
}

void TMap::appendRoomErrorMsg(const int roomId, const QString msg, const bool isToSetFileViewingRecommended)
Expand Down
7 changes: 7 additions & 0 deletions src/TMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@


#include "TAstar.h"
#if defined(INCLUDE_3DMAPPER)
#include "glwidget.h"
#endif

#include "pre_guard.h"
#include <QApplication>
Expand All @@ -43,7 +46,9 @@

class dlgMapper;
class Host;
#if defined(INCLUDE_3DMAPPER)
class GLWidget;
#endif
class TArea;
class TRoom;
class TRoomDB;
Expand Down Expand Up @@ -174,7 +179,9 @@ class TMap : public QObject
// contains complementary directions of dirs on TRoom.h
QMap<int, int> reverseDirections;

#if defined(INCLUDE_3DMAPPER)
QPointer<GLWidget> mpM;
#endif
QPointer<dlgMapper> mpMapper;
QMap<int, int> roomidToIndex;

Expand Down
9 changes: 8 additions & 1 deletion src/ctelnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "dlgComposer.h"
#include "dlgMapper.h"
#include "mudlet.h"
#if defined(INCLUDE_3DMAPPER)
#include "glwidget.h"
#endif

#include "pre_guard.h"
#include <QNetworkProxy>
Expand Down Expand Up @@ -1574,8 +1577,12 @@ void cTelnet::setATCPVariables(const QByteArray& msg)
if (var.startsWith(QLatin1String("RoomNum"))) {
if (mpHost->mpMap) {
mpHost->mpMap->mRoomIdHash[mProfileName] = arg.toInt();
if (mpHost->mpMap->mpM && mpHost->mpMap->mpMapper && mpHost->mpMap->mpMapper->mp2dMap) {
#if defined(INCLUDE_3DMAPPER)
if (mpHost->mpMap->mpM && mpHost->mpMap->mpMapper) {
mpHost->mpMap->mpM->update();
}
#endif
if (mpHost->mpMap->mpMapper && mpHost->mpMap->mpMapper->mp2dMap) {
mpHost->mpMap->mpMapper->mp2dMap->update();
}
}
Expand Down
Loading

0 comments on commit f00f1d1

Please sign in to comment.