Start on Nostalgia Studio
This commit is contained in:
parent
6b1ccc7ed2
commit
60b4a32995
@ -18,10 +18,6 @@ add_definitions(
|
||||
-nostdlib
|
||||
-fno-exceptions
|
||||
-fno-rtti
|
||||
#-g
|
||||
#-fcolor-diagnostics
|
||||
#--analyze
|
||||
#-Os # GCC size optimization flag
|
||||
)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
|
@ -1,8 +1,10 @@
|
||||
FROM wombatant/devenv
|
||||
FROM wombatant/devenv:latest
|
||||
|
||||
ENV DEVKITPRO /opt/devkitPro
|
||||
ENV DEVKITARM ${DEVKITPRO}/devkitARM
|
||||
|
||||
RUN dnf install -y qt5-devel
|
||||
|
||||
###############################################################################
|
||||
# Install Ox
|
||||
|
||||
|
@ -7,7 +7,7 @@ if len(sys.argv) < 3:
|
||||
|
||||
pkg = sys.argv[1]
|
||||
name = sys.argv[2]
|
||||
namespace = "namespace wombat {\nnamespace %s {\n\n}\n}" % pkg
|
||||
namespace = "namespace nostalgia {\nnamespace %s {\n\n}\n}" % pkg
|
||||
hpp = "#pragma once\n"
|
||||
cpp = "#include \"%s.hpp\"\n\n%s" % (name, namespace)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
#setup libraries
|
||||
|
||||
@ -20,4 +20,5 @@ add_subdirectory(player)
|
||||
|
||||
if(NOT WOMBAT_BUILD_TYPE STREQUAL "GBA")
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(studio)
|
||||
endif()
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
add_library(
|
||||
NostalgiaCommon
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
if(WOMBAT_BUILD_TYPE STREQUAL "GBA")
|
||||
enable_language(C ASM)
|
||||
@ -8,6 +8,9 @@ if(WOMBAT_BUILD_TYPE STREQUAL "GBA")
|
||||
gba/media.cpp
|
||||
)
|
||||
elseif(WOMBAT_BUILD_TYPE STREQUAL "Native")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
set(
|
||||
CPP
|
||||
qt/gfx.cpp
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(nostalgia)
|
||||
|
||||
|
@ -13,7 +13,7 @@ using namespace nostalgia;
|
||||
int main() {
|
||||
core::init();
|
||||
core::initConsole();
|
||||
core::puts(9 * 32 + 8, "HELLO, WORLD!");
|
||||
core::puts(9 * 32 + 8, "HELLO,WORLD!");
|
||||
core::puts(10 * 32 + 8, "01234 56789");
|
||||
while (1);
|
||||
return 0;
|
||||
|
33
src/studio/CMakeLists.txt
Normal file
33
src/studio/CMakeLists.txt
Normal file
@ -0,0 +1,33 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(nostalgia-studio)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(
|
||||
nostalgia-studio
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
nostalgia-studio
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
${OxClArgs_LIBRARY}
|
||||
${OxFS_LIBRARY}
|
||||
${OxStd_LIBRARY}
|
||||
NostalgiaCommon
|
||||
NostalgiaCore
|
||||
NostalgiaStudioJson
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
nostalgia-studio
|
||||
RUNTIME DESTINATION
|
||||
bin
|
||||
)
|
||||
|
||||
add_subdirectory(json)
|
40
src/studio/json/CMakeLists.txt
Normal file
40
src/studio/json/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(NostalgiaStudioJson)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_library(
|
||||
NostalgiaStudioJson
|
||||
json_read.cpp
|
||||
json_write.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudioJson
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
json.hpp
|
||||
json_read.hpp
|
||||
json_write.hpp
|
||||
DESTINATION
|
||||
include/nostalgia/studio/json
|
||||
)
|
||||
|
||||
|
||||
add_executable(
|
||||
NostalgiaStudioJsonTest
|
||||
test.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudioJsonTest
|
||||
NostalgiaStudioJson
|
||||
)
|
||||
|
||||
add_test("Test\\ NostalgiaStudioJson" NostalgiaStudioJsonTest)
|
31
src/studio/json/json.hpp
Normal file
31
src/studio/json/json.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "json_read.hpp"
|
||||
#include "json_write.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
class JsonOperator {
|
||||
|
||||
public:
|
||||
virtual int op(QString fieldName, int *dest) = 0;
|
||||
|
||||
virtual int op(QString fieldName, bool *dest) = 0;
|
||||
|
||||
virtual int op(QString fieldName, double *dest) = 0;
|
||||
|
||||
virtual int op(QString fieldName, QString *dest) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
18
src/studio/json/json_operator.hpp
Normal file
18
src/studio/json/json_operator.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <ox/std/types.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
}
|
||||
}
|
89
src/studio/json/json_read.cpp
Normal file
89
src/studio/json/json_read.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "json_read.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
JsonReader::JsonReader(QJsonObject &obj): m_src(obj) {
|
||||
}
|
||||
|
||||
ox::Error JsonReader::op(QString fieldName, int *dest) {
|
||||
if (m_src.contains(fieldName)) {
|
||||
return op(m_src[fieldName], dest);
|
||||
} else {
|
||||
return JSON_ERR_FIELD_MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error JsonReader::op(QString fieldName, bool *dest) {
|
||||
if (m_src.contains(fieldName)) {
|
||||
return op(m_src[fieldName], dest);
|
||||
} else {
|
||||
return JSON_ERR_FIELD_MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error JsonReader::op(QString fieldName, double *dest) {
|
||||
if (m_src.contains(fieldName)) {
|
||||
return op(m_src[fieldName], dest);
|
||||
} else {
|
||||
return JSON_ERR_FIELD_MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error JsonReader::op(QString fieldName, QString *dest) {
|
||||
if (m_src.contains(fieldName)) {
|
||||
return op(m_src[fieldName], dest);
|
||||
} else {
|
||||
return JSON_ERR_FIELD_MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ox::Error JsonReader::op(QJsonValueRef src, int *dest) {
|
||||
if (src.isDouble()) {
|
||||
*dest = src.toInt();
|
||||
return 0;
|
||||
} else {
|
||||
return JSON_ERR_UNEXPECTED_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error JsonReader::op(QJsonValueRef src, bool *dest) {
|
||||
if (src.isBool()) {
|
||||
*dest = src.toBool();
|
||||
return 0;
|
||||
} else {
|
||||
return JSON_ERR_UNEXPECTED_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error JsonReader::op(QJsonValueRef src, double *dest) {
|
||||
if (src.isDouble()) {
|
||||
*dest = src.toDouble();
|
||||
return 0;
|
||||
} else {
|
||||
return JSON_ERR_UNEXPECTED_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error JsonReader::op(QJsonValueRef src, QString *dest) {
|
||||
if (src.isString()) {
|
||||
*dest = src.toString();
|
||||
return 0;
|
||||
} else {
|
||||
return JSON_ERR_UNEXPECTED_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
83
src/studio/json/json_read.hpp
Normal file
83
src/studio/json/json_read.hpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include "json_operator.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
enum {
|
||||
JSON_ERR_FIELD_MISSING,
|
||||
JSON_ERR_UNEXPECTED_TYPE,
|
||||
};
|
||||
|
||||
class JsonReader {
|
||||
|
||||
private:
|
||||
QJsonObject &m_src;
|
||||
|
||||
public:
|
||||
JsonReader(QJsonObject &obj);
|
||||
|
||||
ox::Error op(QString fieldName, int *dest);
|
||||
|
||||
ox::Error op(QString fieldName, bool *dest);
|
||||
|
||||
ox::Error op(QString fieldName, double *dest);
|
||||
|
||||
ox::Error op(QString fieldName, QString *dest);
|
||||
|
||||
template<typename T>
|
||||
ox::Error op(QString fieldName, T *dest);
|
||||
|
||||
template<typename T>
|
||||
ox::Error op(QString fieldName, QVector<T> *dest);
|
||||
|
||||
private:
|
||||
ox::Error op(QJsonValueRef src, int *dest);
|
||||
|
||||
ox::Error op(QJsonValueRef src, bool *dest);
|
||||
|
||||
ox::Error op(QJsonValueRef src, double *dest);
|
||||
|
||||
ox::Error op(QJsonValueRef src, QString *dest);
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
ox::Error JsonReader::op(QString fieldName, T *dest) {
|
||||
auto obj = m_src[fieldName].toObject();
|
||||
auto reader = JsonReader(obj);
|
||||
return ioOp(&reader, dest);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
ox::Error JsonReader::op(QString fieldName, QVector<T> *dest) {
|
||||
ox::Error err = 0;
|
||||
auto a = m_src[fieldName].toArray();
|
||||
dest->resize(a.size());
|
||||
for (int i = 0; i < dest->size(); i++) {
|
||||
err |= op(a[i], &dest->at(i));
|
||||
}
|
||||
return err;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int read(QString json, T *dest) {
|
||||
auto obj = QJsonDocument::fromJson(json.toUtf8()).object();
|
||||
JsonReader rdr(obj);
|
||||
return ioOp(&rdr, dest);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
16
src/studio/json/json_write.cpp
Normal file
16
src/studio/json/json_write.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "json_write.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
|
||||
}
|
||||
}
|
16
src/studio/json/json_write.hpp
Normal file
16
src/studio/json/json_write.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
|
||||
}
|
||||
}
|
86
src/studio/json/test.cpp
Normal file
86
src/studio/json/test.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ox;
|
||||
using namespace nostalgia::studio;
|
||||
|
||||
struct TestStructNest {
|
||||
bool Bool;
|
||||
int Int;
|
||||
double Double;
|
||||
QString String;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int ioOp(T *io, TestStructNest *obj) {
|
||||
Error err = 0;
|
||||
err |= io->op("Bool", &obj->Bool);
|
||||
err |= io->op("Int", &obj->Int);
|
||||
err |= io->op("Double", &obj->Double);
|
||||
err |= io->op("String", &obj->String);
|
||||
return err;
|
||||
}
|
||||
|
||||
struct TestStruct {
|
||||
bool Bool;
|
||||
int Int;
|
||||
double Double;
|
||||
QString String;
|
||||
TestStructNest Struct;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int ioOp(T *io, TestStruct *obj) {
|
||||
Error err = 0;
|
||||
err |= io->op("Bool", &obj->Bool);
|
||||
err |= io->op("Int", &obj->Int);
|
||||
err |= io->op("Double", &obj->Double);
|
||||
err |= io->op("String", &obj->String);
|
||||
err |= io->op("Struct", &obj->Struct);
|
||||
return err;
|
||||
}
|
||||
|
||||
int main(int argc, char **args) {
|
||||
int err = 0;
|
||||
auto json =
|
||||
"{"
|
||||
" \"Bool\": true,"
|
||||
" \"Int\": 42,"
|
||||
" \"Double\": 42.42,"
|
||||
" \"String\": \"Test String\","
|
||||
" \"Struct\": {"
|
||||
" \"Bool\": true,"
|
||||
" \"Int\": 42,"
|
||||
" \"Double\": 42.42,"
|
||||
" \"String\": \"Test String\""
|
||||
" }"
|
||||
"}";
|
||||
TestStruct ts;
|
||||
read(json, &ts);
|
||||
|
||||
cout << ts.Bool << endl;
|
||||
cout << ts.Int << endl;
|
||||
cout << ts.Double << endl;
|
||||
cout << ts.String.toStdString() << endl;
|
||||
|
||||
err |= !(ts.Bool) << 0;
|
||||
err |= !(ts.Int == 42) << 1;
|
||||
err |= !(ts.Double == 42.42) << 2;
|
||||
err |= !(ts.String == "Test String") << 3;
|
||||
|
||||
err |= !(ts.Struct.Bool) << 4;
|
||||
err |= !(ts.Struct.Int == 42) << 5;
|
||||
err |= !(ts.Struct.Double == 42.42) << 6;
|
||||
err |= !(ts.Struct.String == "Test String") << 7;
|
||||
|
||||
return err;
|
||||
}
|
21
src/studio/main.cpp
Normal file
21
src/studio/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include "studio/mainwindow.hpp"
|
||||
|
||||
using namespace nostalgia::studio;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
32
src/studio/mainwindow.cpp
Normal file
32
src/studio/mainwindow.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include "studio/mainwindow.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) {
|
||||
auto screenSize = QApplication::desktop()->screenGeometry();
|
||||
|
||||
// set window to 70% of screen width, and center it
|
||||
auto sizePct = 0.7;
|
||||
resize(screenSize.width() * sizePct, screenSize.height() * sizePct);
|
||||
move(-x(), -y());
|
||||
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
|
||||
|
||||
setWindowTitle("Nostalgia Studio");
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
42
src/studio/mainwindow.hpp
Normal file
42
src/studio/mainwindow.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QMainWindow>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
class MainWindow: public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString EditorSettings;
|
||||
static const QString AppTitle;
|
||||
|
||||
private:
|
||||
QString m_projectPath;
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
virtual ~MainWindow();
|
||||
|
||||
void openProject(QString);
|
||||
|
||||
private:
|
||||
void setupDockWidgets();
|
||||
int readSettings(QString path);
|
||||
int writeSettings(QString path);
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(nost-pack)
|
||||
|
||||
@ -23,7 +23,3 @@ install(
|
||||
RUNTIME DESTINATION
|
||||
bin
|
||||
)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
|
||||
set(CMAKE_AUTOMOC OFF)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user