Compare commits
12 Commits
6b948ee069
...
release-d2
Author | SHA1 | Date | |
---|---|---|---|
6d649292e2 | |||
7f56a77e7d | |||
055d64b125 | |||
de9f842640 | |||
200e586768 | |||
f1609519a7 | |||
e452d9db4f | |||
43a87b606e | |||
8acc6244d5 | |||
bd2aeee276 | |||
89fab5cc20 | |||
1c06ea677f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
.clangd
|
||||
.current_build
|
||||
.conanbuild
|
||||
.idea
|
||||
.mypy_cache
|
||||
.stfolder
|
||||
.stignore
|
||||
|
@ -15,6 +15,7 @@ probably differ), install the following additional packages:
|
||||
* pkg-config
|
||||
* xorg-dev
|
||||
* libgtk-3-dev
|
||||
* python3-mypy
|
||||
|
||||
## Build
|
||||
|
||||
|
5
deps/ox/src/ox/claw/read.cpp
vendored
5
deps/ox/src/ox/claw/read.cpp
vendored
@ -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) {
|
||||
|
6
deps/ox/src/ox/fs/CMakeLists.txt
vendored
6
deps/ox/src/ox/fs/CMakeLists.txt
vendored
@ -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
|
||||
|
11
deps/ox/src/ox/std/memory.hpp
vendored
11
deps/ox/src/ox/std/memory.hpp
vendored
@ -39,6 +39,7 @@ constexpr T *construct_at(T *p, Args &&...args ) {
|
||||
|
||||
#endif
|
||||
|
||||
#include "error.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
|
||||
@ -290,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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -109,8 +109,9 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key key, bool down) {
|
||||
m_subsheetEditor.close();
|
||||
m_exportMenu.close();
|
||||
}
|
||||
auto pal = m_model.pal();
|
||||
if (pal) {
|
||||
auto const popupOpen = m_subsheetEditor.isOpen() && m_exportMenu.isOpen();
|
||||
auto const pal = m_model.pal();
|
||||
if (pal && !popupOpen) {
|
||||
const auto colorCnt = pal->colors.size();
|
||||
if (key == turbine::Key::Alpha_D) {
|
||||
m_tool = Tool::Draw;
|
||||
@ -496,7 +497,7 @@ void TileSheetEditorImGui::ExportMenu::draw() noexcept {
|
||||
ImGui::SetNextWindowSize(ImVec2(235, popupHeight));
|
||||
if (ImGui::BeginPopupModal(popupName, &m_show, modalFlags)) {
|
||||
ImGui::InputInt("Scale", &m_scale);
|
||||
m_scale = ox::clamp(m_scale, 1, 20);
|
||||
m_scale = ox::clamp(m_scale, 1, 50);
|
||||
if (ImGui::Button("OK", ImVec2{50, 20})) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
m_show = false;
|
||||
|
@ -41,6 +41,8 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
}
|
||||
void draw() noexcept;
|
||||
void close() noexcept;
|
||||
[[nodiscard]]
|
||||
inline bool isOpen() const noexcept { return m_show; }
|
||||
};
|
||||
class ExportMenu {
|
||||
int m_scale = 0;
|
||||
@ -53,6 +55,8 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
}
|
||||
void draw() noexcept;
|
||||
void close() noexcept;
|
||||
[[nodiscard]]
|
||||
inline bool isOpen() const noexcept { return m_show; }
|
||||
};
|
||||
std::size_t m_selectedPaletteIdx = 0;
|
||||
turbine::Context &m_ctx;
|
||||
|
@ -9,6 +9,11 @@ target_link_libraries(
|
||||
OlympicApplib
|
||||
)
|
||||
|
||||
target_compile_definitions(
|
||||
NostalgiaStudio PUBLIC
|
||||
OLYMPIC_APP_VERSION="2023.12.0"
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaStudio
|
||||
|
@ -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,
|
||||
|
@ -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 {};
|
||||
|
@ -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 {};
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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()));
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace studio {
|
||||
|
||||
struct StudioContext {
|
||||
ox::SignalHandler *ui = nullptr;
|
||||
class StudioUI *ui = nullptr;
|
||||
Project *project = nullptr;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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()) {
|
||||
|
Reference in New Issue
Block a user