From 17856bbe7ebbdc0ff8e82c8099ca5dede473aafc Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Thu, 30 May 2019 03:09:58 -0400 Subject: [PATCH] tycho: various UI changes --- CMakeLists.txt | 13 +- source/tycho-qt/common.h | 29 ---- .../{tycho => tycho-qt}/data/color/lines.png | Bin source/{tycho => tycho-qt}/data/color/map.png | Bin .../{tycho => tycho-qt}/data/color/points.png | Bin .../data/color/polygons.png | Bin source/{tycho => tycho-qt}/data/hc/lines.png | Bin source/{tycho => tycho-qt}/data/hc/map.png | Bin source/{tycho => tycho-qt}/data/hc/points.png | Bin .../{tycho => tycho-qt}/data/hc/polygons.png | Bin .../{tycho => tycho-qt}/data/misc/tycho1.png | Bin .../{tycho => tycho-qt}/data/misc/tycho2.png | Bin .../data/sources/icons.psd | Bin .../data/sources/tycho1.psd | Bin .../data/sources/tycho2.psd | Bin source/tycho-qt/main.cc | 5 - source/tycho-qt/mapprops.cc | 17 --- source/tycho-qt/mapprops.h | 23 --- source/tycho-qt/resources.qrc | 14 ++ source/tycho-qt/tycho.h | 9 ++ source/tycho-qt/viewmap.ui | 24 +++ source/tycho-qt/winabout.ui | 94 ++++++++++++ source/tycho-qt/winmapprops.cc | 17 +++ source/tycho-qt/winmapprops.h | 23 +++ .../tycho-qt/{mapprops.ui => winmapprops.ui} | 24 ++- source/tycho-qt/winmenu.cc | 42 +++++- source/tycho-qt/winmenu.h | 7 +- source/tycho-qt/winmenu.ui | 137 +++++++++++++++++- source/tycho/lib.rs | 13 +- 29 files changed, 396 insertions(+), 95 deletions(-) delete mode 100644 source/tycho-qt/common.h rename source/{tycho => tycho-qt}/data/color/lines.png (100%) rename source/{tycho => tycho-qt}/data/color/map.png (100%) rename source/{tycho => tycho-qt}/data/color/points.png (100%) rename source/{tycho => tycho-qt}/data/color/polygons.png (100%) rename source/{tycho => tycho-qt}/data/hc/lines.png (100%) rename source/{tycho => tycho-qt}/data/hc/map.png (100%) rename source/{tycho => tycho-qt}/data/hc/points.png (100%) rename source/{tycho => tycho-qt}/data/hc/polygons.png (100%) rename source/{tycho => tycho-qt}/data/misc/tycho1.png (100%) rename source/{tycho => tycho-qt}/data/misc/tycho2.png (100%) rename source/{tycho => tycho-qt}/data/sources/icons.psd (100%) rename source/{tycho => tycho-qt}/data/sources/tycho1.psd (100%) rename source/{tycho => tycho-qt}/data/sources/tycho2.psd (100%) delete mode 100644 source/tycho-qt/mapprops.cc delete mode 100644 source/tycho-qt/mapprops.h create mode 100644 source/tycho-qt/resources.qrc create mode 100644 source/tycho-qt/tycho.h create mode 100644 source/tycho-qt/viewmap.ui create mode 100644 source/tycho-qt/winabout.ui create mode 100644 source/tycho-qt/winmapprops.cc create mode 100644 source/tycho-qt/winmapprops.h rename source/tycho-qt/{mapprops.ui => winmapprops.ui} (95%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fab9cf2..1b4d3cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.14) project(maraiah-tycho CXX) set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -18,14 +19,18 @@ find_package(Qt5Widgets CONFIG REQUIRED) add_executable( maraiah-tycho WIN32 - source/tycho-qt/mapprops.ui + source/tycho-qt/resources.qrc + + source/tycho-qt/viewmap.ui + source/tycho-qt/winabout.ui + source/tycho-qt/winmapprops.ui source/tycho-qt/winmenu.ui - source/tycho-qt/common.h - source/tycho-qt/mapprops.h + source/tycho-qt/tycho.h + source/tycho-qt/winmapprops.h source/tycho-qt/winmenu.h - source/tycho-qt/mapprops.cc + source/tycho-qt/winmapprops.cc source/tycho-qt/winmenu.cc source/tycho-qt/main.cc ) diff --git a/source/tycho-qt/common.h b/source/tycho-qt/common.h deleted file mode 100644 index 92d49c3..0000000 --- a/source/tycho-qt/common.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include - -#ifndef NDEBUG -# define DbgPrintFunc() std::puts(__func__) -#else -# define DbgPrintFunc() -#endif - -typedef float f32; -typedef double f64; - -typedef std::int8_t i8; -typedef std::int16_t i16; -typedef std::int32_t i32; -typedef std::int64_t i64; - -typedef std::uint8_t u8; -typedef std::uint16_t u16; -typedef std::uint32_t u32; -typedef std::uint64_t u64; - -typedef std::ptrdiff_t isize; -typedef std::size_t usize; - -// EOF diff --git a/source/tycho/data/color/lines.png b/source/tycho-qt/data/color/lines.png similarity index 100% rename from source/tycho/data/color/lines.png rename to source/tycho-qt/data/color/lines.png diff --git a/source/tycho/data/color/map.png b/source/tycho-qt/data/color/map.png similarity index 100% rename from source/tycho/data/color/map.png rename to source/tycho-qt/data/color/map.png diff --git a/source/tycho/data/color/points.png b/source/tycho-qt/data/color/points.png similarity index 100% rename from source/tycho/data/color/points.png rename to source/tycho-qt/data/color/points.png diff --git a/source/tycho/data/color/polygons.png b/source/tycho-qt/data/color/polygons.png similarity index 100% rename from source/tycho/data/color/polygons.png rename to source/tycho-qt/data/color/polygons.png diff --git a/source/tycho/data/hc/lines.png b/source/tycho-qt/data/hc/lines.png similarity index 100% rename from source/tycho/data/hc/lines.png rename to source/tycho-qt/data/hc/lines.png diff --git a/source/tycho/data/hc/map.png b/source/tycho-qt/data/hc/map.png similarity index 100% rename from source/tycho/data/hc/map.png rename to source/tycho-qt/data/hc/map.png diff --git a/source/tycho/data/hc/points.png b/source/tycho-qt/data/hc/points.png similarity index 100% rename from source/tycho/data/hc/points.png rename to source/tycho-qt/data/hc/points.png diff --git a/source/tycho/data/hc/polygons.png b/source/tycho-qt/data/hc/polygons.png similarity index 100% rename from source/tycho/data/hc/polygons.png rename to source/tycho-qt/data/hc/polygons.png diff --git a/source/tycho/data/misc/tycho1.png b/source/tycho-qt/data/misc/tycho1.png similarity index 100% rename from source/tycho/data/misc/tycho1.png rename to source/tycho-qt/data/misc/tycho1.png diff --git a/source/tycho/data/misc/tycho2.png b/source/tycho-qt/data/misc/tycho2.png similarity index 100% rename from source/tycho/data/misc/tycho2.png rename to source/tycho-qt/data/misc/tycho2.png diff --git a/source/tycho/data/sources/icons.psd b/source/tycho-qt/data/sources/icons.psd similarity index 100% rename from source/tycho/data/sources/icons.psd rename to source/tycho-qt/data/sources/icons.psd diff --git a/source/tycho/data/sources/tycho1.psd b/source/tycho-qt/data/sources/tycho1.psd similarity index 100% rename from source/tycho/data/sources/tycho1.psd rename to source/tycho-qt/data/sources/tycho1.psd diff --git a/source/tycho/data/sources/tycho2.psd b/source/tycho-qt/data/sources/tycho2.psd similarity index 100% rename from source/tycho/data/sources/tycho2.psd rename to source/tycho-qt/data/sources/tycho2.psd diff --git a/source/tycho-qt/main.cc b/source/tycho-qt/main.cc index efa7e1f..84b7d41 100644 --- a/source/tycho-qt/main.cc +++ b/source/tycho-qt/main.cc @@ -2,13 +2,8 @@ #include #include -extern "C" void test_fn(); - int main(int argc, char *argv[]) { - puts("hello, world"); - test_fn(); - QApplication a(argc, argv); WinMenu w; w.show(); diff --git a/source/tycho-qt/mapprops.cc b/source/tycho-qt/mapprops.cc deleted file mode 100644 index e08cd2b..0000000 --- a/source/tycho-qt/mapprops.cc +++ /dev/null @@ -1,17 +0,0 @@ -#include "common.h" -#include "mapprops.h" -#include "ui_mapprops.h" - -MapProps::MapProps(QWidget *parent) : - QDialog(parent, Qt::Window), - ui(new Ui::MapProps) -{ - ui->setupUi(this); -} - -MapProps::~MapProps() -{ - DbgPrintFunc(); -} - -// EOF diff --git a/source/tycho-qt/mapprops.h b/source/tycho-qt/mapprops.h deleted file mode 100644 index 1d36eb0..0000000 --- a/source/tycho-qt/mapprops.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include -#include - -namespace Ui -{ - class MapProps; -} - -class MapProps : public QDialog -{ - Q_OBJECT - -public: - explicit MapProps(QWidget *parent = nullptr); - ~MapProps(); - -private: - std::unique_ptr ui; -}; - -// EOF diff --git a/source/tycho-qt/resources.qrc b/source/tycho-qt/resources.qrc new file mode 100644 index 0000000..9a584a3 --- /dev/null +++ b/source/tycho-qt/resources.qrc @@ -0,0 +1,14 @@ + + + data/color/lines.png + data/color/map.png + data/color/points.png + data/color/polygons.png + data/hc/lines.png + data/hc/map.png + data/hc/points.png + data/hc/polygons.png + data/misc/tycho1.png + data/misc/tycho2.png + + diff --git a/source/tycho-qt/tycho.h b/source/tycho-qt/tycho.h new file mode 100644 index 0000000..ee2747a --- /dev/null +++ b/source/tycho-qt/tycho.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include +#include + +#define dbgPrintFunc() qDebug("%s", __func__) + +// EOF diff --git a/source/tycho-qt/viewmap.ui b/source/tycho-qt/viewmap.ui new file mode 100644 index 0000000..e54a3f3 --- /dev/null +++ b/source/tycho-qt/viewmap.ui @@ -0,0 +1,24 @@ + + + ViewMap + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + + diff --git a/source/tycho-qt/winabout.ui b/source/tycho-qt/winabout.ui new file mode 100644 index 0000000..9ef1715 --- /dev/null +++ b/source/tycho-qt/winabout.ui @@ -0,0 +1,94 @@ + + + WinAbout + + + + 0 + 0 + 669 + 281 + + + + About Tycho + + + + + + <img src="qrc:///data/misc/tycho2.png"/> + + + + + + + + + <h1>Tycho</h1> + + + + + + + VERSION NUMBER + + + + + + + Tycho is a map editor for Marathon 2 and Marathon Infinity. + + + + + + + Marathon is Copyright © Bungie Software. +Tycho is public domain software under the CC0 license. + + + + + + + AUTHORS + + + + + + + QDialogButtonBox::Close + + + + + + + + + + + + + buttonBox + rejected() + WinAbout + close() + + + 479 + 256 + + + 334 + 140 + + + + + diff --git a/source/tycho-qt/winmapprops.cc b/source/tycho-qt/winmapprops.cc new file mode 100644 index 0000000..e2a9252 --- /dev/null +++ b/source/tycho-qt/winmapprops.cc @@ -0,0 +1,17 @@ +#include "tycho.h" +#include "winmapprops.h" +#include "ui_winmapprops.h" + +WinMapProps::WinMapProps(QWidget *parent) : + QDialog(parent, Qt::Window), + ui(new Ui::WinMapProps) +{ + ui->setupUi(this); +} + +WinMapProps::~WinMapProps() +{ + dbgPrintFunc(); +} + +// EOF diff --git a/source/tycho-qt/winmapprops.h b/source/tycho-qt/winmapprops.h new file mode 100644 index 0000000..7753621 --- /dev/null +++ b/source/tycho-qt/winmapprops.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include + +namespace Ui +{ + class WinMapProps; +} + +class WinMapProps : public QDialog +{ + Q_OBJECT + +public: + explicit WinMapProps(QWidget *parent = nullptr); + ~WinMapProps(); + +private: + std::unique_ptr ui; +}; + +// EOF diff --git a/source/tycho-qt/mapprops.ui b/source/tycho-qt/winmapprops.ui similarity index 95% rename from source/tycho-qt/mapprops.ui rename to source/tycho-qt/winmapprops.ui index dcc98e3..11830e7 100644 --- a/source/tycho-qt/mapprops.ui +++ b/source/tycho-qt/winmapprops.ui @@ -1,7 +1,7 @@ - MapProps - + WinMapProps + Qt::WindowModal @@ -349,7 +349,7 @@ buttonBox accepted() - MapProps + WinMapProps accept() @@ -365,7 +365,7 @@ buttonBox rejected() - MapProps + WinMapProps reject() @@ -378,5 +378,21 @@ + + checkBox_24 + toggled(bool) + spinBox + setEnabled(bool) + + + 364 + 487 + + + 270 + 175 + + + diff --git a/source/tycho-qt/winmenu.cc b/source/tycho-qt/winmenu.cc index be1f35d..1b7e5f9 100644 --- a/source/tycho-qt/winmenu.cc +++ b/source/tycho-qt/winmenu.cc @@ -1,23 +1,51 @@ -#include "common.h" +#include "tycho.h" #include "winmenu.h" #include "ui_winmenu.h" +#include "ui_winabout.h" -#include +#include +#include + +extern "C" void test_fn(char const *fname); WinMenu::WinMenu(QWidget *parent) : QMainWindow(parent), ui(new Ui::WinMenu), - props(new MapProps(this)) + props(new WinMapProps(this)) { ui->setupUi(this); - - connect(ui->actionMapProps, &QAction::triggered, - this, &WinMenu::openMapProperties); } WinMenu::~WinMenu() { - DbgPrintFunc(); + dbgPrintFunc(); +} + +void WinMenu::mapNew() +{ + // TODO +} + +void WinMenu::mapOpen() +{ + auto fname = + QFileDialog::getOpenFileName( + this, + tr("Open Map File"), + QString(), + tr("Marathon Map files (*.scen *.sceA Map)")); + + test_fn(qUtf8Printable(fname)); +} + +void WinMenu::openAbout() +{ + QDialog dlg{this}; + Ui::WinAbout about{}; + + about.setupUi(&dlg); + + dlg.exec(); } void WinMenu::openMapProperties() diff --git a/source/tycho-qt/winmenu.h b/source/tycho-qt/winmenu.h index b638118..ba8f26f 100644 --- a/source/tycho-qt/winmenu.h +++ b/source/tycho-qt/winmenu.h @@ -1,6 +1,6 @@ #pragma once -#include "mapprops.h" +#include "winmapprops.h" #include #include @@ -19,11 +19,14 @@ public: ~WinMenu(); public slots: + void mapNew(); + void mapOpen(); + void openAbout(); void openMapProperties(); private: std::unique_ptr ui; - MapProps *props; + WinMapProps *props; }; // EOF diff --git a/source/tycho-qt/winmenu.ui b/source/tycho-qt/winmenu.ui index 4f71c0c..231551e 100644 --- a/source/tycho-qt/winmenu.ui +++ b/source/tycho-qt/winmenu.ui @@ -19,7 +19,28 @@ Tycho - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + @@ -35,6 +56,8 @@ + + @@ -42,8 +65,15 @@ + + + Help + + + + @@ -67,8 +97,111 @@ Map Properties + + + Quit + + + Ctrl+Q + + + + + About Tycho + + + F1 + + - + + + actionMapProps + triggered() + WinMenu + openMapProperties() + + + -1 + -1 + + + 399 + 299 + + + + + actionQuit + triggered() + WinMenu + close() + + + -1 + -1 + + + 399 + 299 + + + + + actionOpen + triggered() + WinMenu + mapOpen() + + + -1 + -1 + + + 399 + 299 + + + + + actionNew + triggered() + WinMenu + mapNew() + + + -1 + -1 + + + 399 + 299 + + + + + actionAbout + triggered() + WinMenu + openAbout() + + + -1 + -1 + + + 399 + 299 + + + + + + openMapProperties() + mapNew() + mapOpen() + openAbout() + diff --git a/source/tycho/lib.rs b/source/tycho/lib.rs index 5d62dca..359ad34 100644 --- a/source/tycho/lib.rs +++ b/source/tycho/lib.rs @@ -1,7 +1,16 @@ +use maraiah::durandal::ffi; + #[no_mangle] -pub extern "C" fn test_fn() +pub extern "C" fn test_fn(fname: *const ffi::c_char) { - println!("hello, world! from rust"); + let fname = unsafe {ffi::CStr::from_ptr(fname)}; + println!("hello, world! from rust: {}", fname.to_str().unwrap()); } +/* +struct Project +{ +} +*/ + // EOF