From 6f8435de202198fa04e6474c8fcac1cac009b895 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 19 Sep 2014 12:01:38 +0200 Subject: [PATCH] Add panoply_preview tool placeholder --HG-- branch : qt5 --- code/nel/tools/3d/CMakeLists.txt | 4 + .../tools/3d/panoply_preview/CMakeLists.txt | 28 +++ .../tools/3d/panoply_preview/command_log.cpp | 184 +++++++++++++++++ .../tools/3d/panoply_preview/command_log.h | 70 +++++++ .../tools/3d/panoply_preview/main_window.cpp | 139 +++++++++++++ .../tools/3d/panoply_preview/main_window.h | 90 +++++++++ .../3d/panoply_preview/panoply_preview.cpp | 59 ++++++ .../3d/panoply_preview/panoply_preview.h | 67 +++++++ .../tools/3d/panoply_preview/tool_config.h | 105 ++++++++++ .../tools/3d/panoply_preview/tool_main.cpp | 189 ++++++++++++++++++ code/nel/tools/3d/panoply_preview/tool_main.h | 33 +++ 11 files changed, 968 insertions(+) create mode 100644 code/nel/tools/3d/panoply_preview/CMakeLists.txt create mode 100644 code/nel/tools/3d/panoply_preview/command_log.cpp create mode 100644 code/nel/tools/3d/panoply_preview/command_log.h create mode 100644 code/nel/tools/3d/panoply_preview/main_window.cpp create mode 100644 code/nel/tools/3d/panoply_preview/main_window.h create mode 100644 code/nel/tools/3d/panoply_preview/panoply_preview.cpp create mode 100644 code/nel/tools/3d/panoply_preview/panoply_preview.h create mode 100644 code/nel/tools/3d/panoply_preview/tool_config.h create mode 100644 code/nel/tools/3d/panoply_preview/tool_main.cpp create mode 100644 code/nel/tools/3d/panoply_preview/tool_main.h diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index cb709ffaa..3c6c4f3ff 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -61,6 +61,10 @@ IF(WITH_NEL_TOOLS AND WITH_3D) ADD_SUBDIRECTORY(tile_edit_qt) ADD_SUBDIRECTORY(object_viewer_widget) ENDIF(WITH_QT) + + IF(WITH_QT5) + ADD_SUBDIRECTORY(panoply_preview) + ENDIF() IF(SQUISH_FOUND) ADD_SUBDIRECTORY(s3tc_compressor_lib) diff --git a/code/nel/tools/3d/panoply_preview/CMakeLists.txt b/code/nel/tools/3d/panoply_preview/CMakeLists.txt new file mode 100644 index 000000000..83c74b9b2 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/CMakeLists.txt @@ -0,0 +1,28 @@ + +FILE(GLOB SRCS *.cpp) +FILE(GLOB HDRS *.h) +FILE(GLOB RESOURCES *.qrc) + +SOURCE_GROUP("" FILES ${SRCS} ${HDRS} ${RESOURCES}) + +SET(CMAKE_AUTOMOC ON) + +QT5_ADD_RESOURCES(RESOURCE_ADDED ${RESOURCES}) + +ADD_EXECUTABLE(nl_panoply_preview WIN32 ${SRC} + ${SRCS} + ${HDRS} + ${RESOURCE_ADDED} + ) + +TARGET_LINK_LIBRARIES(nl_panoply_preview + nelmisc + nel3d + Qt5::Widgets) + +NL_DEFAULT_PROPS(nl_panoply_preview "NeL, Tools, 3D: panoply_preview") +NL_ADD_RUNTIME_FLAGS(nl_panoply_preview) + +QT5_USE_MODULES(nl_panoply_preview Widgets) + +INSTALL(TARGETS nl_panoply_preview RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT samples3d) diff --git a/code/nel/tools/3d/panoply_preview/command_log.cpp b/code/nel/tools/3d/panoply_preview/command_log.cpp new file mode 100644 index 000000000..faf76f1eb --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/command_log.cpp @@ -0,0 +1,184 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include +#include "command_log.h" + +// STL includes + +// Qt includes +#include + +// NeL includes +#include +#include +#include + +// Project includes + +using namespace std; +using namespace NLMISC; + +namespace NLTOOLS { + +CCommandLog::CCommandLog(QWidget *parent) : QWidget(parent) +{ + m_DisplayerOutput = new QTextEdit(); + m_DisplayerOutput->setReadOnly(true); + m_DisplayerOutput->setFocusPolicy(Qt::NoFocus); + m_CommandInput = new QLineEdit(); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(m_DisplayerOutput); + layout->addWidget(m_CommandInput); + setLayout(layout); + + connect(m_CommandInput, SIGNAL(returnPressed()), this, SLOT(returnPressed())); + + DebugLog->addDisplayer(this); + InfoLog->addDisplayer(this); + WarningLog->addDisplayer(this); + AssertLog->addDisplayer(this); + ErrorLog->addDisplayer(this); +} + +CCommandLog::~CCommandLog() +{ + DebugLog->removeDisplayer(this); + InfoLog->removeDisplayer(this); + WarningLog->removeDisplayer(this); + AssertLog->removeDisplayer(this); + ErrorLog->removeDisplayer(this); +} + +void CCommandLog::doDisplay(const CLog::TDisplayInfo& args, const char *message) +{ + switch (args.LogType) + { + case CLog::LOG_DEBUG: + m_DisplayerOutput->setTextColor(Qt::darkGray); + break; + case CLog::LOG_STAT: + m_DisplayerOutput->setTextColor(Qt::darkGreen); + break; + case CLog::LOG_NO: + case CLog::LOG_UNKNOWN: + case CLog::LOG_INFO: + m_DisplayerOutput->setTextColor(Qt::black); + break; + case CLog::LOG_WARNING: + m_DisplayerOutput->setTextColor(Qt::darkBlue); + break; + case CLog::LOG_ERROR: + case CLog::LOG_ASSERT: + m_DisplayerOutput->setTextColor(Qt::darkRed); + break; + } + + bool needSpace = false; + //stringstream ss; + string str; + + if (args.LogType != CLog::LOG_NO) + { + str += logTypeToString(args.LogType); + needSpace = true; + } + + // Write thread identifier + if (args.ThreadId != 0) + { + if (needSpace) { str += " "; needSpace = false; } +#ifdef NL_OS_WINDOWS + str += NLMISC::toString("%4x", args.ThreadId); +#else + str += NLMISC::toString("%08x", args.ThreadId); +#endif + needSpace = true; + } + + if (args.FileName != NULL) + { + if (needSpace) { str += " "; needSpace = false; } + str += NLMISC::toString("%20s", CFile::getFilename(args.FileName).c_str()); + needSpace = true; + } + + if (args.Line != -1) + { + if (needSpace) { str += " "; needSpace = false; } + str += NLMISC::toString("%4u", args.Line); + //ss << setw(4) << args.Line; + needSpace = true; + } + + if (args.FuncName != NULL) + { + if (needSpace) { str += " "; needSpace = false; } + str += NLMISC::toString("%20s", args.FuncName); + needSpace = true; + } + + if (needSpace) { str += ": "; needSpace = false; } + + uint nbl = 1; + + char *npos, *pos = const_cast(message); + while ((npos = strchr (pos, '\n'))) + { + *npos = '\0'; + str += pos; + /*if (needSlashR) + str += "\r";*/ + str += "\n"; + *npos = '\n'; + pos = npos+1; + nbl++; + } + str += pos; + + pos = const_cast(args.CallstackAndLog.c_str()); + while ((npos = strchr (pos, '\n'))) + { + *npos = '\0'; + str += pos; + /*if (needSlashR) + str += "\r";*/ + str += "\n"; + *npos = '\n'; + pos = npos+1; + nbl++; + } + str += pos; + + m_DisplayerOutput->append(str.substr(0, str.size() - 1).c_str()); +} + +void CCommandLog::returnPressed() +{ + QString text = m_CommandInput->text(); + if (text.isEmpty()) + return; + + std::string cmd = text.toLocal8Bit().data(); + ICommand::execute(cmd, InfoLog()); + + m_CommandInput->clear(); +} + +} /* namespace NLTOOLS */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/command_log.h b/code/nel/tools/3d/panoply_preview/command_log.h new file mode 100644 index 000000000..8c8d774d3 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/command_log.h @@ -0,0 +1,70 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLTOOLS_COMMAND_LOG_H +#define NLTOOLS_COMMAND_LOG_H +#include + +// STL includes + +// Qt includes +#include +#include +#include + +// NeL includes +#include +#include + +// Project includes + +namespace NLTOOLS { + +/** + * CCommandLog + * \brief CCommandLog + * \date 2010-02-05 20:27GMT + * \author Jan BOON (jan.boon@kaetemi.be) + */ +class CCommandLog : public QWidget, public NLMISC::IDisplayer +{ + Q_OBJECT + +public: + CCommandLog(QWidget *parent); + virtual ~CCommandLog(); + +protected: + virtual void doDisplay(const NLMISC::CLog::TDisplayInfo& args, const char *message); + +private slots: + void returnPressed(); + +private: + QTextEdit *m_DisplayerOutput; + QLineEdit *m_CommandInput; + +private: + CCommandLog(const CCommandLog &); + CCommandLog &operator=(const CCommandLog &); + +}; /* class CCommandLog */ + +} /* namespace NLTOOLS */ + +#endif /* #ifndef NLTOOLS_COMMAND_LOG_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/main_window.cpp b/code/nel/tools/3d/panoply_preview/main_window.cpp new file mode 100644 index 000000000..fcce034d7 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/main_window.cpp @@ -0,0 +1,139 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include +#include "main_window.h" + +// STL includes + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// NeL includes +// #include +#include +#include + +// Project includes +#include "command_log.h" +#include "panoply_preview.h" + +using namespace std; +using namespace NLMISC; + +namespace NLTOOLS { + +namespace { + +QString nli18n(const char *label) +{ + return QString::fromUtf16(CI18N::get(label).c_str()); +} + +} /* anonymous namespace */ + +CMainWindow::CMainWindow(const QMap &customSizeHints, QWidget *parent, Qt::WindowFlags flags) + : QMainWindow(parent, flags), + m_PanoplyPreview(NULL), + m_CommandLog(NULL), m_CommandLogDock(NULL), + m_WidgetsMenu(NULL), m_HelpMenu(NULL), + m_AboutAct(NULL) +{ + setObjectName("CMainWindow"); + + m_PanoplyPreview = new CPanoplyPreview(this); + setCentralWidget(m_PanoplyPreview); + + createActions(); + createMenus(); + createToolBars(); + createStatusBar(); + createDockWindows(); +} + +CMainWindow::~CMainWindow() +{ + +} + +void CMainWindow::createActions() +{ + m_AboutAct = new QAction(this); + connect(m_AboutAct, SIGNAL(triggered()), this, SLOT(about())); + + m_AboutAct->setText(tr("About")); + m_AboutAct->setStatusTip(tr("About")); +} + +void CMainWindow::createMenus() +{ + m_WidgetsMenu = menuBar()->addMenu(QString::null); + + menuBar()->addSeparator(); + + m_HelpMenu = menuBar()->addMenu(QString::null); + m_HelpMenu->addAction(m_AboutAct); + + m_WidgetsMenu->setTitle(tr("Widgets")); + m_HelpMenu->setTitle(tr("Help")); +} + +void CMainWindow::createToolBars() +{ + +} + +void CMainWindow::createStatusBar() +{ + statusBar()->showMessage(tr("Ready")); +} + +void CMainWindow::createDockWindows() +{ + // CommandLog (Console) + { + m_CommandLogDock = new QDockWidget(this); + m_CommandLogDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); + m_CommandLog = new CCommandLog(m_CommandLogDock); + m_CommandLogDock->setWidget(m_CommandLog); + addDockWidget(Qt::BottomDockWidgetArea, m_CommandLogDock); + m_WidgetsMenu->addAction(m_CommandLogDock->toggleViewAction()); + } + + m_CommandLogDock->setWindowTitle(tr("Command Log")); +} + +void CMainWindow::about() +{ + QMessageBox::about(this, tr("Panoply Preview"), tr("Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be)")); +} + +} /* namespace NLTOOLS */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/main_window.h b/code/nel/tools/3d/panoply_preview/main_window.h new file mode 100644 index 000000000..ff957c968 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/main_window.h @@ -0,0 +1,90 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLTOOLS_MAIN_WINDOW_H +#define NLTOOLS_MAIN_WINDOW_H +#include + +// STL includes + +// Qt includes +#include + +// NeL includes +#include +#include +#include +#include +#include + +// Project includes +// ... + +class QTreeView; +class QDirModel; +class QUndoStack; +class QScrollArea; + +namespace NLTOOLS { + class CCommandLog; + class CPanoplyPreview; + +/** + * CMainWindow + * \brief CMainWindow + * \date 2014-09-19 09:38GMT + * \author Jan BOON (jan.boon@kaetemi.be) + */ +class CMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + CMainWindow(const QMap &customSizeHints, QWidget *parent = 0, Qt::WindowFlags flags = 0); + virtual ~CMainWindow(); + +private slots: + void about(); + +private: + void createActions(); + void createMenus(); + void createToolBars(); + void createStatusBar(); + void createDockWindows(); + +private: + CMainWindow(const CMainWindow &); + CMainWindow &operator=(const CMainWindow &); + +private: + CPanoplyPreview *m_PanoplyPreview; + + CCommandLog *m_CommandLog; + QDockWidget *m_CommandLogDock; + + QMenu *m_WidgetsMenu; + QMenu *m_HelpMenu; + + QAction *m_AboutAct; + +}; /* class CMainWindow */ + +} /* namespace NLTOOLS */ + +#endif /* #ifndef NLTOOLS_MAIN_WINDOW_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/panoply_preview.cpp b/code/nel/tools/3d/panoply_preview/panoply_preview.cpp new file mode 100644 index 000000000..c7af90cb3 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/panoply_preview.cpp @@ -0,0 +1,59 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include +#include "panoply_preview.h" + +// STL includes + +// Qt includes +#include + +// NeL includes +#include +#include +#include + +// Project includes + +using namespace std; +using namespace NLMISC; + +namespace NLTOOLS { + +CPanoplyPreview::CPanoplyPreview(QWidget *parent) : QWidget(parent) +{ + m_DisplayerOutput = new QTextEdit(); + m_DisplayerOutput->setReadOnly(true); + m_DisplayerOutput->setFocusPolicy(Qt::NoFocus); + m_CommandInput = new QLineEdit(); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(m_DisplayerOutput); + layout->addWidget(m_CommandInput); + setLayout(layout); + + // connect(m_CommandInput, SIGNAL(returnPressed()), this, SLOT(returnPressed())); +} + +CPanoplyPreview::~CPanoplyPreview() +{ + +} + +} /* namespace NLTOOLS */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/panoply_preview.h b/code/nel/tools/3d/panoply_preview/panoply_preview.h new file mode 100644 index 000000000..fe4bbcd08 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/panoply_preview.h @@ -0,0 +1,67 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLTOOLS_PANOPLY_PREVIEW_H +#define NLTOOLS_PANOPLY_PREVIEW_H +#include + +// STL includes + +// Qt includes +#include +#include +#include + +// NeL includes +#include +#include + +// Project includes + +namespace NLTOOLS { + +/** + * CPanoplyPreview + * \brief CPanoplyPreview + * \date 2014-09-19 09:38GMT + * \author Jan BOON (jan.boon@kaetemi.be) + */ +class CPanoplyPreview : public QWidget +{ + Q_OBJECT + +public: + CPanoplyPreview(QWidget *parent); + virtual ~CPanoplyPreview(); + +//private slots: + // ... + +private: + QTextEdit *m_DisplayerOutput; + QLineEdit *m_CommandInput; + +private: + CPanoplyPreview(const CPanoplyPreview &); + CPanoplyPreview &operator=(const CPanoplyPreview &); + +}; /* class CPanoplyPreview */ + +} /* namespace NLTOOLS */ + +#endif /* #ifndef NLTOOLS_PANOPLY_PREVIEW_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/tool_config.h b/code/nel/tools/3d/panoply_preview/tool_config.h new file mode 100644 index 000000000..94e53d2dc --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/tool_config.h @@ -0,0 +1,105 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLTOOLS_CONFIG_H +#define NLTOOLS_CONFIG_H +#include + + + +// use the default log.log file (not erased on use) +// #define NLTOOLS_USE_LOG_LOG false + + + +// the config file name +// #define NLTOOLS_CONFIG_FILE "panoply_preview.cfg" +// #define NLTOOLS_CONFIG_FILE_DEFAULT "panoply_preview_default.cfg" + + + +// use panoply_preview log file +// #define NLTOOLS_USE_LOG 1 + +// panoply_preview log file name +#define NLTOOLS_LOG_FILE "panoply_preview.log" + +// clear panoply_preview log before use +#define NLTOOLS_ERASE_LOG true + +// version number +#define NLTOOLS_VERSION "0.10.0" + + + +// use the low fragmentation heap (windows feature) +// #define NLTOOLS_LOW_FRAGMENTATION_HEAP 1 + + + +// temporary dev tags +//#define NL_DEV_STEREO 0 +//#define NL_DEV_MEMLEAK 1 +//#define NL_DEV_NET 0 +//#define NL_DEV_NETNEW 1 +//#define NL_DEV_CG 0 +//#define NL_DEV_BULLET 0 + + + +// some default defines +#if FINAL_VERSION +# if !defined(NLTOOLS_USE_LOG_LOG) +# define NLTOOLS_USE_LOG_LOG false +# endif +# if !defined(NLTOOLS_USE_LOG) +# define NLTOOLS_USE_LOG 0 +# endif +#endif + +#if !defined (NLTOOLS_USE_LOG_LOG) +# define NLTOOLS_USE_LOG_LOG true +#endif +#if !defined (NLTOOLS_USE_LOG) +# define NLTOOLS_USE_LOG 1 +#endif + +#if !defined (NLTOOLS_LOW_FRAGMENTATION_HEAP) +# ifdef NL_OS_WINDOWS +# define NLTOOLS_LOW_FRAGMENTATION_HEAP 1 +# else +# define NLTOOLS_LOW_FRAGMENTATION_HEAP 0 +# endif +#endif + +// for compatibility with old configuration +#ifndef NLTOOLS_CONFIG_FILE +# ifndef NLTOOLS_CONFIG +# define NLTOOLS_CONFIG_FILE "panoply_preview.cfg" +# else +# define NLTOOLS_CONFIG_FILE NLTOOLS_CONFIG "panoply_preview.cfg" +# endif +#endif + +#ifndef NLTOOLS_CONFIG_FILE_DEFAULT +# define NLTOOLS_CONFIG_FILE_DEFAULT "panoply_preview_default.cfg" +#endif + + + +#endif /* #ifndef NLTOOLS_CONFIG_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/tool_main.cpp b/code/nel/tools/3d/panoply_preview/tool_main.cpp new file mode 100644 index 000000000..d9b85efe7 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/tool_main.cpp @@ -0,0 +1,189 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include +#include "tool_main.h" + +// STL includes +#include +#ifdef NL_OS_WINDOWS +# include +# include +# include +#endif + +// Qt includes +#include +#include +#include +#include + +// NeL includes +#include +#include +#include +#include +#include +#include + +// Project includes +#include "tool_config.h" +#include "main_window.h" + +using namespace std; +using namespace NLMISC; + +namespace NLTOOLS { + +namespace { + +CFileDisplayer *s_FileDisplayer = NULL; + +} /* anonymous namespace */ + +} /* namespace NLTOOLS */ + +void usage() +{ + /* from Qt sample */ + + qWarning() << "Usage: mainwindow [-SizeHint x] ..."; + exit(1); +} + +QMap parseCustomSizeHints(int argc, char **argv) +{ + /* from Qt sample */ + + QMap result; + + for (int i = 1; i < argc; ++i) { + QString arg = QString::fromLocal8Bit(argv[i]); + + if (arg.startsWith(QLatin1String("-SizeHint"))) { + QString name = arg.mid(9); + if (name.isEmpty()) + usage(); + if (++i == argc) + usage(); + QString sizeStr = QString::fromLocal8Bit(argv[i]); + int idx = sizeStr.indexOf(QLatin1Char('x')); + if (idx == -1) + usage(); + bool ok; + int w = sizeStr.left(idx).toInt(&ok); + if (!ok) + usage(); + int h = sizeStr.mid(idx + 1).toInt(&ok); + if (!ok) + usage(); + result[name] = QSize(w, h); + } + } + + return result; +} + +#ifdef NL_OS_WINDOWS +# ifdef _UNICODE +# define tstring wstring +# else +# define tstring string +# endif +#endif + +sint main(int argc, char **argv) +{ + // go nel! + { + // use log.log if NEL_LOG_IN_FILE and NLTOOLS_USE_LOG_LOG defined as 1 + createDebug(NULL, NLTOOLS_USE_LOG_LOG, false); + +#if NLTOOLS_USE_LOG + // create toverhex_client.log + // filedisplayer only deletes the 001 etc + if (NLTOOLS_ERASE_LOG && CFile::isExists(NLTOOLS_LOG_FILE)) + CFile::deleteFile(NLTOOLS_LOG_FILE); + // initialize the log file + NLTOOLS::s_FileDisplayer = new CFileDisplayer(); + NLTOOLS::s_FileDisplayer->setParam(NLTOOLS_LOG_FILE, NLTOOLS_ERASE_LOG); + DebugLog->addDisplayer(NLTOOLS::s_FileDisplayer); + InfoLog->addDisplayer(NLTOOLS::s_FileDisplayer); + WarningLog->addDisplayer(NLTOOLS::s_FileDisplayer); + AssertLog->addDisplayer(NLTOOLS::s_FileDisplayer); + ErrorLog->addDisplayer(NLTOOLS::s_FileDisplayer); +#endif + + nlinfo("Welcome to NeL!"); + } + + // low fragmentation heap (windows) +#if NLTOOLS_LOW_FRAGMENTATION_HEAP + ULONG heapFragValue = 2; // enable low fragmentation heap + if (HeapSetInformation(GetProcessHeap(), + HeapCompatibilityInformation, + &heapFragValue, sizeof(heapFragValue))) + { + nlinfo("HeapSetInformation OK!\n"); + } + else + { + nlwarning("HeapSetInformation FAIL! (%d)\n", GetLastError()); + } +#endif + +#ifdef NL_OS_WINDOWS + HRESULT hr; + hr = hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + bool coInitOk = (hr == S_OK) || (hr == S_FALSE); +#endif + + CSheetId::initWithoutSheet(); + + QApplication app(argc, const_cast(argv)); + + QApplication::setStyle(QStyleFactory::create("Fusion")); + QPalette palette = app.palette(); + palette.setColor(QPalette::Window, QColor(64, 64, 64)); + palette.setColor(QPalette::WindowText, Qt::white); + palette.setColor(QPalette::Base, QColor(48, 48, 48)); + palette.setColor(QPalette::AlternateBase, QColor(64, 64, 64)); + palette.setColor(QPalette::ToolTipBase, Qt::white); + palette.setColor(QPalette::ToolTipText, Qt::white); + palette.setColor(QPalette::Text, Qt::white); + palette.setColor(QPalette::Button, QColor(64, 64, 64)); + palette.setColor(QPalette::ButtonText, Qt::white); + palette.setColor(QPalette::BrightText, Qt::red); + palette.setColor(QPalette::Highlight, QColor(64, 128, 96)); + palette.setColor(QPalette::HighlightedText, Qt::white); + app.setPalette(palette); + + QMap customSizeHints = parseCustomSizeHints(argc, argv); + + NLTOOLS::CMainWindow mainWin(customSizeHints); + mainWin.resize(800, 600); + mainWin.show(); // calls isVisible(true) + + int result = app.exec(); + +#ifdef NL_OS_WINDOWS + if (coInitOk) CoUninitialize(); +#endif + + return result; +} + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/tool_main.h b/code/nel/tools/3d/panoply_preview/tool_main.h new file mode 100644 index 000000000..75eae7204 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/tool_main.h @@ -0,0 +1,33 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLTOOLS_MAIN_H +#define NLTOOLS_MAIN_H +#include + +// STL includes + +// NeL includes + +// Project includes + +namespace NLTOOLS { + +} /* namespace NLTOOLS */ + +#endif /* #ifndef NLTOOLS_MAIN_H */ + +/* end of file */