mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-03 00:59:47 +02:00
Preperations for actual visuals
This commit is contained in:
parent
1741d7c295
commit
a49bfd9d99
@ -62,7 +62,7 @@ public:
|
||||
* ctor
|
||||
* @param path Path to the root of the game data.
|
||||
*/
|
||||
GameData(const std::string& path);
|
||||
GameData(const std::string& path = "");
|
||||
|
||||
GameWorld* engine;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void setArchive(const LoaderIMG& archive);
|
||||
|
||||
signals:
|
||||
void selectedFileChanged(const std::string& file);
|
||||
void selectedFileChanged(const QString& file);
|
||||
|
||||
public slots:
|
||||
void selectedIndexChanged(const QModelIndex& current);
|
||||
|
@ -1,16 +1,27 @@
|
||||
#include "ViewerWidget.hpp"
|
||||
|
||||
ViewerWidget::ViewerWidget(QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f)
|
||||
: QGLWidget(parent, shareWidget, f), gworld(nullptr), fm(ViewerWidget::UNK)
|
||||
{
|
||||
}
|
||||
|
||||
void ViewerWidget::initializeGL()
|
||||
{
|
||||
QGLWidget::initializeGL();
|
||||
timer.setInterval(16);
|
||||
connect(&timer, SIGNAL(timeout()), SLOT(updateGL()));
|
||||
timer.start();
|
||||
|
||||
glewExperimental = 1;
|
||||
glewInit();
|
||||
|
||||
gworld = new GameWorld("");
|
||||
}
|
||||
|
||||
void ViewerWidget::resizeGL(int w, int h)
|
||||
{
|
||||
QGLWidget::resizeGL(w, h);
|
||||
glViewport(0, 0, w, h);
|
||||
}
|
||||
|
||||
void ViewerWidget::paintGL()
|
||||
@ -18,15 +29,47 @@ void ViewerWidget::paintGL()
|
||||
glClearColor(0.3f, 0.3f, 0.3f, 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if( !currentFile.empty() ) {
|
||||
QString dbg;
|
||||
dbg.append("Viewing: ");
|
||||
dbg.append(currentFile.c_str());
|
||||
if( !currentFile.isEmpty() ) {
|
||||
QString dbg =
|
||||
QString("Viewing %1, %2")
|
||||
.arg(currentFile);
|
||||
switch(fm) {
|
||||
case DFF: dbg = dbg.arg("DFF");
|
||||
break;
|
||||
case TXD: dbg = dbg.arg("TXD");
|
||||
break;
|
||||
case UNK: dbg = dbg.arg("Unknown");
|
||||
break;
|
||||
}
|
||||
renderText(5, height() - 5, dbg);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::showFile(const std::string& file)
|
||||
GameWorld* ViewerWidget::world()
|
||||
{
|
||||
return gworld;
|
||||
}
|
||||
|
||||
void ViewerWidget::showFile(const QString& file)
|
||||
{
|
||||
currentFile = file;
|
||||
}
|
||||
QString low = file.toLower();
|
||||
if(low.endsWith("dff")) {
|
||||
showDFF(file);
|
||||
}
|
||||
else if(low.endsWith("txd")) {
|
||||
showTXD(file);
|
||||
}
|
||||
emit fileOpened(file);
|
||||
}
|
||||
|
||||
void ViewerWidget::showDFF(const QString& file)
|
||||
{
|
||||
gworld->gameData.loadDFF(file.toStdString());
|
||||
fm = ViewerWidget::DFF;
|
||||
}
|
||||
|
||||
void ViewerWidget::showTXD(const QString& file)
|
||||
{
|
||||
fm = ViewerWidget::TXD;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#ifndef _VIEWERWIDGET_HPP_
|
||||
#define _VIEWERWIDGET_HPP_
|
||||
#include <engine/GameData.hpp>
|
||||
#include <engine/GameWorld.hpp>
|
||||
#include <QGLWidget>
|
||||
#include <QTimer>
|
||||
|
||||
@ -8,20 +10,38 @@ class ViewerWidget : public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
std::string currentFile;
|
||||
QString currentFile;
|
||||
|
||||
QTimer timer;
|
||||
|
||||
GameWorld* gworld;
|
||||
public:
|
||||
|
||||
enum FileMode {
|
||||
TXD, DFF, UNK
|
||||
};
|
||||
|
||||
ViewerWidget(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
|
||||
|
||||
virtual void initializeGL();
|
||||
|
||||
virtual void resizeGL(int w, int h);
|
||||
|
||||
virtual void paintGL();
|
||||
|
||||
GameWorld* world();
|
||||
|
||||
public slots:
|
||||
|
||||
void showFile(const std::string& file);
|
||||
void showFile(const QString& file);
|
||||
void showDFF(const QString& file);
|
||||
void showTXD(const QString& file);
|
||||
|
||||
signals:
|
||||
|
||||
void fileOpened(const QString& file);
|
||||
|
||||
private:
|
||||
FileMode fm;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#include "ViewerWindow.hpp"
|
||||
#include <engine/GameWorld.hpp>
|
||||
#include "ViewerWidget.hpp"
|
||||
#include "ArchiveContentsWidget.hpp"
|
||||
#include <QMenuBar>
|
||||
@ -23,7 +24,8 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags): QMainWindow(
|
||||
file->addSeparator();
|
||||
file->addAction("E&xit", QApplication::instance(), SLOT(quit()), QKeySequence::Quit);
|
||||
|
||||
connect(archivewidget, SIGNAL(selectedFileChanged(std::string)), viewer, SLOT(showFile(std::string)));
|
||||
connect(archivewidget, SIGNAL(selectedFileChanged(QString)), viewer, SLOT(showFile(QString)));
|
||||
connect(viewer, SIGNAL(fileOpened(QString)), SLOT(updateTitle(QString)));
|
||||
|
||||
QSettings settings("OpenRW", "rwviewer");
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
@ -41,6 +43,8 @@ void ViewerWindow::openArchive(const QString& name)
|
||||
LoaderIMG ld;
|
||||
ld.load(rname.toStdString());
|
||||
|
||||
viewer->world()->gameData.loadIMG(rname.toStdString());
|
||||
|
||||
archivewidget->setArchive(ld);
|
||||
}
|
||||
|
||||
@ -60,3 +64,9 @@ void ViewerWindow::openArchive()
|
||||
openArchive(dialog.selectedFiles().at(0));
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWindow::updateTitle(const QString& name)
|
||||
{
|
||||
setWindowTitle(name);
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,17 @@ class ViewerWindow : public QMainWindow
|
||||
ViewerWidget* viewer;
|
||||
ArchiveContentsWidget* archivewidget;
|
||||
public:
|
||||
|
||||
ViewerWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0);
|
||||
|
||||
void openArchive(const QString& name);
|
||||
|
||||
virtual void closeEvent(QCloseEvent*);
|
||||
|
||||
public slots:
|
||||
|
||||
void openArchive();
|
||||
void updateTitle(const QString& name);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user