Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ endif()

project(commando LANGUAGES C CXX)

include(CTest)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# This file handles extra settings wanted/needed for different compilers.
Expand Down Expand Up @@ -77,14 +79,14 @@ endif()

if(W3D_BUILD_OPTION_SDL3)
include(sdl3)
add_compile_definitions(-DOPENW3D_SDL3=1)
add_compile_definitions(OPENW3D_SDL3=1)
elseif(WIN32)
add_compile_definitions(-DOPENW3D_WIN32=1)
add_compile_definitions(OPENW3D_WIN32=1)
else()
message(FATAL_ERROR "Invalid backend")
endif()

add_compile_definitions(-DWEBBROWSER_ENABLED=$<BOOL:${W3D_BUILD_OPTION_WEBBROWSER}>)
add_compile_definitions(WEBBROWSER_ENABLED=$<BOOL:${W3D_BUILD_OPTION_WEBBROWSER}>)

if(W3D_BUILD_OPTION_OPENAL)
include(openal)
Expand All @@ -106,7 +108,7 @@ endif()

if(WIN32)
# Do we want to build with bink for video decoding?
cmake_dependent_option(W3D_BUILD_OPTION_BINK "Build with bink." ON NOT W3D_BUILD_OPTION_FFMPEG OFF)
cmake_dependent_option(W3D_BUILD_OPTION_BINK "Build with bink." ON "NOT W3D_BUILD_OPTION_FFMPEG" OFF)
add_feature_info(BinkBuild W3D_BUILD_OPTION_BINK "Build OpenW3D with Bink")

if(W3D_BUILD_OPTION_BINK)
Expand All @@ -115,7 +117,7 @@ if(WIN32)
endif()

# Do we want to build with miles for audio playback?
cmake_dependent_option(W3D_BUILD_OPTION_MILES "Build with miles." ON NOT W3D_BUILD_OPTION_OPENAL OFF)
cmake_dependent_option(W3D_BUILD_OPTION_MILES "Build with miles." ON "NOT W3D_BUILD_OPTION_OPENAL" OFF)
add_feature_info(MilesBuild W3D_BUILD_OPTION_MILES "Build OpenW3D with Miles Audio")

if(W3D_BUILD_OPTION_MILES)
Expand Down
5 changes: 4 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows",
"VCPKG_INSTALLED_DIR": "C:/vcpkg.installed",
"W3D_BUILD_QT_TOOLS": "ON"
"W3D_BUILD_QT_TOOLS": "ON",
"W3D_BUILD_OPTION_FFMPEG": "ON",
"W3D_BUILD_OPTION_OPENAL": "ON",
"W3D_BUILD_OPTION_MILES": "OFF"
}
},
{
Expand Down
3 changes: 3 additions & 0 deletions Code/Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ if(W3D_BUILD_QT_TOOLS)
add_subdirectory(WDumpCore)
add_subdirectory(WWConfigQt)
add_subdirectory(WDumpQt)
if(WIN32)
add_subdirectory(W3DViewQt)
endif()
endif()
2 changes: 2 additions & 0 deletions Code/Tools/QtCommon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(QTCOMMON_SRC
RecentFiles.cpp
RecentFiles.h
ShortcutHelpers.cpp
ShortcutHelpers.h
)

add_library(qtcommon STATIC)
Expand Down
22 changes: 22 additions & 0 deletions Code/Tools/QtCommon/ShortcutHelpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "ShortcutHelpers.h"

#include <QAction>
#include <QKeySequence>
#include <QWidget>

namespace qtcommon {

QAction *CreateWindowShortcutAction(QWidget *window, const QList<QKeySequence> &shortcuts)
{
if (!window || shortcuts.isEmpty()) {
return nullptr;
}

auto *action = new QAction(window);
action->setShortcuts(shortcuts);
action->setShortcutContext(Qt::WindowShortcut);
window->addAction(action);
return action;
}

} // namespace qtcommon
13 changes: 13 additions & 0 deletions Code/Tools/QtCommon/ShortcutHelpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <QList>

class QAction;
class QKeySequence;
class QWidget;

namespace qtcommon {

QAction *CreateWindowShortcutAction(QWidget *window, const QList<QKeySequence> &shortcuts);

} // namespace qtcommon
75 changes: 75 additions & 0 deletions Code/Tools/W3DViewQt/AddToLineupDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include "AddToLineupDialog.h"

#include "W3DViewport.h"
#include "ui_AddToLineupDialog.h"

#include "assetmgr.h"
#include "rendobj.h"

#include <QComboBox>
#include <QDialogButtonBox>
#include <QMessageBox>

AddToLineupDialog::AddToLineupDialog(W3DViewport *viewport, QWidget *parent)
: QDialog(parent)
, _viewport(viewport)
, _ui(new Ui::AddToLineupDialog)
{
_ui->setupUi(this);

connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &AddToLineupDialog::accept);
connect(_ui->buttonBox, &QDialogButtonBox::rejected, this, &AddToLineupDialog::reject);

populateObjects();
}

AddToLineupDialog::~AddToLineupDialog()
{
delete _ui;
}

QString AddToLineupDialog::selectedName() const
{
return _ui->objectComboBox->currentText().trimmed();
}

void AddToLineupDialog::accept()
{
const QString name = selectedName();
if (name.isEmpty()) {
QMessageBox::information(this, "Add To Lineup", "Please select an object or enter a name.");
return;
}

QDialog::accept();
}

void AddToLineupDialog::populateObjects()
{
if (!_viewport) {
return;
}

auto *asset_manager = WW3DAssetManager::Get_Instance();
if (!asset_manager) {
return;
}

RenderObjIterator *iterator = asset_manager->Create_Render_Obj_Iterator();
if (!iterator) {
return;
}

for (iterator->First(); !iterator->Is_Done(); iterator->Next()) {
const int class_id = iterator->Current_Item_Class_ID();
if (!_viewport->canLineUpClass(class_id)) {
continue;
}
const char *name = iterator->Current_Item_Name();
if (name && name[0]) {
_ui->objectComboBox->addItem(QString::fromLatin1(name));
}
}

asset_manager->Release_Render_Obj_Iterator(iterator);
}
28 changes: 28 additions & 0 deletions Code/Tools/W3DViewQt/AddToLineupDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include <QDialog>

class W3DViewport;

namespace Ui {
class AddToLineupDialog;
}

class AddToLineupDialog final : public QDialog
{
Q_OBJECT

public:
explicit AddToLineupDialog(W3DViewport *viewport, QWidget *parent = nullptr);
~AddToLineupDialog() override;
QString selectedName() const;

protected:
void accept() override;

private:
void populateObjects();

W3DViewport *_viewport = nullptr;
Ui::AddToLineupDialog *_ui = nullptr;
};
41 changes: 41 additions & 0 deletions Code/Tools/W3DViewQt/AddToLineupDialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddToLineupDialog</class>
<widget class="QDialog" name="AddToLineupDialog">
<property name="windowTitle">
<string>Add To Lineup</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="objectLabel">
<property name="text">
<string>&amp;Object:</string>
</property>
<property name="buddy">
<cstring>objectComboBox</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="objectComboBox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading
Loading