add info panel
This commit is contained in:
parent
97661469f5
commit
476113a928
|
@ -87,6 +87,8 @@ set(TESTAPP_SRC_FILES
|
|||
set(CUTTOWN_SRC_FILES
|
||||
CuttownTest/gameData.cpp
|
||||
CuttownTest/gameData.h
|
||||
CuttownTest/infoPanel.cpp
|
||||
CuttownTest/infoPanel.h
|
||||
CuttownTest/Main.cpp
|
||||
CuttownTest/mainWindow.cpp
|
||||
CuttownTest/mainWindow.h
|
||||
|
|
|
@ -14,18 +14,37 @@
|
|||
#include "WorldReader.h"
|
||||
#include "World.h"
|
||||
|
||||
GameData::GameData() : gameRegion(GameRegion::UNKNOWN), gameType(GameType::UNKNOWN)
|
||||
{
|
||||
worldGob = nullptr;
|
||||
world = nullptr;
|
||||
}
|
||||
|
||||
GameData::~GameData()
|
||||
{
|
||||
delete worldGob; worldGob = nullptr;
|
||||
delete world; world = nullptr;
|
||||
}
|
||||
|
||||
void GameData::read(QString rootDir, QString worldName)
|
||||
{
|
||||
this->rootDir = rootDir;
|
||||
gameType = GameType::UNKNOWN;
|
||||
delete worldGob; worldGob = nullptr;
|
||||
delete world; world = nullptr;
|
||||
|
||||
if (rootDir.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
findGame(rootDir);
|
||||
if (gameType != GameType::UNKNOWN) {
|
||||
QString lmpDir = rootDir + dataRelPath;
|
||||
LmpRepository* lmpRepository = new LmpRepositoryImpl(lmpDir.toStdString(), gameType);
|
||||
QString lmpDir = rootDir + "/" + dataRelPath;
|
||||
//LmpRepository* lmpRepository = new LmpRepositoryImpl(lmpDir.toStdString(), gameType);
|
||||
|
||||
QString gobFile = lmpDir + "CUTTOWN.GOB";
|
||||
GobFile cuttownGob = GobFile(gobFile.toStdString(), gameType);
|
||||
World* world = WorldReader().readWorld(&cuttownGob, "cuttown");
|
||||
QString gobFile = lmpDir + "/" + worldName.toUpper() + ".GOB";
|
||||
worldGob = new GobFile(gobFile.toStdString(), gameType);
|
||||
world = WorldReader().readWorld(worldGob, worldName.toLower().toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,14 @@
|
|||
#include "GameType.h"
|
||||
#include "GameRegion.h"
|
||||
|
||||
class GobFile;
|
||||
class World;
|
||||
|
||||
class GameData
|
||||
{
|
||||
public:
|
||||
GameData() : gameRegion(GameRegion::UNKNOWN), gameType(GameType::UNKNOWN) {}
|
||||
GameData();
|
||||
~GameData();
|
||||
|
||||
void read(QString rootDir, QString worldName);
|
||||
|
||||
|
@ -22,6 +26,10 @@ private:
|
|||
/* Relative path from the root where the data files live. */
|
||||
QString dataRelPath;
|
||||
|
||||
GobFile* worldGob;
|
||||
World* world;
|
||||
|
||||
|
||||
private:
|
||||
void findGame(QString rootDir);
|
||||
void findGameFromElf(QString elfname);
|
||||
|
|
19
CuttownTest/infoPanel.cpp
Normal file
19
CuttownTest/infoPanel.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "InfoPanel.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
InfoPanel::InfoPanel(QWidget* parent, GameData& gameData) : gameData(gameData)
|
||||
{
|
||||
widget = new QTableWidget(1, 2, parent);
|
||||
}
|
||||
|
||||
InfoPanel::~InfoPanel()
|
||||
{
|
||||
delete widget;
|
||||
widget = nullptr;
|
||||
}
|
||||
|
||||
QWidget* InfoPanel::getWidget()
|
||||
{
|
||||
return widget;
|
||||
}
|
18
CuttownTest/infoPanel.h
Normal file
18
CuttownTest/infoPanel.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
class QWidget;
|
||||
class GameData;
|
||||
|
||||
class InfoPanel
|
||||
{
|
||||
public:
|
||||
InfoPanel(QWidget* parent, GameData& gameData);
|
||||
~InfoPanel();
|
||||
|
||||
QWidget* getWidget();
|
||||
|
||||
private:
|
||||
QWidget* widget;
|
||||
GameData& gameData;
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include <QtWidgets>
|
||||
#include "mainWindow.h"
|
||||
#include "InfoPanel.h"
|
||||
|
||||
MainWindow::MainWindow(GameData& gameDataIn)
|
||||
: textEdit(new QTextEdit), gameData(gameDataIn)
|
||||
|
@ -16,8 +17,6 @@ MainWindow::MainWindow(GameData& gameDataIn)
|
|||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
QMessageBox::about(this, tr("About World Viewer"),
|
||||
|
@ -53,13 +52,11 @@ void MainWindow::createStatusBar()
|
|||
|
||||
void MainWindow::createDockWindows()
|
||||
{
|
||||
QDockWidget* dock = new QDockWidget(tr("Structure"), this);
|
||||
QDockWidget* dock = new QDockWidget(tr("Info"), this);
|
||||
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
listWidget = new QListWidget(dock);
|
||||
listWidget->addItems(QStringList()
|
||||
<< "xxx"
|
||||
);
|
||||
dock->setWidget(listWidget);
|
||||
infoPanel = new InfoPanel(dock, gameData);
|
||||
dock->setWidget(infoPanel->getWidget());
|
||||
|
||||
addDockWidget(Qt::LeftDockWidgetArea, dock);
|
||||
viewMenu->addAction(dock->toggleViewAction());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ class QMenu;
|
|||
class QTextEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class InfoPanel;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
|
@ -30,7 +31,7 @@ private:
|
|||
void createDockWindows();
|
||||
|
||||
QTextEdit* textEdit;
|
||||
QListWidget* listWidget;
|
||||
InfoPanel* infoPanel;
|
||||
|
||||
QMenu* viewMenu;
|
||||
|
||||
|
|
Reference in a new issue