tycho: various UI changes

gui-branch-qt
an 2019-05-30 03:09:58 -04:00
parent 11f90cb112
commit 17856bbe7e
29 changed files with 396 additions and 95 deletions

View File

@ -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
)

View File

@ -1,29 +0,0 @@
#pragma once
#include <cstdint>
#include <cstddef>
#include <cstdio>
#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

View File

Before

Width:  |  Height:  |  Size: 805 B

After

Width:  |  Height:  |  Size: 805 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 761 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 343 B

View File

Before

Width:  |  Height:  |  Size: 972 B

After

Width:  |  Height:  |  Size: 972 B

View File

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 306 B

View File

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 673 B

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -2,13 +2,8 @@
#include <QApplication>
#include <cstdio>
extern "C" void test_fn();
int main(int argc, char *argv[])
{
puts("hello, world");
test_fn();
QApplication a(argc, argv);
WinMenu w;
w.show();

View File

@ -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

View File

@ -1,23 +0,0 @@
#pragma once
#include <QDialog>
#include <memory>
namespace Ui
{
class MapProps;
}
class MapProps : public QDialog
{
Q_OBJECT
public:
explicit MapProps(QWidget *parent = nullptr);
~MapProps();
private:
std::unique_ptr<Ui::MapProps> ui;
};
// EOF

View File

@ -0,0 +1,14 @@
<RCC>
<qresource>
<file>data/color/lines.png</file>
<file>data/color/map.png</file>
<file>data/color/points.png</file>
<file>data/color/polygons.png</file>
<file>data/hc/lines.png</file>
<file>data/hc/map.png</file>
<file>data/hc/points.png</file>
<file>data/hc/polygons.png</file>
<file>data/misc/tycho1.png</file>
<file>data/misc/tycho2.png</file>
</qresource>
</RCC>

9
source/tycho-qt/tycho.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#include <QtGlobal>
#include <cstdint>
#include <cstddef>
#define dbgPrintFunc() qDebug("%s", __func__)
// EOF

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ViewMap</class>
<widget class="QWidget" name="ViewMap">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WinAbout</class>
<widget class="QDialog" name="WinAbout">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>669</width>
<height>281</height>
</rect>
</property>
<property name="windowTitle">
<string>About Tycho</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;img src=&quot;qrc:///data/misc/tycho2.png&quot;/&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;h1&gt;Tycho&lt;/h1&gt;</string>
</property>
</widget>
</item>
<item>
<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>
</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>WinAbout</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>479</x>
<y>256</y>
</hint>
<hint type="destinationlabel">
<x>334</x>
<y>140</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -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

View File

@ -0,0 +1,23 @@
#pragma once
#include <QDialog>
#include <memory>
namespace Ui
{
class WinMapProps;
}
class WinMapProps : public QDialog
{
Q_OBJECT
public:
explicit WinMapProps(QWidget *parent = nullptr);
~WinMapProps();
private:
std::unique_ptr<Ui::WinMapProps> ui;
};
// EOF

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapProps</class>
<widget class="QDialog" name="MapProps">
<class>WinMapProps</class>
<widget class="QDialog" name="WinMapProps">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
@ -349,7 +349,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>MapProps</receiver>
<receiver>WinMapProps</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@ -365,7 +365,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>MapProps</receiver>
<receiver>WinMapProps</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
@ -378,5 +378,21 @@
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_24</sender>
<signal>toggled(bool)</signal>
<receiver>spinBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>364</x>
<y>487</y>
</hint>
<hint type="destinationlabel">
<x>270</x>
<y>175</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,23 +1,51 @@
#include "common.h"
#include "tycho.h"
#include "winmenu.h"
#include "ui_winmenu.h"
#include "ui_winabout.h"
#include <stdio.h>
#include <QFileDialog>
#include <iostream>
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()

View File

@ -1,6 +1,6 @@
#pragma once
#include "mapprops.h"
#include "winmapprops.h"
#include <QMainWindow>
#include <memory>
@ -19,11 +19,14 @@ public:
~WinMenu();
public slots:
void mapNew();
void mapOpen();
void openAbout();
void openMapProperties();
private:
std::unique_ptr<Ui::WinMenu> ui;
MapProps *props;
WinMapProps *props;
};
// EOF

View File

@ -19,7 +19,28 @@
<property name="windowTitle">
<string>Tycho</string>
</property>
<widget class="QWidget" name="widget_3"/>
<widget class="QWidget" name="widget">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QMdiArea" name="mdiArea"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
@ -35,6 +56,8 @@
</property>
<addaction name="actionNew"/>
<addaction name="actionOpen"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
@ -42,8 +65,15 @@
</property>
<addaction name="actionMapProps"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionOpen">
@ -67,8 +97,111 @@
<string>Map Properties</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About Tycho</string>
</property>
<property name="shortcut">
<string>F1</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
<connections>
<connection>
<sender>actionMapProps</sender>
<signal>triggered()</signal>
<receiver>WinMenu</receiver>
<slot>openMapProperties()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionQuit</sender>
<signal>triggered()</signal>
<receiver>WinMenu</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionOpen</sender>
<signal>triggered()</signal>
<receiver>WinMenu</receiver>
<slot>mapOpen()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionNew</sender>
<signal>triggered()</signal>
<receiver>WinMenu</receiver>
<slot>mapNew()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionAbout</sender>
<signal>triggered()</signal>
<receiver>WinMenu</receiver>
<slot>openAbout()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>openMapProperties()</slot>
<slot>mapNew()</slot>
<slot>mapOpen()</slot>
<slot>openAbout()</slot>
</slots>
</ui>

View File

@ -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