Compare commits

...

13 Commits

Author SHA1 Message Date
7f56a77e7d [nostalgia/studio] Add version to Nostalgia Studio
All checks were successful
Build / build (push) Successful in 2m17s
2023-12-31 23:20:40 -06:00
055d64b125 [olympic] Add support for an AppLib app specific version
All checks were successful
Build / build (push) Successful in 2m20s
2023-12-31 23:18:17 -06:00
de9f842640 [ox/std] Add error.hpp include to memory.hpp
All checks were successful
Build / build (push) Successful in 2m15s
2023-12-31 22:52:10 -06:00
200e586768 Add .idea to .gitignore 2023-12-31 22:52:10 -06:00
f1609519a7 [olympic] Cleanup 2023-12-31 22:52:10 -06:00
e452d9db4f [nostalgia] Add python3-mypy to Debian deps 2023-12-31 22:52:10 -06:00
43a87b606e [nostalgia] Ensure pkg-gba reads .current_build without a new line
All checks were successful
Build / build (push) Successful in 2m20s
2023-12-30 13:59:10 -06:00
8acc6244d5 [olympic/keel] Improve error clarity on pack some common failures 2023-12-30 13:58:42 -06:00
bd2aeee276 [ox/claw] Improve error clarity when loading ModelObjects 2023-12-30 13:57:51 -06:00
89fab5cc20 [ox/fs] Remove stdc++fs from library list on Linux
All checks were successful
Build / build (push) Successful in 2m10s
2023-12-30 01:05:46 -06:00
1c06ea677f [nostalgia] Add links to Tonc and GBATEK to developer-handbook
All checks were successful
Build / build (push) Successful in 2m7s
2023-12-29 19:05:10 -06:00
6b948ee069 Merge commit '932c3e57e93d63dc98c454015afea941416ff423'
All checks were successful
Build / build (push) Successful in 2m8s
2023-12-29 18:44:06 -06:00
72dddcaee5 [ox] Fix TypeDescWriter segfault 2023-12-29 18:42:59 -06:00
18 changed files with 76 additions and 28 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
.clangd
.current_build
.conanbuild
.idea
.mypy_cache
.stfolder
.stignore

View File

@ -15,6 +15,7 @@ probably differ), install the following additional packages:
* pkg-config
* xorg-dev
* libgtk-3-dev
* python3-mypy
## Build

View File

@ -74,7 +74,10 @@ Result<Buffer> stripClawHeader(const ox::Buffer &buff) noexcept {
Result<ModelObject> readClaw(TypeStore &ts, const char *buff, std::size_t buffSz) noexcept {
oxRequire(header, readClawHeader(buff, buffSz));
oxRequire(t, ts.getLoad(header.typeName, header.typeVersion, header.typeParams));
auto const [t, tdErr] = ts.getLoad(header.typeName, header.typeVersion, header.typeParams);
if (tdErr) {
return OxError(3, "Could not load type descriptor");
}
ModelObject obj;
oxReturnError(obj.setType(t));
switch (header.fmt) {

View File

@ -16,12 +16,6 @@ if(NOT MSVC)
endif()
if(NOT OX_BARE_METAL)
if(NOT APPLE AND NOT MSVC AND NOT ${OX_OS_FREEBSD})
target_link_libraries(
OxFS PUBLIC
stdc++fs
)
endif()
set_property(
TARGET
OxFS

View File

@ -219,9 +219,11 @@ template<typename T>
constexpr Error TypeDescWriter::field(CRStringView name, const T *val) noexcept {
if (m_type) {
if constexpr(isVector_v<T> || isArray_v<T>) {
return field(name, val->data(), 0, detail::buildSubscriptStack(val));
typename T::value_type *data = nullptr;
return field(name, data, 0, detail::buildSubscriptStack(val));
} else if constexpr(isSmartPtr_v<T>) {
return field(name, val->get(), 0, detail::buildSubscriptStack(val));
typename T::value_type *data = nullptr;
return field(name, data, 0, detail::buildSubscriptStack(val));
} else if constexpr(is_pointer_v<T>) {
return field(name, val, 0, detail::buildSubscriptStack(val));
} else {

View File

@ -39,6 +39,7 @@ constexpr T *construct_at(T *p, Args &&...args ) {
#endif
#include "error.hpp"
#include "utility.hpp"
@ -74,6 +75,7 @@ class SharedPtr {
int *m_refCnt = nullptr;
public:
using value_type = T;
explicit constexpr SharedPtr(T *t = nullptr) noexcept: m_t(t), m_refCnt(new int) {
}
@ -183,6 +185,7 @@ class UniquePtr {
T *m_t = nullptr;
public:
using value_type = T;
explicit constexpr UniquePtr(T *t = nullptr) noexcept: m_t(t) {
}
@ -288,4 +291,14 @@ constexpr auto make_unique(Args&&... args) {
return UniquePtr<U>(new T(ox::forward<Args>(args)...));
}
template<typename T, typename U = T, typename ...Args>
[[nodiscard]]
constexpr Result<UniquePtr<U>> make_unique_catch(Args&&... args) noexcept {
try {
return UniquePtr<U>(new T(ox::forward<Args>(args)...));
} catch (ox::Exception const&ex) {
return ex.toError();
}
}
}

View File

@ -63,6 +63,13 @@ All components have a platform indicator next to them:
### GBA
The GBA has two major resources for learning about its hardware:
* [Tonc](https://www.coranac.com/tonc/text/toc.htm) - This is basically a short
book on the GBA and low level development.
* [GBATEK](https://rust-console.github.io/gbatek-gbaonly/) - This is a more
concise resource that mostly tells about memory ranges and registers.
#### Graphics
* Background Palette: 256 colors

View File

@ -18,8 +18,10 @@ arch = platform.machine()
host_env = f'{os}-{arch}'
# get current build type
with open(".current_build","r") as f:
with open(".current_build", "r") as f:
current_build = f.readlines()[0]
if current_build[len(current_build) - 1] == '\n':
current_build = current_build[:len(current_build) - 1]
project_dir = sys.argv[1]
project_name = sys.argv[2]

View File

@ -9,6 +9,11 @@ target_link_libraries(
OlympicApplib
)
target_compile_definitions(
NostalgiaStudio PUBLIC
OLYMPIC_APP_VERSION="2023.12.0"
)
install(
TARGETS
NostalgiaStudio

View File

@ -13,6 +13,10 @@
#define OLYMPIC_APP_NAME "App"
#endif
#ifndef OLYMPIC_APP_VERSION
#define OLYMPIC_APP_VERSION "dev build"
#endif
#ifndef OLYMPIC_PROJECT_NAMESPACE
#define OLYMPIC_PROJECT_NAMESPACE project
#endif
@ -31,6 +35,8 @@
namespace olympic {
ox::String s_version = ox::String(OLYMPIC_APP_VERSION);
ox::Error run(
ox::StringView project,
ox::StringView appName,

View File

@ -125,7 +125,11 @@ ox::Error preloadDir(
auto const dir = ox::sfmt("{}{}/", path, name);
oxReturnError(preloadDir(ts, romFs, pl, dir));
} else {
oxReturnError(preloadObj(ts, romFs, pl, filePath));
auto const err = preloadObj(ts, romFs, pl, filePath);
if (err) {
oxErrf("\033[31;1;1mCould not preload {}:\n\t{}\n", filePath, toStr(err));
return err;
}
}
}
return {};

View File

@ -120,7 +120,11 @@ static ox::Error transformClaw(
auto const dir = ox::sfmt("{}{}/", path, name);
oxReturnError(transformClaw(ctx, ts, dest, dir));
} else {
oxReturnError(doTransformations(ctx, ts, dest, filePath));
auto const err = doTransformations(ctx, ts, dest, filePath);
if (err) {
oxErrf("\033[31;1;1mCould not do transformations for {}:\n\t{}\n", filePath, toStr(err));
return err;
}
}
}
return {};

View File

@ -7,10 +7,14 @@
#include <studio/imguiuitl.hpp>
#include "aboutpopup.hpp"
namespace olympic {
extern ox::String s_version;
}
namespace studio {
AboutPopup::AboutPopup(turbine::Context &ctx) noexcept {
m_text = ox::sfmt("{} - dev build", keelCtx(ctx).appName);
m_text = ox::sfmt("{} - {}", keelCtx(ctx).appName, olympic::s_version);
}
void AboutPopup::open() noexcept {

View File

@ -5,7 +5,6 @@
#include <ctime>
#include <ox/logconn/logconn.hpp>
#include <ox/logconn/def.hpp>
#include <ox/std/trace.hpp>
#include <ox/std/uuid.hpp>
#include <keel/media.hpp>
@ -31,21 +30,19 @@ class StudioUIDrawer: public turbine::gl::Drawer {
static int updateHandler(turbine::Context &ctx) noexcept {
auto sctx = turbine::applicationData<studio::StudioContext>(ctx);
auto ui = dynamic_cast<StudioUI*>(sctx->ui);
ui->update();
sctx->ui->update();
return 16;
}
static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept {
auto sctx = turbine::applicationData<studio::StudioContext>(ctx);
auto ui = dynamic_cast<StudioUI*>(sctx->ui);
ui->handleKeyEvent(key, down);
sctx->ui->handleKeyEvent(key, down);
}
static ox::Error runApp(
ox::CRStringView appName,
ox::CRStringView projectDataDir,
ox::UniquePtr<ox::FileSystem> fs) noexcept {
ox::UPtr<ox::FileSystem> &&fs) noexcept {
oxRequireM(ctx, turbine::init(std::move(fs), appName));
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
turbine::setUpdateHandler(*ctx, updateHandler);

View File

@ -334,13 +334,15 @@ ox::Error StudioUI::createOpenProject(ox::CRStringView path) noexcept {
std::filesystem::create_directories(toStdStringView(path), ec);
oxReturnError(OxError(ec.value() != 0, "Could not create project directory"));
oxReturnError(openProjectPath(path));
return m_project->writeAllTypeDescriptors();
return m_project->writeTypeStore();
}
ox::Error StudioUI::openProjectPath(ox::CRStringView path) noexcept {
oxRequireM(fs, keel::loadRomFs(path));
oxReturnError(keel::setRomFs(keelCtx(m_ctx), std::move(fs)));
m_project = ox::make_unique<studio::Project>(keelCtx(m_ctx), ox::String(path), m_projectDataDir);
oxReturnError(
ox::make_unique_catch<studio::Project>(keelCtx(m_ctx), ox::String(path), m_projectDataDir)
.moveTo(m_project));
auto const sctx = applicationData<studio::StudioContext>(m_ctx);
sctx->project = m_project.get();
turbine::setWindowTitle(m_ctx, ox::sfmt("{} - {}", keelCtx(m_ctx).appName, m_project->projectPath()));

View File

@ -11,7 +11,7 @@
namespace studio {
struct StudioContext {
ox::SignalHandler *ui = nullptr;
class StudioUI *ui = nullptr;
Project *project = nullptr;
};

View File

@ -56,7 +56,7 @@ class Project {
ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap;
public:
explicit Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDataDir) noexcept;
explicit Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDataDir);
ox::Error create() noexcept;
@ -91,7 +91,7 @@ class Project {
[[nodiscard]]
ox::Vector<ox::String> const&fileList(ox::CRStringView ext) noexcept;
ox::Error writeAllTypeDescriptors() noexcept;
ox::Error writeTypeStore() noexcept;
private:
void buildFileIndex() noexcept;
@ -131,8 +131,8 @@ ox::Error Project::writeObj(ox::CRStringView path, T const&obj, ox::ClawFormat f
}
oxRequire(desc, m_typeStore.get<T>());
auto const descExists = m_fs.stat(ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*desc))).error != 0;
if (!descExists || ox::defines::Debug) {
oxReturnError(writeAllTypeDescriptors());
if (!descExists) {
oxReturnError(writeTypeStore());
}
oxReturnError(keel::setAsset(m_ctx, path, obj));
fileUpdated.emit(path);

View File

@ -26,7 +26,7 @@ static void generateTypes(ox::TypeStore &ts) noexcept {
}
}
Project::Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDataDir) noexcept:
Project::Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDataDir):
m_ctx(ctx),
m_path(std::move(path)),
m_projectDataDir(projectDataDir),
@ -35,6 +35,9 @@ Project::Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDa
m_fs(*m_ctx.rom) {
oxTracef("studio", "Project: {}", m_path);
generateTypes(m_typeStore);
if (ox::defines::Debug) {
oxThrowError(writeTypeStore());
}
buildFileIndex();
}
@ -70,7 +73,7 @@ ox::Vector<ox::String> const&Project::fileList(ox::CRStringView ext) noexcept {
return m_fileExtFileMap[ext];
}
ox::Error Project::writeAllTypeDescriptors() noexcept {
ox::Error Project::writeTypeStore() noexcept {
// write all descriptors because we don't know which types T depends on
oxReturnError(mkdir(m_typeDescPath));
for (auto const &t: m_typeStore.typeList()) {