Skip to content

Commit

Permalink
lightpreview: show leaf contents in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwa committed Mar 25, 2024
1 parent 64826f4 commit 1b289d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lightpreview/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ void MainWindow::createOutputLog()

void MainWindow::createStatusBar()
{
statusBar();
m_cameraStatus = new QLabel();
statusBar()->addWidget(m_cameraStatus);
}

/**
Expand Down Expand Up @@ -1030,12 +1031,23 @@ void MainWindow::loadFileInternal(const QString &file, bool is_reload)

void MainWindow::displayCameraPositionInfo()
{
const auto *bsp = std::get_if<mbsp_t>(&m_bspdata.bsp);
if (!bsp)
return;

const qvec3f point = glView->cameraPosition();
[[maybe_unused]] const mleaf_t *leaf = BSP_FindLeafAtPoint(bsp, &bsp->dmodels[0], point);
const qvec3f forward = glView->cameraForward();

std::string leaf_type;
{
const auto *bsp = std::get_if<mbsp_t>(&m_bspdata.bsp);
if (!bsp)
return;

const mleaf_t *leaf = BSP_FindLeafAtPoint(bsp, &bsp->dmodels[0], point);
if (leaf) {
auto *game = bsp->loadversion->game;
leaf_type = game->create_contents_from_native(leaf->contents).to_string(game);
}
}

std::string cpp_str = fmt::format("pos ({}) forward ({}) contents ({})", point, forward, leaf_type);

// TODO: display leaf info
m_cameraStatus->setText(QString::fromStdString(cpp_str));
}
2 changes: 2 additions & 0 deletions lightpreview/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class QCheckBox;
class QStringList;
class QTextEdit;
class StatsPanel;
class QLabel;

enum class ETLogTab
{
Expand Down Expand Up @@ -77,6 +78,7 @@ class MainWindow : public QMainWindow
qint64 m_fileSize = -1;
ETLogTab m_activeLogTab = ETLogTab::TAB_LIGHTPREVIEW;
QThread *m_compileThread = nullptr;
QLabel *m_cameraStatus = nullptr;

public:
explicit MainWindow(QWidget *parent = nullptr);
Expand Down

0 comments on commit 1b289d3

Please sign in to comment.