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
which simply modifies the current physics model. This should always be set to
`1` by new editors.
- `LandscapeId` is a Landscape enumeration. is the landscape number to use for
the sky. This starts at `0`, since it's an offset into the landscape
- `LandscapeId` is a Landscape enumeration. It is the landscape number to use
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
set, then this is used as the music index instead.
- `MissionFlags` is a Mission Flags bit field.

View File

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

View File

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

View File

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

View File

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

View File

@ -1,33 +1,11 @@
#pragma once
#include "bindings.h"
#include <QMdiSubWindow>
namespace Ui
{
class ProjectView;
}
#include "bindings.h"
#include "../ui/ui_projectview.h"
class ProjectModel : public QObject
{
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
class ProjectView : public QMdiSubWindow, private Ui::ProjectView
{
Q_OBJECT
@ -41,7 +19,6 @@ protected:
void closeEvent(QCloseEvent *event) override;
private:
QSharedPointer<Ui::ProjectView> ui;
QSharedPointer<ProjectModel> proj;
};

View File

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

View File

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

View File

@ -1,47 +1,63 @@
//! Project management.
use crate::qintr::*;
use std::{cell::RefCell, fs};
use memmap::Mmap;
//use memmap::Mmap;
use maraiah::map;
pub struct Project
pub struct ProjectModel
{
emit: ProjectEmitter,
wad: RefCell<Option<map::Wad>>,
emit: ProjectModelEmitter,
}
impl Drop for Project
impl Drop for ProjectModel
{
fn drop(&mut self)
{
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) {
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
}
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
{
if cfg!(debug_assertions) {
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 mm = unsafe {Mmap::map(&fp)};
@ -51,9 +67,22 @@ impl ProjectTrait for Project
self.wad.replace(Some(wad));
return true;
}
*/
false
}
fn save(&self)
{
if cfg!(debug_assertions) {
eprintln!("saving project");
}
}
fn is_dirty(&self) -> bool
{
false
}
}
// EOF

View File

@ -37,9 +37,6 @@
<layout class="QFormLayout" name="formLayout">
<item row="1" column="0">
<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">
<string>Map Name</string>
</property>
@ -47,6 +44,12 @@
</item>
<item row="1" column="1">
<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">
<number>65</number>
</property>
@ -54,10 +57,6 @@
</item>
<item row="2" column="0">
<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">
<string>Texture Set</string>
</property>
@ -71,6 +70,12 @@ Because of this, the texture sets are named after the liquids primarily.</string
<verstretch>0</verstretch>
</sizepolicy>
</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>
<property name="text">
<string>Water</string>
@ -100,9 +105,6 @@ Because of this, the texture sets are named after the liquids primarily.</string
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>The sky texture to use.</string>
</property>
<property name="text">
<string>Landscape</string>
</property>
@ -116,6 +118,12 @@ Because of this, the texture sets are named after the liquids primarily.</string
<verstretch>0</verstretch>
</sizepolicy>
</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>
<property name="text">
<string>Lh'owon Day</string>
@ -140,10 +148,6 @@ Because of this, the texture sets are named after the liquids primarily.</string
</item>
<item row="4" column="0">
<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">
<string>Music No.</string>
</property>
@ -160,6 +164,12 @@ Aleph One allows for adding music to levels, although you will need to check the
<verstretch>0</verstretch>
</sizepolicy>
</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>
</item>
</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">
<widget class="QCheckBox" name="checkBox_3">
<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 name="text">
<string>Carnage</string>

View File

@ -2,16 +2,8 @@
<ui version="4.0">
<class>Points</class>
<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">
<string>Point Editor</string>
<string>Point Inspector</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">

View File

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