Compare commits

..

No commits in common. "8889bcf1a460ac20d73fb5bcf0eb8aa0d4176c82" and "82d0d378b0296388b6927e17b58e2a34ac89fc11" have entirely different histories.

21 changed files with 86 additions and 323 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "maraiah"
version = "0.1.0"
authors = ["Alison Watson <marrub@greyserv.net>", "Tae Matous"]
authors = ["Alison Watson <marrub@greyserv.net>"]
description = "Marathon editing tools."
homepage = "https://greyserv.net/maraiah/"
repository = "http://git.greyserv.net/marrub/Maraiah"

12
LICENSE
View File

@ -1,10 +1,10 @@
Some of the data contained in tests/data and benches/data is Copyright © Bungie
Software. I do not own them, but am permitted to redistribute them. Everything
else is public domain, as stated:
Some of the data contained in tests/data and benches/data is
Copyright © Bungie Software. I do not own them, but am permitted to
redistribute them. Everything else is public domain, as stated:
To the extent possible under law, I, Alison Watson, and all other contributors
to Maraiah, have waived all copyright and related or neighboring rights to this
Document as described by the Creative Commons Zero license as follows:
To the extent possible under law, I, Alison Watson, have waived all
copyright and related or neighboring rights to this Document as described by
the Creative Commons Zero license as follows:
Creative Commons Legal Code

View File

@ -64,7 +64,6 @@ pub mod fixed;
pub mod image;
pub mod machdr;
pub mod map;
pub mod meta;
pub mod shp;
pub mod snd;
pub mod sound;

View File

@ -96,7 +96,7 @@ pub enum Chunk
/** `LINS` chunks. */ Lins(Vec<map::lins::Line>),
/** `LITE` chunks. */ Lite(Vec<map::lite::Light>),
/** `MNpx` chunks. */ Mnpx(Vec<map::mnpx::Monster>),
/** `Minf` chunks. */ Minf(map::minf::Info),
/** `Minf` chunks. */ Minf(map::minf::Minf),
/** `NAME` chunks. */ Name(Vec<String>),
/** `NOTE` chunks. */ Note(Vec<map::note::Note>),
/** `OBJS` chunks. */ Objs(Vec<map::objs::Object>),

View File

@ -1,10 +1,10 @@
//! `Info` type.
//! `Minf` type.
use crate::{err::*, text::*};
use bitflags::bitflags;
/// Reads a `Minf` chunk.
pub fn read(b: &[u8]) -> ResultS<Info>
pub fn read(b: &[u8]) -> ResultS<Minf>
{
read_data! {
endian: BIG, buf: b, size: 88, start: 0, data {
@ -18,12 +18,12 @@ pub fn read(b: &[u8]) -> ResultS<Info>
}
}
Ok(Info{texture_id, physics_id, skypict_id, miss_flags, envi_flags,
Ok(Minf{texture_id, physics_id, skypict_id, miss_flags, envi_flags,
entr_flags, level_name})
}
/// Writes a `Minf` chunk.
pub fn write(v: &Info) -> Vec<u8>
pub fn write(v: &Minf) -> Vec<u8>
{
let mut o = Vec::with_capacity(4);
o.extend(&v.texture_id.to_be_bytes());
@ -37,7 +37,7 @@ pub fn write(v: &Info) -> Vec<u8>
}
/// Reads an old `Minf` chunk.
pub fn read_old(b: &[u8]) -> ResultS<Info>
pub fn read_old(b: &[u8]) -> ResultS<Minf>
{
let minf = read(b)?;
@ -51,10 +51,10 @@ pub fn read_old(b: &[u8]) -> ResultS<Info>
entr_flags.insert(EntFlags::CO_OP)
}
Ok(Info{entr_flags, ..minf})
Ok(Minf{entr_flags, ..minf})
}
impl Default for Info
impl Default for Minf
{
fn default() -> Self
{
@ -71,7 +71,7 @@ impl Default for Info
/// Static map information.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Info
pub struct Minf
{
pub texture_id: u16,
pub physics_id: u16,

View File

@ -1,28 +0,0 @@
//! Meta-information of this crate.
use crate::ffi;
macro_rules! meta_str {
($($name:ident = $cname:ident = $e:expr;)*) => {
$(
pub const $name: &'static str = $e;
pub const $cname: ffi::NT = c_str!($e);
)*
}
}
meta_str!(
AUTHORS = C_AUTHORS = env!("CARGO_PKG_AUTHORS");
DESCRIPTION = C_DESCRIPTION = env!("CARGO_PKG_DESCRIPTION");
HOMEPAGE = C_HOMEPAGE = env!("CARGO_PKG_HOMEPAGE");
LICENSE_TEXT = C_LICENSE_TEXT = include_str!("../LICENSE");
NAME = C_NAME = env!("CARGO_PKG_NAME");
REPOSITORY = C_REPOSITORY = env!("CARGO_PKG_REPOSITORY");
VERSION = C_VERSION = env!("CARGO_PKG_VERSION");
VERSION_MAJOR = C_VERSION_MAJOR = env!("CARGO_PKG_VERSION_MAJOR");
VERSION_MINOR = C_VERSION_MINOR = env!("CARGO_PKG_VERSION_MINOR");
VERSION_PATCH = C_VERSION_PATCH = env!("CARGO_PKG_VERSION_PATCH");
VERSION_PRE = C_VERSION_PRE = env!("CARGO_PKG_VERSION_PRE");
);
// EOF

View File

@ -33,12 +33,10 @@ add_library(
cc_source/projectview.cc
resources/resources.qrc
ui/about.ui
ui/license.ui
ui/mapprops.ui
ui/mapview.ui
ui/menu.ui
ui/points.ui
ui/projectview.ui
)
set_target_properties(
@ -55,6 +53,13 @@ target_include_directories(
$ENV{OUT_DIR}
)
target_compile_definitions(
maraiah-tycho-hermes
PUBLIC
-DTYCHO_VERSION=\"$ENV{CARGO_PKG_VERSION}\"
-DTYCHO_AUTHORS=\"$ENV{CARGO_PKG_AUTHORS}\"
)
target_link_libraries(
maraiah-tycho-hermes
Qt5::Core

View File

@ -1,8 +1,10 @@
[package]
name = "maraiah-tycho"
version = "0.0.0"
edition = "2018"
build = "build.rs"
name = "maraiah-tycho"
version = "0.1.0"
authors = ["Alison Watson <marrub@greyserv.net>", "Tae Matous"]
description = "Tycho map editor."
edition = "2018"
build = "build.rs"
[dependencies]
maraiah = {path = "../.."}
@ -10,7 +12,6 @@ memmap = "0.7"
[build-dependencies]
cmake = "0.1"
maraiah = {path = "../.."}
rust_qt_binding_generator = "0.3"
[[bin]]

View File

@ -28,12 +28,11 @@ public slots:
protected:
void closeEvent(QCloseEvent *event) override;
void openLicense(QWidget *parent);
private:
ProjectView *activeProject() const;
QMdiSubWindow *activeSubWindow() const;
void addProject(ProjectView *view);
void addProject(ProjectView *proj);
QSharedPointer<Ui::Menu> ui;
};

View File

@ -20,12 +20,4 @@ constexpr std::uint32_t fourCC(std::uint8_t a,
return (a << 24) | (b << 16) | (c << 8) | d;
}
extern "C" {
char const *tychoAuthors();
char const *tychoHomepage();
char const *tychoLicenseText();
char const *tychoRepository();
char const *tychoVersion();
}
// EOF

View File

@ -4,7 +4,6 @@
#include "project.h"
#include "../ui/ui_menu.h"
#include "../ui/ui_about.h"
#include "../ui/ui_license.h"
#include <QCloseEvent>
#include <QFileDialog>
@ -17,12 +16,11 @@ Menu::Menu(QWidget *parent) :
{
ui->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->actionNew->setShortcut(QKeySequence(QKeySequence::New));
ui->actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
ui->actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents));
ui->actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P")));
dbgPrintFunc();
}
@ -58,40 +56,11 @@ void Menu::mapOpen()
void Menu::openAbout()
{
QDialog dlg{this};
Ui::About ui{};
Ui::About about{};
ui.setupUi(&dlg);
auto text = ui.labelText->text();
text.replace("AUTHORS",
tr(tychoAuthors()).replace(':', ", ").toHtmlEscaped());
text.replace("HOMEPAGE", tr(tychoHomepage()));
text.replace("REPOSITORY", tr(tychoRepository()));
text.replace("VERSION", tr(tychoVersion()));
ui.labelText->setText(text);
connect(ui.btnLicense, &QPushButton::clicked, this, [&](){
openLicense(&dlg);
});
dlg.exec();
}
void Menu::openLicense(QWidget *parent)
{
QDialog dlg{parent};
Ui::License ui{};
ui.setupUi(&dlg);
ui.text->setPlainText(tychoLicenseText());
connect(ui.btnCopy, &QPushButton::clicked, this, [&]() {
ui.text->selectAll();
ui.text->copy();
});
about.setupUi(&dlg);
about.labelVer->setText(tr(TYCHO_VERSION));
about.labelAuthors->setText(tr(TYCHO_AUTHORS).replace(':', '\n'));
dlg.exec();
}
@ -111,10 +80,7 @@ void Menu::updateActions()
auto view = activeProject();
bool active = view != nullptr;
ui->actionClose->setEnabled(active);
ui->actionMapProps->setEnabled(active);
dbgPrintFunc();
}
void Menu::closeEvent(QCloseEvent *event)
@ -131,7 +97,8 @@ void Menu::closeEvent(QCloseEvent *event)
ProjectView *Menu::activeProject() const
{
return qobject_cast<ProjectView *>(activeSubWindow());
auto win = activeSubWindow();
return win ? qobject_cast<ProjectView *>(win->widget()) : nullptr;
}
QMdiSubWindow *Menu::activeSubWindow() const

View File

@ -13,7 +13,7 @@ ProjectModel::~ProjectModel()
bool ProjectModel::isDirty() const
{
return false;
return true;
}
bool ProjectModel::open(const QString &fname)

View File

@ -11,11 +11,8 @@ ProjectView::ProjectView(QWidget *parent) :
proj(new ProjectModel)
{
auto widget = new QWidget(this);
ui->setupUi(widget);
setWidget(widget);
setAttribute(Qt::WA_DeleteOnClose);
dbgPrintFunc();
}

View File

@ -1,6 +1,5 @@
use maraiah::{err::*, ffi};
mod meta;
mod qimpl;
mod qintr;

View File

@ -1,25 +0,0 @@
//! Meta-information exposing functions.
use maraiah::{ffi, meta};
macro_rules! meta_str {
($($name:ident = $e:expr;)*) => {
$(
#[no_mangle]
pub extern "C" fn $name() -> ffi::NT
{
$e
}
)*
}
}
meta_str!(
tychoAuthors = meta::C_AUTHORS;
tychoHomepage = meta::C_HOMEPAGE;
tychoLicenseText = meta::C_LICENSE_TEXT;
tychoRepository = meta::C_REPOSITORY;
tychoVersion = meta::C_VERSION;
);
// EOF

View File

@ -1,5 +1,3 @@
//! Qt implementation.
mod project;
pub use self::project::*;

View File

@ -1,4 +1,3 @@
//! Qt interface.
#![allow(unused_imports)]
#![allow(dead_code)]

View File

@ -9,22 +9,19 @@
<rect>
<x>0</x>
<y>0</y>
<width>675</width>
<height>305</height>
<width>669</width>
<height>281</height>
</rect>
</property>
<property name="windowTitle">
<string>About Tycho</string>
</property>
<property name="windowIcon">
<iconset theme="dialog-information"/>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelImage">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;img src=&quot;qrc:///tycho/misc/tycho2.png&quot;/&gt;</string>
</property>
@ -33,64 +30,47 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelText">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;h1&gt;Tycho&lt;/h1&gt;
&lt;h4&gt;VERSION&lt;/h4&gt;
&lt;p&gt;Tycho is a map editor for Marathon 2 and Marathon Infinity.&lt;/p&gt;
&lt;p&gt;Marathon is Copyright © Bungie Software.&lt;/p&gt;
&lt;p&gt;Tycho is public domain software under the CC0 license.&lt;/p&gt;
&lt;p&gt;Home: &lt;a href=&quot;HOMEPAGE&quot;&gt;HOMEPAGE&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Source code: &lt;a href=&quot;REPOSITORY&quot;&gt;REPOSITORY&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Made by AUTHORS&lt;/p&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
<string>&lt;h1&gt;Tycho&lt;/h1&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnLicense">
<property name="text">
<string>License Info</string>
</property>
<property name="icon">
<iconset theme="help-about"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="text">
<string>Close</string>
</property>
<property name="icon">
<iconset theme="window-close"/>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="labelVer">
<property name="text">
<string>VERSION NUMBER</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Tycho is a map editor for Marathon 2 and Marathon Infinity.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Marathon is Copyright © Bungie Software.
Tycho is public domain software under the CC0 license.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelAuthors">
<property name="text">
<string>AUTHORS</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</item>
@ -101,18 +81,18 @@
</resources>
<connections>
<connection>
<sender>btnClose</sender>
<signal>clicked()</signal>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>About</receiver>
<slot>accept()</slot>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>622</x>
<x>479</x>
<y>256</y>
</hint>
<hint type="destinationlabel">
<x>337</x>
<y>143</y>
<x>334</x>
<y>140</y>
</hint>
</hints>
</connection>

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>License</class>
<widget class="QDialog" name="License">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="text">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="backgroundVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnCopy">
<property name="text">
<string>Copy</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="text">
<string>Close</string>
</property>
<property name="icon">
<iconset theme="window-close"/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>btnClose</sender>
<signal>clicked()</signal>
<receiver>License</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>548</x>
<y>374</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>199</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -61,8 +61,6 @@
<addaction name="actionNew"/>
<addaction name="actionOpen"/>
<addaction name="separator"/>
<addaction name="actionClose"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuEdit">
@ -130,17 +128,6 @@
<string>&amp;About Tycho</string>
</property>
</action>
<action name="actionClose">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="window-close"/>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
@ -243,22 +230,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionClose</sender>
<signal>triggered()</signal>
<receiver>mdiArea</receiver>
<slot>closeActiveSubWindow()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>301</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>openMapProperties()</slot>

View File

@ -1,4 +1,4 @@
map::minf::Info{
map::minf::Minf{
texture_id: 0,
physics_id: 1,
skypict_id: 1,