Compare commits

...

4 Commits

14 changed files with 121 additions and 149 deletions

View File

@ -971,8 +971,8 @@ Static Map Info is 88 bytes.
one ended up being useless and the third was made into a map flag instead one ended up being useless and the third was made into a map flag instead
which simply modifies the current physics model. This should always be set to which simply modifies the current physics model. This should always be set to
`1` by new editors. `1` by new editors.
- `LandscapeId` is a Landscape enumeration. is the landscape number to use for - `LandscapeId` is a Landscape enumeration. It is the landscape number to use
the sky. This starts at `0`, since it's an offset into the landscape for the sky. This starts at `0`, since it's an offset into the landscape
collections. If `DataVersion` is `DataM1` or the `Music` flag of `EnvFlags` is collections. If `DataVersion` is `DataM1` or the `Music` flag of `EnvFlags` is
set, then this is used as the music index instead. set, then this is used as the music index instead.
- `MissionFlags` is a Mission Flags bit field. - `MissionFlags` is a Mission Flags bit field.

View File

@ -29,7 +29,6 @@ add_library(
cc_source/main.cc cc_source/main.cc
cc_source/mapprops.cc cc_source/mapprops.cc
cc_source/menu.cc cc_source/menu.cc
cc_source/projectmodel.cc
cc_source/projectview.cc cc_source/projectview.cc
resources/resources.qrc resources/resources.qrc
ui/about.ui ui/about.ui

View File

@ -6,8 +6,8 @@
"implementationModule": "qimpl" "implementationModule": "qimpl"
}, },
"objects": { "objects": {
"Project": { "ProjectModel": {
"type": "Object", "type": "List",
"functions": { "functions": {
"open": { "open": {
"return": "bool", "return": "bool",
@ -16,11 +16,27 @@
"name": "fname", "name": "fname",
"type": "QString" "type": "QString"
}] }]
},
"save": {
"return": "void",
"mut": false
},
"isDirty": {
"return": "bool",
"mut": false
} }
}, },
"properties": { "properties": {
}, },
"itemProperties": { "itemProperties": {
"rowName": {
"type": "quint64",
"roles": [["display"]]
},
"someNumber": {
"type": "quint64",
"roles": [[], ["display"]]
}
} }
} }
} }

View File

@ -2,14 +2,11 @@
#include <QDialog> #include <QDialog>
#include "../ui/ui_mapprops.h"
class ProjectModel; class ProjectModel;
namespace Ui class MapProps : public QDialog, private Ui::MapProps
{
class MapProps;
}
class MapProps : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -20,7 +17,6 @@ public:
private: private:
QSharedPointer<ProjectModel> proj; QSharedPointer<ProjectModel> proj;
QSharedPointer<Ui::MapProps> ui;
}; };
// EOF // EOF

View File

@ -3,15 +3,11 @@
#include <QMainWindow> #include <QMainWindow>
#include <vector> #include <vector>
#include "../ui/ui_menu.h"
class ProjectView; class ProjectView;
class QMdiSubWindow;
namespace Ui class Menu : public QMainWindow, private Ui::Menu
{
class Menu;
}
class Menu : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -34,8 +30,6 @@ private:
ProjectView *activeProject() const; ProjectView *activeProject() const;
QMdiSubWindow *activeSubWindow() const; QMdiSubWindow *activeSubWindow() const;
void addProject(ProjectView *view); void addProject(ProjectView *view);
QSharedPointer<Ui::Menu> ui;
}; };
// EOF // EOF

View File

@ -1,33 +1,11 @@
#pragma once #pragma once
#include "bindings.h"
#include <QMdiSubWindow> #include <QMdiSubWindow>
namespace Ui #include "bindings.h"
{ #include "../ui/ui_projectview.h"
class ProjectView;
}
class ProjectModel : public QObject class ProjectView : public QMdiSubWindow, private Ui::ProjectView
{
Q_OBJECT
public:
explicit ProjectModel();
~ProjectModel();
bool isDirty() const;
public slots:
bool open(const QString &fname);
void save();
private:
Project data;
};
class ProjectView : public QMdiSubWindow
{ {
Q_OBJECT Q_OBJECT
@ -41,7 +19,6 @@ protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
private: private:
QSharedPointer<Ui::ProjectView> ui;
QSharedPointer<ProjectModel> proj; QSharedPointer<ProjectModel> proj;
}; };

View File

@ -1,21 +1,19 @@
#include "tycho.h" #include "tycho.h"
#include "mapprops.h" #include "mapprops.h"
#include "../ui/ui_mapprops.h"
#include <QDialogButtonBox> #include <QDialogButtonBox>
MapProps::MapProps(QSharedPointer<ProjectModel> _proj, QWidget *parent) : MapProps::MapProps(QSharedPointer<ProjectModel> _proj, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::MapProps),
proj(_proj) proj(_proj)
{ {
ui->setupUi(this); setupUi(this);
setModal(true); setModal(true);
auto bbox = new QDialogButtonBox(this); auto bbox = new QDialogButtonBox(this);
bbox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); bbox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
ui->verticalLayout->addWidget(bbox); verticalLayout->addWidget(bbox);
connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
connect(bbox, SIGNAL(rejected()), this, SLOT(reject())); connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));

View File

@ -2,7 +2,6 @@
#include "mapprops.h" #include "mapprops.h"
#include "menu.h" #include "menu.h"
#include "project.h" #include "project.h"
#include "../ui/ui_menu.h"
#include "../ui/ui_about.h" #include "../ui/ui_about.h"
#include "../ui/ui_license.h" #include "../ui/ui_license.h"
@ -12,17 +11,16 @@
#include <iostream> #include <iostream>
Menu::Menu(QWidget *parent) : Menu::Menu(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent)
ui(new Ui::Menu)
{ {
ui->setupUi(this); setupUi(this);
ui->actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents)); actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents));
ui->actionClose->setShortcut(QKeySequence(QKeySequence::Close)); actionClose->setShortcut(QKeySequence(QKeySequence::Close));
ui->actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P"))); actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P")));
ui->actionNew->setShortcut(QKeySequence(QKeySequence::New)); actionNew->setShortcut(QKeySequence(QKeySequence::New));
ui->actionOpen->setShortcut(QKeySequence(QKeySequence::Open)); actionOpen->setShortcut(QKeySequence(QKeySequence::Open));
ui->actionQuit->setShortcut(QKeySequence(QKeySequence::Quit)); actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
dbgPrintFunc(); dbgPrintFunc();
} }
@ -111,15 +109,15 @@ void Menu::updateActions()
auto view = activeProject(); auto view = activeProject();
bool active = view != nullptr; bool active = view != nullptr;
ui->actionClose->setEnabled(active); actionClose->setEnabled(active);
ui->actionMapProps->setEnabled(active); actionMapProps->setEnabled(active);
dbgPrintFunc(); dbgPrintFunc();
} }
void Menu::closeEvent(QCloseEvent *event) void Menu::closeEvent(QCloseEvent *event)
{ {
for(auto *win : ui->mdiArea->subWindowList()) { for(auto *win : mdiArea->subWindowList()) {
if(!win->close()) { if(!win->close()) {
event->ignore(); event->ignore();
return; return;
@ -136,12 +134,13 @@ ProjectView *Menu::activeProject() const
QMdiSubWindow *Menu::activeSubWindow() const QMdiSubWindow *Menu::activeSubWindow() const
{ {
return ui->mdiArea->activeSubWindow(); return mdiArea->activeSubWindow();
} }
void Menu::addProject(ProjectView *view) void Menu::addProject(ProjectView *view)
{ {
auto win = ui->mdiArea->addSubWindow(view); auto win = mdiArea->addSubWindow(view);
win->showMaximized(); win->showMaximized();
} }

View File

@ -1,29 +0,0 @@
#include "tycho.h"
#include "project.h"
ProjectModel::ProjectModel() :
data()
{
}
ProjectModel::~ProjectModel()
{
dbgPrintFunc();
}
bool ProjectModel::isDirty() const
{
return false;
}
bool ProjectModel::open(const QString &fname)
{
return data.open(fname);
}
void ProjectModel::save()
{
dbgPrintFunc();
}
// EOF

View File

@ -1,22 +1,22 @@
#include "tycho.h" #include "tycho.h"
#include "project.h" #include "project.h"
#include "../ui/ui_projectview.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QMessageBox> #include <QMessageBox>
ProjectView::ProjectView(QWidget *parent) : ProjectView::ProjectView(QWidget *parent) :
QMdiSubWindow(parent), QMdiSubWindow(parent),
ui(new Ui::ProjectView),
proj(new ProjectModel) proj(new ProjectModel)
{ {
auto widget = new QWidget(this); auto widget = new QWidget(this);
ui->setupUi(widget); setupUi(widget);
setWidget(widget); setWidget(widget);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
listView->setModel(proj.data());
dbgPrintFunc(); dbgPrintFunc();
} }

View File

@ -1,47 +1,63 @@
//! Project management.
use crate::qintr::*; use crate::qintr::*;
use std::{cell::RefCell, fs}; //use memmap::Mmap;
use memmap::Mmap;
use maraiah::map; use maraiah::map;
pub struct Project pub struct ProjectModel
{ {
emit: ProjectEmitter, emit: ProjectModelEmitter,
wad: RefCell<Option<map::Wad>>,
} }
impl Drop for Project impl Drop for ProjectModel
{ {
fn drop(&mut self) fn drop(&mut self)
{ {
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
eprintln!("drop Project"); eprintln!("drop ProjectModel");
} }
} }
} }
impl ProjectTrait for Project impl ProjectModelTrait for ProjectModel
{ {
fn new(emit: ProjectEmitter) -> Project fn new(emit: ProjectModelEmitter, _: ProjectModelList) -> ProjectModel
{ {
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
eprintln!("new Project"); eprintln!("new ProjectModel");
} }
Project{emit, wad: RefCell::new(None)} ProjectModel{emit}
} }
fn emit(&mut self) -> &mut ProjectEmitter fn emit(&mut self) -> &mut ProjectModelEmitter
{ {
&mut self.emit &mut self.emit
} }
fn row_count(&self) -> usize
{
7
}
fn row_name(&self, row: usize) -> u64
{
row as u64 + 1
}
fn some_number(&self, row: usize) -> u64
{
69420
}
fn open(&mut self, path: String) -> bool fn open(&mut self, path: String) -> bool
{ {
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
eprintln!("opening project: {}", &path); eprintln!("opening project: {}", &path);
} }
let fp = fs::File::open(path); /*
let fp = std::fs::File::open(path);
let fp = if let Ok(fp) = fp {fp} else {return false;}; let fp = if let Ok(fp) = fp {fp} else {return false;};
let mm = unsafe {Mmap::map(&fp)}; let mm = unsafe {Mmap::map(&fp)};
@ -51,9 +67,22 @@ impl ProjectTrait for Project
self.wad.replace(Some(wad)); self.wad.replace(Some(wad));
return true; return true;
} }
*/
false false
} }
fn save(&self)
{
if cfg!(debug_assertions) {
eprintln!("saving project");
}
}
fn is_dirty(&self) -> bool
{
false
}
} }
// EOF // EOF

View File

@ -37,9 +37,6 @@
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="toolTip">
<string>The name of the map. This is used in the level selection menu.</string>
</property>
<property name="text"> <property name="text">
<string>Map Name</string> <string>Map Name</string>
</property> </property>
@ -47,6 +44,12 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="lineEdit"> <widget class="QLineEdit" name="lineEdit">
<property name="toolTip">
<string>The name of the map. This is used in the level selection menu.</string>
</property>
<property name="whatsThis">
<string>The map name can be up to 65 characters, and a limited set of special characters may be used. The text encoding is actually Macintosh Roman, although in this program it is encoded as Unicode, and will be translated accordingly.</string>
</property>
<property name="maxLength"> <property name="maxLength">
<number>65</number> <number>65</number>
</property> </property>
@ -54,10 +57,6 @@
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="toolTip">
<string>The texture set to use. This determines every texture that will be used, and all of the liquids.
Because of this, the texture sets are named after the liquids primarily.</string>
</property>
<property name="text"> <property name="text">
<string>Texture Set</string> <string>Texture Set</string>
</property> </property>
@ -71,6 +70,12 @@ Because of this, the texture sets are named after the liquids primarily.</string
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>This determines the set of textures and liquids that will be used.</string>
</property>
<property name="whatsThis">
<string>This is an offset from the first texture collection in the Shapes file. The kind of liquid the level uses is also determined by this field due to the way the engine is programmed.</string>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Water</string> <string>Water</string>
@ -100,9 +105,6 @@ Because of this, the texture sets are named after the liquids primarily.</string
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="toolTip">
<string>The sky texture to use.</string>
</property>
<property name="text"> <property name="text">
<string>Landscape</string> <string>Landscape</string>
</property> </property>
@ -116,6 +118,12 @@ Because of this, the texture sets are named after the liquids primarily.</string
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>The sky texture to use.</string>
</property>
<property name="whatsThis">
<string>This is an offset from the first landscape collection in the Shapes file.</string>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Lh'owon Day</string> <string>Lh'owon Day</string>
@ -140,10 +148,6 @@ Because of this, the texture sets are named after the liquids primarily.</string
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="toolTip">
<string>The ID of the music to use. This is generally unused since Marathon 2 and Infinity don't have music.
Aleph One allows for adding music to levels, although you will need to check the &quot;Music&quot; flag to use this field.</string>
</property>
<property name="text"> <property name="text">
<string>Music No.</string> <string>Music No.</string>
</property> </property>
@ -160,6 +164,12 @@ Aleph One allows for adding music to levels, although you will need to check the
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>The ID of the music to use. This replaces the Landscape field.</string>
</property>
<property name="whatsThis">
<string>This is generally unused since Marathon 2 and Infinity don't have music. Aleph One allows for adding music to levels, although you will need to check the &quot;Music&quot; flag to use this field.</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -179,7 +189,7 @@ Aleph One allows for adding music to levels, although you will need to check the
<item row="2" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="checkBox_3"> <widget class="QCheckBox" name="checkBox_3">
<property name="toolTip"> <property name="toolTip">
<string>The map can be played in the Carnage game mode, often known as Deathmatch.</string> <string>The map can be played in the Carnage game mode.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Carnage</string> <string>Carnage</string>

View File

@ -2,16 +2,8 @@
<ui version="4.0"> <ui version="4.0">
<class>Points</class> <class>Points</class>
<widget class="QWidget" name="Points"> <widget class="QWidget" name="Points">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>82</height>
</rect>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Point Editor</string> <string>Point Inspector</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">

View File

@ -15,21 +15,12 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QCheckBox" name="checkBox"> <widget class="QListView" name="listView">
<property name="enabled"> <property name="verticalScrollBarPolicy">
<bool>false</bool> <enum>Qt::ScrollBarAlwaysOn</enum>
</property> </property>
<property name="text"> <property name="horizontalScrollBarPolicy">
<string>gay</string> <enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>