Compare commits
2 Commits
5b91ad25c2
...
b946e428ad
Author | SHA1 | Date | |
---|---|---|---|
b946e428ad | |||
a84a829769 |
12
deps/ox/src/ox/clargs/clargs.cpp
vendored
12
deps/ox/src/ox/clargs/clargs.cpp
vendored
@ -37,32 +37,32 @@ ClArgs::ClArgs(int argc, const char **args) noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClArgs::getBool(ox::CRStringView arg, bool defaultValue) const noexcept {
|
bool ClArgs::getBool(ox::CRString arg, bool defaultValue) const noexcept {
|
||||||
auto [value, err] = m_ints.at(arg);
|
auto [value, err] = m_ints.at(arg);
|
||||||
return !err ? *value : defaultValue;
|
return !err ? *value : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ClArgs::getString(ox::CRStringView arg, const char *defaultValue) const noexcept {
|
String ClArgs::getString(ox::CRString arg, const char *defaultValue) const noexcept {
|
||||||
auto [value, err] = m_strings.at(arg);
|
auto [value, err] = m_strings.at(arg);
|
||||||
return !err ? *value : defaultValue;
|
return !err ? *value : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClArgs::getInt(ox::CRStringView arg, int defaultValue) const noexcept {
|
int ClArgs::getInt(ox::CRString arg, int defaultValue) const noexcept {
|
||||||
auto [value, err] = m_ints.at(arg);
|
auto [value, err] = m_ints.at(arg);
|
||||||
return !err ? *value : defaultValue;
|
return !err ? *value : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<bool> ClArgs::getBool(ox::CRStringView arg) const noexcept {
|
Result<bool> ClArgs::getBool(ox::CRString arg) const noexcept {
|
||||||
oxRequire(out, m_bools.at(arg));
|
oxRequire(out, m_bools.at(arg));
|
||||||
return *out;
|
return *out;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<String> ClArgs::getString(ox::CRStringView argName) const noexcept {
|
Result<String> ClArgs::getString(ox::CRString argName) const noexcept {
|
||||||
oxRequire(out, m_strings.at(argName));
|
oxRequire(out, m_strings.at(argName));
|
||||||
return *out;
|
return *out;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> ClArgs::getInt(ox::CRStringView arg) const noexcept {
|
Result<int> ClArgs::getInt(ox::CRString arg) const noexcept {
|
||||||
oxRequire(out, m_ints.at(arg));
|
oxRequire(out, m_ints.at(arg));
|
||||||
return *out;
|
return *out;
|
||||||
}
|
}
|
||||||
|
12
deps/ox/src/ox/clargs/clargs.hpp
vendored
12
deps/ox/src/ox/clargs/clargs.hpp
vendored
@ -23,21 +23,21 @@ class ClArgs {
|
|||||||
ClArgs(int argc, const char **args) noexcept;
|
ClArgs(int argc, const char **args) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept;
|
bool getBool(ox::CRString arg, bool defaultValue) const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
String getString(ox::CRStringView argName, const char *defaultValue) const noexcept;
|
String getString(ox::CRString argName, const char *defaultValue) const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
int getInt(ox::CRStringView arg, int defaultValue) const noexcept;
|
int getInt(ox::CRString arg, int defaultValue) const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Result<bool> getBool(ox::CRStringView arg) const noexcept;
|
Result<bool> getBool(ox::CRString arg) const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Result<String> getString(ox::CRStringView argName) const noexcept;
|
Result<String> getString(ox::CRString argName) const noexcept;
|
||||||
|
|
||||||
Result<int> getInt(ox::CRStringView arg) const noexcept;
|
Result<int> getInt(ox::CRString arg) const noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
10
deps/ox/src/ox/event/signal.hpp
vendored
10
deps/ox/src/ox/event/signal.hpp
vendored
@ -245,7 +245,7 @@ class Signal<Error(Args...)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error call(Args... args) noexcept final {
|
Error call(Args... args) noexcept final {
|
||||||
return f(args...);
|
return f(ox::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ class Signal<Error(Args...)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error call(Args... args) noexcept final {
|
Error call(Args... args) noexcept final {
|
||||||
return (m_receiver->*(m_methodPtr))(args...);
|
return (m_receiver->*(m_methodPtr))(ox::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup(Signal *signal) noexcept final {
|
void cleanup(Signal *signal) noexcept final {
|
||||||
@ -286,7 +286,7 @@ class Signal<Error(Args...)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error call(Args... args) noexcept final {
|
Error call(Args... args) noexcept final {
|
||||||
return (m_receiver->*(m_methodPtr))(args...);
|
return (m_receiver->*(m_methodPtr))(ox::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup(Signal*) noexcept final {
|
void cleanup(Signal*) noexcept final {
|
||||||
@ -391,14 +391,14 @@ Error Signal<Error(Args...)>::disconnectObject(const void *receiver) const noexc
|
|||||||
template<class... Args>
|
template<class... Args>
|
||||||
void Signal<Error(Args...)>::emit(Args... args) const noexcept {
|
void Signal<Error(Args...)>::emit(Args... args) const noexcept {
|
||||||
for (auto &f : m_slots) {
|
for (auto &f : m_slots) {
|
||||||
oxIgnoreError(f->call(args...));
|
oxIgnoreError(f->call(ox::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
Error Signal<Error(Args...)>::emitCheckError(Args... args) const noexcept {
|
Error Signal<Error(Args...)>::emitCheckError(Args... args) const noexcept {
|
||||||
for (auto &f : m_slots) {
|
for (auto &f : m_slots) {
|
||||||
oxReturnError(f->call(args...));
|
oxReturnError(f->call(ox::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
|
1
deps/ox/src/ox/fs/CMakeLists.txt
vendored
1
deps/ox/src/ox/fs/CMakeLists.txt
vendored
@ -44,7 +44,6 @@ if(NOT OX_BARE_METAL)
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
oxfs-tool
|
oxfs-tool
|
||||||
OxFS
|
OxFS
|
||||||
OxStd
|
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
|
2
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
2
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@ -252,7 +252,7 @@ Error Directory<FileStore, InodeId_t>::write(PathIterator path, uint64_t inode64
|
|||||||
|
|
||||||
oxTracef("ox::fs::Directory::write", "Attempting to write Directory entry: {}", name->data());
|
oxTracef("ox::fs::Directory::write", "Attempting to write Directory entry: {}", name->data());
|
||||||
oxReturnError(val->init(inode, name->data(), val.size()));
|
oxReturnError(val->init(inode, name->data(), val.size()));
|
||||||
return m_fs.write(m_inodeId, cpy, cpy->size(), static_cast<uint8_t>(FileType::Directory));
|
return m_fs.write(m_inodeId, cpy.get(), cpy->size(), static_cast<uint8_t>(FileType::Directory));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
deps/ox/src/ox/fs/test/CMakeLists.txt
vendored
1
deps/ox/src/ox/fs/test/CMakeLists.txt
vendored
@ -6,7 +6,6 @@ add_executable(
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
FSTests
|
FSTests
|
||||||
OxFS
|
OxFS
|
||||||
OxStd
|
|
||||||
OxMetalClaw
|
OxMetalClaw
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
deps/ox/src/ox/logconn/logconn.cpp
vendored
2
deps/ox/src/ox/logconn/logconn.cpp
vendored
@ -58,7 +58,7 @@ ox::Error LoggerConn::initConn(ox::CRStringView appName) noexcept {
|
|||||||
addr.sin_port = htons(5590);
|
addr.sin_port = htons(5590);
|
||||||
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
oxReturnError(OxError(static_cast<ox::ErrorCode>(connect(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)))));
|
oxReturnError(OxError(static_cast<ox::ErrorCode>(connect(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)))));
|
||||||
return sendInit({.appName = appName});
|
return sendInit({.appName = ox::BasicString<128>(appName)});
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error LoggerConn::send(const char *buff, std::size_t len) const noexcept {
|
ox::Error LoggerConn::send(const char *buff, std::size_t len) const noexcept {
|
||||||
|
2
deps/ox/src/ox/mc/read.hpp
vendored
2
deps/ox/src/ox/mc/read.hpp
vendored
@ -254,7 +254,7 @@ constexpr Error MetalClawReaderTemplate<Reader>::field(const char*, HashMap<Stri
|
|||||||
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
||||||
auto wkeyPtr = wkey.get();
|
auto wkeyPtr = wkey.get();
|
||||||
oxReturnError(handler.fieldCString("", &wkeyPtr, keyLen + 1));
|
oxReturnError(handler.fieldCString("", &wkeyPtr, keyLen + 1));
|
||||||
return handler.field("", &val[wkey.get()]);
|
return handler.field("", &val[wkeyPtr]);
|
||||||
};
|
};
|
||||||
for (std::size_t i = 0; i < len; ++i) {
|
for (std::size_t i = 0; i < len; ++i) {
|
||||||
oxReturnError(loopBody(handler, *val));
|
oxReturnError(loopBody(handler, *val));
|
||||||
|
2
deps/ox/src/ox/mc/write.hpp
vendored
2
deps/ox/src/ox/mc/write.hpp
vendored
@ -363,7 +363,7 @@ constexpr Error MetalClawWriter<Writer>::field(const char*, const HashMap<String
|
|||||||
constexpr auto loopBody = [](auto &handler, auto const&key, auto const&val) -> ox::Error {
|
constexpr auto loopBody = [](auto &handler, auto const&key, auto const&val) -> ox::Error {
|
||||||
const auto keyLen = ox_strlen(key);
|
const auto keyLen = ox_strlen(key);
|
||||||
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
||||||
memcpy(wkey, key.c_str(), keyLen + 1);
|
memcpy(wkey.get(), key.c_str(), keyLen + 1);
|
||||||
oxReturnError(handler.fieldCString("", wkey.get(), keyLen));
|
oxReturnError(handler.fieldCString("", wkey.get(), keyLen));
|
||||||
oxRequireM(value, val.at(key));
|
oxRequireM(value, val.at(key));
|
||||||
return handler.field("", value);
|
return handler.field("", value);
|
||||||
|
15
deps/ox/src/ox/model/descwrite.hpp
vendored
15
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -175,8 +175,9 @@ class TypeDescWriter {
|
|||||||
constexpr TypeDescWriter::TypeDescWriter(TypeStore *typeStore) noexcept: m_typeStore(typeStore) {}
|
constexpr TypeDescWriter::TypeDescWriter(TypeStore *typeStore) noexcept: m_typeStore(typeStore) {}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr ox::Error TypeDescWriter::setTypeInfo(CRStringView typeName, int typeVersion,
|
constexpr ox::Error TypeDescWriter::setTypeInfo(
|
||||||
const TypeParamPack &typeParams, std::size_t) noexcept {
|
CRStringView typeName, int typeVersion,
|
||||||
|
const TypeParamPack &typeParams, std::size_t) noexcept {
|
||||||
PrimitiveType pt;
|
PrimitiveType pt;
|
||||||
if constexpr(is_union_v<T>) {
|
if constexpr(is_union_v<T>) {
|
||||||
pt = PrimitiveType::Union;
|
pt = PrimitiveType::Union;
|
||||||
@ -197,7 +198,7 @@ constexpr Error TypeDescWriter::field(CRStringView name, const T*, std::size_t,
|
|||||||
constexpr typename remove_pointer<T>::type *p = nullptr;
|
constexpr typename remove_pointer<T>::type *p = nullptr;
|
||||||
const auto t = type(p);
|
const auto t = type(p);
|
||||||
oxAssert(t != nullptr, "field(const char *name, T *val, std::size_t): Type not found or generated");
|
oxAssert(t != nullptr, "field(const char *name, T *val, std::size_t): Type not found or generated");
|
||||||
m_type->fieldList.emplace_back(t, name, detail::indirectionLevels_v<T> + 1, subscriptStack, buildTypeId(*t));
|
m_type->fieldList.emplace_back(t, String(name), detail::indirectionLevels_v<T> + 1, subscriptStack, buildTypeId(*t));
|
||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
@ -208,7 +209,7 @@ constexpr Error TypeDescWriter::field(CRStringView name, UnionView<T, force> val
|
|||||||
if (m_type) {
|
if (m_type) {
|
||||||
const auto t = type(val);
|
const auto t = type(val);
|
||||||
oxAssert(t != nullptr, "field(const char *name, T val): Type not found or generated");
|
oxAssert(t != nullptr, "field(const char *name, T val): Type not found or generated");
|
||||||
m_type->fieldList.emplace_back(t, name, 0, SubscriptStack{}, t->typeName);
|
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, t->typeName);
|
||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
@ -226,7 +227,7 @@ constexpr Error TypeDescWriter::field(CRStringView name, const T *val) noexcept
|
|||||||
} else {
|
} else {
|
||||||
const auto t = type(val);
|
const auto t = type(val);
|
||||||
oxAssert(t != nullptr, "field(const char *name, T *val): Type not found or generated");
|
oxAssert(t != nullptr, "field(const char *name, T *val): Type not found or generated");
|
||||||
m_type->fieldList.emplace_back(t, name, 0, SubscriptStack{}, buildTypeId(*t));
|
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, buildTypeId(*t));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +238,7 @@ template<typename ...Args>
|
|||||||
constexpr Error TypeDescWriter::fieldCString(CRStringView name, Args&&...) noexcept {
|
constexpr Error TypeDescWriter::fieldCString(CRStringView name, Args&&...) noexcept {
|
||||||
constexpr auto s = "";
|
constexpr auto s = "";
|
||||||
const auto t = type(s);
|
const auto t = type(s);
|
||||||
m_type->fieldList.emplace_back(t, name, 0, SubscriptStack{}, t->typeName);
|
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, t->typeName);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +345,7 @@ constexpr const DescriptorType *TypeDescWriter::getType(CRStringView tn, int typ
|
|||||||
oxAssert(type != nullptr, "TypeDescWriter::getType returning null DescriptorType");
|
oxAssert(type != nullptr, "TypeDescWriter::getType returning null DescriptorType");
|
||||||
return type;
|
return type;
|
||||||
} else {
|
} else {
|
||||||
auto dt = ox::make_unique<DescriptorType>(tn, typeVersion, pt, typeParams);
|
auto dt = ox::make_unique<DescriptorType>(String(tn), typeVersion, pt, typeParams);
|
||||||
dt->length = b;
|
dt->length = b;
|
||||||
const auto out = dt.get();
|
const auto out = dt.get();
|
||||||
const auto typeId = buildTypeId(tn, typeVersion, typeParams);
|
const auto typeId = buildTypeId(tn, typeVersion, typeParams);
|
||||||
|
4
deps/ox/src/ox/model/typestore.hpp
vendored
4
deps/ox/src/ox/model/typestore.hpp
vendored
@ -44,11 +44,11 @@ class TypeStore {
|
|||||||
return out->get();
|
return out->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr DescriptorType *getInit(const auto &typeName, int typeVersion, PrimitiveType pt,
|
constexpr DescriptorType *getInit(CRStringView typeName, int typeVersion, PrimitiveType pt,
|
||||||
const TypeParamPack &typeParams) noexcept {
|
const TypeParamPack &typeParams) noexcept {
|
||||||
const auto typeId = buildTypeId(typeName, typeVersion, typeParams);
|
const auto typeId = buildTypeId(typeName, typeVersion, typeParams);
|
||||||
auto &out = m_cache[typeId];
|
auto &out = m_cache[typeId];
|
||||||
out = ox::make_unique<DescriptorType>(typeName, typeVersion, pt, typeParams);
|
out = ox::make_unique<DescriptorType>(String(typeName), typeVersion, pt, typeParams);
|
||||||
return out.get();
|
return out.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
deps/ox/src/ox/std/error.hpp
vendored
12
deps/ox/src/ox/std/error.hpp
vendored
@ -25,8 +25,6 @@ class exception {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "def.hpp"
|
#include "def.hpp"
|
||||||
#include "defines.hpp"
|
|
||||||
#include "strongint.hpp"
|
|
||||||
#include "typetraits.hpp"
|
#include "typetraits.hpp"
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
@ -191,6 +189,13 @@ struct [[nodiscard]] Result {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr auto &unwrapThrow() {
|
||||||
|
if (error) {
|
||||||
|
throw ox::Exception(error);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr const auto &unwrap() const noexcept {
|
constexpr const auto &unwrap() const noexcept {
|
||||||
if (error) [[unlikely]] {
|
if (error) [[unlikely]] {
|
||||||
oxPanic(error, "Failed unwrap");
|
oxPanic(error, "Failed unwrap");
|
||||||
@ -198,7 +203,8 @@ struct [[nodiscard]] Result {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr ox::Result<T> to(const auto &f) noexcept {
|
template<typename U = T>
|
||||||
|
constexpr ox::Result<U> to(const auto &f) noexcept {
|
||||||
if (error) [[unlikely]] {
|
if (error) [[unlikely]] {
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
}
|
}
|
||||||
|
15
deps/ox/src/ox/std/new.hpp
vendored
15
deps/ox/src/ox/std/new.hpp
vendored
@ -115,11 +115,11 @@ class MallocaPtr {
|
|||||||
return reinterpret_cast<T*>(m_val);
|
return reinterpret_cast<T*>(m_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const T &operator=(MallocaPtr &other) = delete;
|
constexpr MallocaPtr &operator=(MallocaPtr &other) = delete;
|
||||||
|
|
||||||
constexpr const T &operator=(const MallocaPtr &other) = delete;
|
constexpr MallocaPtr &operator=(const MallocaPtr &other) = delete;
|
||||||
|
|
||||||
constexpr const T &operator=(MallocaPtr &&other) noexcept {
|
constexpr MallocaPtr &operator=(MallocaPtr &&other) noexcept {
|
||||||
if (m_onHeap && m_val) {
|
if (m_onHeap && m_val) {
|
||||||
delete[] reinterpret_cast<uint8_t*>(m_val);
|
delete[] reinterpret_cast<uint8_t*>(m_val);
|
||||||
}
|
}
|
||||||
@ -127,6 +127,7 @@ class MallocaPtr {
|
|||||||
m_val = other.m_val;
|
m_val = other.m_val;
|
||||||
other.m_onHeap = false;
|
other.m_onHeap = false;
|
||||||
other.m_val = nullptr;
|
other.m_val = nullptr;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const T *operator->() const noexcept {
|
constexpr const T *operator->() const noexcept {
|
||||||
@ -137,11 +138,11 @@ class MallocaPtr {
|
|||||||
return reinterpret_cast<T*>(m_val);
|
return reinterpret_cast<T*>(m_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr operator const T*() const noexcept {
|
constexpr explicit operator const T*() const noexcept {
|
||||||
return reinterpret_cast<T*>(m_val);
|
return reinterpret_cast<T*>(m_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr operator T*() noexcept {
|
constexpr explicit operator T*() noexcept {
|
||||||
return reinterpret_cast<T*>(m_val);
|
return reinterpret_cast<T*>(m_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +154,10 @@ class MallocaPtr {
|
|||||||
return *reinterpret_cast<T*>(m_val);
|
return *reinterpret_cast<T*>(m_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool operator==(std::nullptr_t) const noexcept {
|
||||||
|
return m_val == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr bool operator==(const MallocaPtr<T> &other) const noexcept {
|
constexpr bool operator==(const MallocaPtr<T> &other) const noexcept {
|
||||||
return m_val == other.m_val && m_onHeap == other.m_onHeap;
|
return m_val == other.m_val && m_onHeap == other.m_onHeap;
|
||||||
}
|
}
|
||||||
|
2
deps/ox/src/ox/std/span.hpp
vendored
2
deps/ox/src/ox/std/span.hpp
vendored
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include "bit.hpp"
|
#include "bit.hpp"
|
||||||
#include "iterator.hpp"
|
#include "iterator.hpp"
|
||||||
#include "typetraits.hpp"
|
|
||||||
#include "types.hpp"
|
|
||||||
#include "vector.hpp"
|
#include "vector.hpp"
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
17
deps/ox/src/ox/std/string.hpp
vendored
17
deps/ox/src/ox/std/string.hpp
vendored
@ -13,12 +13,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "algorithm.hpp"
|
#include "algorithm.hpp"
|
||||||
#include "buffer.hpp"
|
|
||||||
#include "memops.hpp"
|
#include "memops.hpp"
|
||||||
#include "serialize.hpp"
|
#include "serialize.hpp"
|
||||||
#include "stringview.hpp"
|
#include "stringview.hpp"
|
||||||
#include "strops.hpp"
|
#include "strops.hpp"
|
||||||
#include "typetraits.hpp"
|
|
||||||
#include "vector.hpp"
|
#include "vector.hpp"
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
@ -40,7 +38,7 @@ class BasicString {
|
|||||||
|
|
||||||
constexpr BasicString(const char *str, std::size_t size) noexcept;
|
constexpr BasicString(const char *str, std::size_t size) noexcept;
|
||||||
|
|
||||||
constexpr BasicString(CRStringView str) noexcept;
|
constexpr explicit BasicString(CRStringView str) noexcept;
|
||||||
|
|
||||||
constexpr BasicString(const BasicString&) noexcept;
|
constexpr BasicString(const BasicString&) noexcept;
|
||||||
|
|
||||||
@ -140,6 +138,8 @@ class BasicString {
|
|||||||
|
|
||||||
constexpr BasicString operator+(Integer_c auto i) const noexcept;
|
constexpr BasicString operator+(Integer_c auto i) const noexcept;
|
||||||
|
|
||||||
|
constexpr BasicString operator+(CRStringView src) const noexcept;
|
||||||
|
|
||||||
constexpr BasicString operator+(const BasicString &src) const noexcept;
|
constexpr BasicString operator+(const BasicString &src) const noexcept;
|
||||||
|
|
||||||
constexpr bool operator==(const char *other) const noexcept;
|
constexpr bool operator==(const char *other) const noexcept;
|
||||||
@ -414,6 +414,17 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
|
|||||||
return *this + str;
|
return *this + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<std::size_t SmallStringSize_v>
|
||||||
|
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(CRStringView src) const noexcept {
|
||||||
|
const std::size_t strLen = src.len();
|
||||||
|
const auto currentLen = len();
|
||||||
|
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
|
||||||
|
cpy.m_buff.resize(m_buff.size() + strLen);
|
||||||
|
memcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
|
||||||
|
memcpy(&cpy.m_buff[currentLen], src.data(), strLen + 1);
|
||||||
|
return cpy;
|
||||||
|
}
|
||||||
|
|
||||||
template<std::size_t SmallStringSize_v>
|
template<std::size_t SmallStringSize_v>
|
||||||
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(const BasicString &src) const noexcept {
|
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(const BasicString &src) const noexcept {
|
||||||
const std::size_t strLen = src.len();
|
const std::size_t strLen = src.len();
|
||||||
|
2
deps/ox/src/ox/std/trace.hpp
vendored
2
deps/ox/src/ox/std/trace.hpp
vendored
@ -131,7 +131,7 @@ class OutStream {
|
|||||||
m_msg.file = file;
|
m_msg.file = file;
|
||||||
m_msg.line = line;
|
m_msg.line = line;
|
||||||
m_msg.ch = ch;
|
m_msg.ch = ch;
|
||||||
m_msg.msg = msg;
|
m_msg.msg = BasicString<100>(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr OutStream(const char *file, int line, const char *ch, const char *msg = "") noexcept {
|
constexpr OutStream(const char *file, int line, const char *ch, const char *msg = "") noexcept {
|
||||||
|
3
deps/ox/src/ox/std/uuid.hpp
vendored
3
deps/ox/src/ox/std/uuid.hpp
vendored
@ -10,11 +10,10 @@
|
|||||||
|
|
||||||
#include "array.hpp"
|
#include "array.hpp"
|
||||||
#include "bstring.hpp"
|
#include "bstring.hpp"
|
||||||
|
#include "buffer.hpp"
|
||||||
#include "random.hpp"
|
#include "random.hpp"
|
||||||
#include "ranges.hpp"
|
#include "ranges.hpp"
|
||||||
#include "stringview.hpp"
|
#include "stringview.hpp"
|
||||||
#include "strops.hpp"
|
|
||||||
#include "trace.hpp"
|
|
||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ target_link_libraries(
|
|||||||
OxFS
|
OxFS
|
||||||
OxModel
|
OxModel
|
||||||
OxPreloader
|
OxPreloader
|
||||||
OxStd
|
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
@ -45,4 +44,4 @@ install(
|
|||||||
|
|
||||||
if(TURBINE_BUILD_TYPE STREQUAL "Native")
|
if(TURBINE_BUILD_TYPE STREQUAL "Native")
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
@ -56,20 +56,24 @@ ox::Result<keel::AssetRef<T>> readObjFile(
|
|||||||
path = ctx->uuidToPath[assetId];
|
path = ctx->uuidToPath[assetId];
|
||||||
} else {
|
} else {
|
||||||
path = assetId;
|
path = assetId;
|
||||||
uuidStr = ctx->pathToUuid[path].toString();
|
// Warning: StringView to String
|
||||||
|
uuidStr = ctx->pathToUuid[ox::String(path)].toString();
|
||||||
assetId = uuidStr;
|
assetId = uuidStr;
|
||||||
}
|
}
|
||||||
if (forceLoad) {
|
if (forceLoad) {
|
||||||
oxRequire(buff, ctx->rom->read(path));
|
oxRequire(buff, ctx->rom->read(path));
|
||||||
oxRequire(obj, readConvert(ctx, buff));
|
oxRequire(obj, readConvert(ctx, buff));
|
||||||
oxRequire(cached, ctx->assetManager.setAsset(assetId, obj));
|
// Warning: StringView to String
|
||||||
|
oxRequire(cached, ctx->assetManager.setAsset(ox::String(assetId), obj));
|
||||||
return cached;
|
return cached;
|
||||||
} else {
|
} else {
|
||||||
auto [cached, err] = ctx->assetManager.getAsset<T>(assetId);
|
// Warning: StringView to String
|
||||||
|
auto [cached, err] = ctx->assetManager.getAsset<T>(ox::String(assetId));
|
||||||
if (err) {
|
if (err) {
|
||||||
oxRequire(buff, ctx->rom->read(path));
|
oxRequire(buff, ctx->rom->read(path));
|
||||||
oxRequire(obj, readConvert(ctx, buff));
|
oxRequire(obj, readConvert(ctx, buff));
|
||||||
oxReturnError(ctx->assetManager.setAsset(assetId, obj).moveTo(&cached));
|
// Warning: StringView to String
|
||||||
|
oxReturnError(ctx->assetManager.setAsset(ox::String(assetId), obj).moveTo(&cached));
|
||||||
}
|
}
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
@ -103,12 +107,14 @@ ox::Result<AssetRef<T>> setAsset(keel::Context *ctx, ox::StringView assetId, T c
|
|||||||
}
|
}
|
||||||
ox::UUIDStr idStr;
|
ox::UUIDStr idStr;
|
||||||
if (assetId[0] == '/') {
|
if (assetId[0] == '/') {
|
||||||
const auto [id, err] = ctx->pathToUuid.at(assetId);
|
// Warning: StringView to String
|
||||||
|
const auto [id, err] = ctx->pathToUuid.at(ox::String(assetId));
|
||||||
oxReturnError(err);
|
oxReturnError(err);
|
||||||
idStr = id->toString();
|
idStr = id->toString();
|
||||||
assetId = idStr;
|
assetId = idStr;
|
||||||
}
|
}
|
||||||
return ctx->assetManager.setAsset(assetId, asset);
|
// Warning: StringView to String
|
||||||
|
return ctx->assetManager.setAsset(ox::String(assetId), asset);
|
||||||
#else
|
#else
|
||||||
return OxError(1, "Not supported on this platform");
|
return OxError(1, "Not supported on this platform");
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,20 +15,11 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(turbine::Context *ctx, ox::CRStringView path) noexcept {
|
PaletteEditorImGui::PaletteEditorImGui(turbine::Context *ctx, ox::String path):
|
||||||
ox::UniquePtr<PaletteEditorImGui> out;
|
m_ctx(ctx),
|
||||||
try {
|
m_itemPath(std::move(path)),
|
||||||
out = ox::UniquePtr<PaletteEditorImGui>(new PaletteEditorImGui);
|
m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)),
|
||||||
} catch (...) {
|
m_pal(*keel::readObj<Palette>(&m_ctx->keelCtx, ox::FileAddress(m_itemPath.c_str())).unwrapThrow()) {
|
||||||
return OxError(1);
|
|
||||||
}
|
|
||||||
out->m_ctx = ctx;
|
|
||||||
out->m_itemPath = path;
|
|
||||||
const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset();
|
|
||||||
out->m_itemName = out->m_itemPath.substr(lastSlash + 1);
|
|
||||||
oxRequire(pal, keel::readObj<Palette>(&out->m_ctx->keelCtx, ox::FileAddress(out->m_itemPath.c_str())));
|
|
||||||
out->m_pal = *pal;
|
|
||||||
return out.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ox::String &PaletteEditorImGui::itemName() const noexcept {
|
const ox::String &PaletteEditorImGui::itemName() const noexcept {
|
||||||
@ -93,21 +84,25 @@ void PaletteEditorImGui::draw(turbine::Context*) noexcept {
|
|||||||
ImGui::TableSetupColumn("Blue", ImGuiTableColumnFlags_WidthFixed, 50);
|
ImGui::TableSetupColumn("Blue", ImGuiTableColumnFlags_WidthFixed, 50);
|
||||||
ImGui::TableSetupColumn("Color Preview", ImGuiTableColumnFlags_NoHide);
|
ImGui::TableSetupColumn("Color Preview", ImGuiTableColumnFlags_NoHide);
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
|
constexpr auto colVal = [] (unsigned num) {
|
||||||
|
ox::Array<char, 4> numStr;
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ox_itoa(num, numStr.data());
|
||||||
|
ImGui::SetCursorPosX(
|
||||||
|
ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - ImGui::CalcTextSize(numStr.data()).x);
|
||||||
|
ImGui::Text("%s", numStr.data());
|
||||||
|
};
|
||||||
for (auto i = 0u; const auto c : m_pal.colors) {
|
for (auto i = 0u; const auto c : m_pal.colors) {
|
||||||
ImGui::PushID(static_cast<int>(i));
|
ImGui::PushID(static_cast<int>(i));
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
// Color No.
|
// Color No.
|
||||||
ImGui::TableNextColumn();
|
colVal(i);
|
||||||
ImGui::Text("%d", i);
|
|
||||||
// Red
|
// Red
|
||||||
ImGui::TableNextColumn();
|
colVal(red16(c));
|
||||||
ImGui::Text("%d", red16(c));
|
|
||||||
// Green
|
// Green
|
||||||
ImGui::TableNextColumn();
|
colVal(green16(c));
|
||||||
ImGui::Text("%d", green16(c));
|
|
||||||
// Blue
|
// Blue
|
||||||
ImGui::TableNextColumn();
|
colVal(blue16(c));
|
||||||
ImGui::Text("%d", blue16(c));
|
|
||||||
// ColorPreview
|
// ColorPreview
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
const auto ic = ImGui::GetColorU32(ImVec4(redf(c), greenf(c), bluef(c), 1));
|
const auto ic = ImGui::GetColorU32(ImVec4(redf(c), greenf(c), bluef(c), 1));
|
||||||
|
@ -15,15 +15,15 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
turbine::Context *m_ctx = nullptr;
|
turbine::Context *m_ctx = nullptr;
|
||||||
ox::String m_itemName;
|
|
||||||
ox::String m_itemPath;
|
ox::String m_itemPath;
|
||||||
|
ox::String m_itemName;
|
||||||
Palette m_pal;
|
Palette m_pal;
|
||||||
std::size_t m_selectedRow = 0;
|
std::size_t m_selectedRow = 0;
|
||||||
|
|
||||||
PaletteEditorImGui() noexcept = default;
|
PaletteEditorImGui() noexcept = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ox::Result<PaletteEditorImGui*> make(turbine::Context *ctx, ox::CRStringView path) noexcept;
|
PaletteEditorImGui(turbine::Context *ctx, ox::String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of item being edited.
|
* Returns the name of item being edited.
|
||||||
|
@ -17,13 +17,13 @@ class StudioModule: public studio::Module {
|
|||||||
{
|
{
|
||||||
{FileExt_ng},
|
{FileExt_ng},
|
||||||
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||||
return ox::makeCatch<TileSheetEditorImGui>(ctx, path);
|
return ox::makeCatch<TileSheetEditorImGui>(ctx, ox::String(path));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{FileExt_npal},
|
{FileExt_npal},
|
||||||
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||||
return PaletteEditorImGui::make(ctx, path);
|
return ox::makeCatch<PaletteEditorImGui>(ctx, ox::String(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -38,9 +38,9 @@ ox::Error toPngFile(const ox::String &path, const TileSheet::SubSheet &s, const
|
|||||||
return OxError(static_cast<ox::ErrorCode>(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8)));
|
return OxError(static_cast<ox::ErrorCode>(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context *ctx, ox::CRStringView path): m_tileSheetEditor(ctx, path) {
|
TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context *ctx, ox::String path): m_tileSheetEditor(ctx, path) {
|
||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
m_itemPath = path;
|
m_itemPath = std::move(path);
|
||||||
const auto lastSlash = ox::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
|
const auto lastSlash = ox::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
|
||||||
m_itemName = m_itemPath.substr(lastSlash + 1);
|
m_itemName = m_itemPath.substr(lastSlash + 1);
|
||||||
// init palette idx
|
// init palette idx
|
||||||
@ -393,7 +393,7 @@ void TileSheetEditorImGui::drawPaletteSelector() noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error TileSheetEditorImGui::updateActiveSubsheet(const ox::String &name, int cols, int rows) noexcept {
|
ox::Error TileSheetEditorImGui::updateActiveSubsheet(const ox::StringView &name, int cols, int rows) noexcept {
|
||||||
return model()->updateSubsheet(model()->activeSubSheetIdx(), name, cols, rows);
|
return model()->updateSubsheet(model()->activeSubSheetIdx(), name, cols, rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
|||||||
Tool m_tool = Tool::Draw;
|
Tool m_tool = Tool::Draw;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileSheetEditorImGui(turbine::Context *ctx, ox::CRStringView path);
|
TileSheetEditorImGui(turbine::Context *ctx, ox::String path);
|
||||||
|
|
||||||
~TileSheetEditorImGui() override = default;
|
~TileSheetEditorImGui() override = default;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
|||||||
|
|
||||||
void drawPaletteSelector() noexcept;
|
void drawPaletteSelector() noexcept;
|
||||||
|
|
||||||
ox::Error updateActiveSubsheet(const ox::String &name, int cols, int rows) noexcept;
|
ox::Error updateActiveSubsheet(const ox::StringView &name, int cols, int rows) noexcept;
|
||||||
|
|
||||||
// slots
|
// slots
|
||||||
private:
|
private:
|
||||||
|
@ -488,13 +488,13 @@ class UpdateSubSheetCommand: public TileSheetCommand {
|
|||||||
UpdateSubSheetCommand(
|
UpdateSubSheetCommand(
|
||||||
TileSheet &img,
|
TileSheet &img,
|
||||||
TileSheet::SubSheetIdx idx,
|
TileSheet::SubSheetIdx idx,
|
||||||
const ox::String &name,
|
ox::String name,
|
||||||
int cols,
|
int cols,
|
||||||
int rows) noexcept:
|
int rows) noexcept:
|
||||||
m_img(img),
|
m_img(img),
|
||||||
m_idx(std::move(idx)) {
|
m_idx(std::move(idx)) {
|
||||||
m_sheet = m_img.getSubSheet(m_idx);
|
m_sheet = m_img.getSubSheet(m_idx);
|
||||||
m_newName = name;
|
m_newName = std::move(name);
|
||||||
m_newCols = cols;
|
m_newCols = cols;
|
||||||
m_newRows = rows;
|
m_newRows = rows;
|
||||||
}
|
}
|
||||||
@ -682,8 +682,8 @@ void TileSheetEditorModel::deleteTiles(const TileSheet::SubSheetIdx &idx, std::s
|
|||||||
pushCommand(ox::make<DeleteTilesCommand>(m_img, idx, tileIdx, tileCnt));
|
pushCommand(ox::make<DeleteTilesCommand>(m_img, idx, tileIdx, tileCnt));
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error TileSheetEditorModel::updateSubsheet(const TileSheet::SubSheetIdx &idx, const ox::String &name, int cols, int rows) noexcept {
|
ox::Error TileSheetEditorModel::updateSubsheet(const TileSheet::SubSheetIdx &idx, const ox::StringView &name, int cols, int rows) noexcept {
|
||||||
pushCommand(ox::make<UpdateSubSheetCommand>(m_img, idx, name, cols, rows));
|
pushCommand(ox::make<UpdateSubSheetCommand>(m_img, idx, ox::String(name), cols, rows));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
|||||||
|
|
||||||
void deleteTiles(const TileSheet::SubSheetIdx &idx, std::size_t tileIdx, std::size_t tileCnt) noexcept;
|
void deleteTiles(const TileSheet::SubSheetIdx &idx, std::size_t tileIdx, std::size_t tileCnt) noexcept;
|
||||||
|
|
||||||
ox::Error updateSubsheet(const TileSheet::SubSheetIdx &idx, const ox::String &name, int cols, int rows) noexcept;
|
ox::Error updateSubsheet(const TileSheet::SubSheetIdx &idx, const ox::StringView &name, int cols, int rows) noexcept;
|
||||||
|
|
||||||
void setActiveSubsheet(const TileSheet::SubSheetIdx&) noexcept;
|
void setActiveSubsheet(const TileSheet::SubSheetIdx&) noexcept;
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
TileSheetEditorView::TileSheetEditorView(turbine::Context *ctx, ox::CRStringView path):
|
TileSheetEditorView::TileSheetEditorView(turbine::Context *ctx, ox::String path):
|
||||||
m_model(ctx, path), m_pixelsDrawer(&m_model) {
|
m_model(ctx, std::move(path)), m_pixelsDrawer(&m_model) {
|
||||||
// build shaders
|
// build shaders
|
||||||
oxThrowError(m_pixelsDrawer.buildShader());
|
oxThrowError(m_pixelsDrawer.buildShader());
|
||||||
oxThrowError(m_pixelGridDrawer.buildShader());
|
oxThrowError(m_pixelGridDrawer.buildShader());
|
||||||
|
@ -50,7 +50,7 @@ class TileSheetEditorView: public ox::SignalHandler {
|
|||||||
std::size_t m_palIdx = 0;
|
std::size_t m_palIdx = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileSheetEditorView(turbine::Context *ctx, ox::CRStringView path);
|
TileSheetEditorView(turbine::Context *ctx, ox::String path);
|
||||||
|
|
||||||
~TileSheetEditorView() override = default;
|
~TileSheetEditorView() override = default;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class Scene {
|
|||||||
public:
|
public:
|
||||||
explicit Scene(const SceneStatic &sceneStatic) noexcept;
|
explicit Scene(const SceneStatic &sceneStatic) noexcept;
|
||||||
|
|
||||||
ox::Error setupDisplay(core::Context *ctx) const noexcept;
|
ox::Error setupDisplay(core::Context &ctx) const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupLayer(core::Context*, const ox::Vector<uint16_t> &layer, unsigned layerNo) const noexcept;
|
void setupLayer(core::Context*, const ox::Vector<uint16_t> &layer, unsigned layerNo) const noexcept;
|
||||||
|
@ -12,17 +12,17 @@ Scene::Scene(const SceneStatic &sceneStatic) noexcept:
|
|||||||
m_sceneStatic(sceneStatic) {
|
m_sceneStatic(sceneStatic) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error Scene::setupDisplay(core::Context *ctx) const noexcept {
|
ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept {
|
||||||
if (m_sceneStatic.palettes.empty()) {
|
if (m_sceneStatic.palettes.empty()) {
|
||||||
return OxError(1, "Scene has no palettes");
|
return OxError(1, "Scene has no palettes");
|
||||||
}
|
}
|
||||||
const auto &palette = m_sceneStatic.palettes[0];
|
const auto &palette = m_sceneStatic.palettes[0];
|
||||||
oxReturnError(core::loadBgTileSheet(
|
oxReturnError(core::loadBgTileSheet(
|
||||||
ctx, 0, m_sceneStatic.tilesheet, palette));
|
&ctx, 0, m_sceneStatic.tilesheet, palette));
|
||||||
// disable all backgrounds
|
// disable all backgrounds
|
||||||
core::setBgStatus(ctx, 0);
|
core::setBgStatus(&ctx, 0);
|
||||||
for (auto layerNo = 0u; const auto &layer : m_sceneStatic.tileMapIdx) {
|
for (auto layerNo = 0u; const auto &layer : m_sceneStatic.tileMapIdx) {
|
||||||
setupLayer(ctx, layer, layerNo);
|
setupLayer(&ctx, layer, layerNo);
|
||||||
++layerNo;
|
++layerNo;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
namespace nostalgia::scene {
|
namespace nostalgia::scene {
|
||||||
|
|
||||||
SceneEditorImGui::SceneEditorImGui(turbine::Context *ctx, ox::CRStringView path):
|
SceneEditorImGui::SceneEditorImGui(turbine::Context &ctx, ox::String path):
|
||||||
m_editor(ctx, path),
|
m_ctx(ctx),
|
||||||
m_view(ctx, m_editor.scene()) {
|
m_itemPath(std::move(path)),
|
||||||
m_ctx = ctx;
|
m_editor(&m_ctx, m_itemPath),
|
||||||
m_itemPath = path;
|
m_view(&m_ctx, m_editor.scene()) {
|
||||||
const auto lastSlash = std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
|
const auto lastSlash = std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
|
||||||
m_itemName = m_itemPath.substr(lastSlash + 1);
|
m_itemName = m_itemPath.substr(lastSlash + 1);
|
||||||
setRequiresConstantRefresh(false);
|
setRequiresConstantRefresh(false);
|
||||||
@ -48,9 +48,9 @@ void SceneEditorImGui::onActivated() noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ox::Error SceneEditorImGui::saveItem() noexcept {
|
ox::Error SceneEditorImGui::saveItem() noexcept {
|
||||||
const auto sctx = applicationData<studio::StudioContext>(*m_ctx);
|
const auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||||
oxReturnError(sctx->project->writeObj(m_itemPath, &m_editor.scene()));
|
oxReturnError(sctx->project->writeObj(m_itemPath, &m_editor.scene()));
|
||||||
oxReturnError(m_ctx->keelCtx.assetManager.setAsset(m_itemPath, m_editor.scene()));
|
oxReturnError(m_ctx.keelCtx.assetManager.setAsset(m_itemPath, m_editor.scene()));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,14 +16,14 @@ namespace nostalgia::scene {
|
|||||||
class SceneEditorImGui: public studio::Editor {
|
class SceneEditorImGui: public studio::Editor {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
turbine::Context *m_ctx = nullptr;
|
turbine::Context &m_ctx;
|
||||||
ox::String m_itemName;
|
ox::String m_itemName;
|
||||||
ox::String m_itemPath;
|
ox::String m_itemPath;
|
||||||
SceneEditor m_editor;
|
SceneEditor m_editor;
|
||||||
SceneEditorView m_view;
|
SceneEditorView m_view;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SceneEditorImGui(turbine::Context *ctx, ox::CRStringView path);
|
SceneEditorImGui(turbine::Context &ctx, ox::String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of item being edited.
|
* Returns the name of item being edited.
|
||||||
|
@ -15,7 +15,7 @@ SceneEditorView::SceneEditorView(turbine::Context *tctx, const SceneStatic &scen
|
|||||||
}
|
}
|
||||||
|
|
||||||
ox::Error SceneEditorView::setupScene() noexcept {
|
ox::Error SceneEditorView::setupScene() noexcept {
|
||||||
return m_scene.setupDisplay(m_cctx.get());
|
return m_scene.setupDisplay(*m_cctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneEditorView::draw(int width, int height) noexcept {
|
void SceneEditorView::draw(int width, int height) noexcept {
|
||||||
|
@ -19,7 +19,7 @@ ox::Vector<studio::EditorMaker> StudioModule::editors(turbine::Context *ctx) con
|
|||||||
{
|
{
|
||||||
{"nscn"},
|
{"nscn"},
|
||||||
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||||
return ox::makeCatch<SceneEditorImGui>(ctx, path);
|
return ox::makeCatch<SceneEditorImGui>(*ctx, ox::String(path));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,6 @@ static void keyEventHandler(turbine::Context &tctx, turbine::Key key, bool down)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ox::Error run(ox::UniquePtr<ox::FileSystem> &&fs) noexcept {
|
ox::Error run(ox::UniquePtr<ox::FileSystem> &&fs) noexcept {
|
||||||
oxTraceInitHook();
|
|
||||||
oxRequireM(tctx, turbine::init(std::move(fs), "Nostalgia"));
|
oxRequireM(tctx, turbine::init(std::move(fs), "Nostalgia"));
|
||||||
oxRequireM(cctx, core::init(tctx.get()));
|
oxRequireM(cctx, core::init(tctx.get()));
|
||||||
constexpr ox::FileAddress SceneAddr("/Scenes/Chester.nscn");
|
constexpr ox::FileAddress SceneAddr("/Scenes/Chester.nscn");
|
||||||
@ -41,6 +40,6 @@ ox::Error run(ox::UniquePtr<ox::FileSystem> &&fs) noexcept {
|
|||||||
turbine::setUpdateHandler(*tctx, updateHandler);
|
turbine::setUpdateHandler(*tctx, updateHandler);
|
||||||
turbine::setKeyEventHandler(*tctx, keyEventHandler);
|
turbine::setKeyEventHandler(*tctx, keyEventHandler);
|
||||||
s_scene.emplace(*scn);
|
s_scene.emplace(*scn);
|
||||||
oxReturnError(s_scene->setupDisplay(cctx.get()));
|
oxReturnError(s_scene->setupDisplay(*cctx));
|
||||||
return turbine::run(*tctx);
|
return turbine::run(*tctx);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ox/logconn/def.hpp>
|
||||||
#include <ox/logconn/logconn.hpp>
|
#include <ox/logconn/logconn.hpp>
|
||||||
|
|
||||||
#include <keel/media.hpp>
|
#include <keel/media.hpp>
|
||||||
@ -11,8 +12,7 @@
|
|||||||
#include "app.hpp"
|
#include "app.hpp"
|
||||||
|
|
||||||
static ox::Error run(int argc, const char **argv) noexcept {
|
static ox::Error run(int argc, const char **argv) noexcept {
|
||||||
ox::trace::init();
|
#ifndef OX_BARE_METAL
|
||||||
#ifdef OX_USE_STDLIB
|
|
||||||
// GBA doesn't need the modules and calling this doubles the size of the
|
// GBA doesn't need the modules and calling this doubles the size of the
|
||||||
// binary.
|
// binary.
|
||||||
nostalgia::registerKeelModules();
|
nostalgia::registerKeelModules();
|
||||||
@ -33,16 +33,19 @@ int WinMain() {
|
|||||||
#else
|
#else
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
#endif
|
#endif
|
||||||
#if defined(DEBUG) && !defined(OX_BARE_METAL)
|
OX_INIT_DEBUG_LOGGER(loggerConn, "Nostalgia Player")
|
||||||
ox::LoggerConn loggerConn;
|
ox::Error err;
|
||||||
const auto loggerErr = loggerConn.initConn("Nostalgia Player");
|
#ifdef __cpp_exceptions
|
||||||
if (loggerErr) {
|
try {
|
||||||
oxErrf("Could not connect to logger: {} ({}:{})\n", toStr(loggerErr), loggerErr.file, loggerErr.line);
|
err = run(argc, argv);
|
||||||
} else {
|
} catch (ox::Exception const&ex) {
|
||||||
ox::trace::setLogger(&loggerConn);
|
err = ex.toError();
|
||||||
|
} catch (...) {
|
||||||
|
err = OxError(1, "Non-Ox exception");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
err = run(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
const auto err = run(argc, argv);
|
|
||||||
oxAssert(err, "Something went wrong...");
|
oxAssert(err, "Something went wrong...");
|
||||||
return static_cast<int>(err);
|
return static_cast<int>(err);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ target_link_libraries(
|
|||||||
nost-pack
|
nost-pack
|
||||||
OxClArgs
|
OxClArgs
|
||||||
OxLogConn
|
OxLogConn
|
||||||
Keel
|
|
||||||
NostalgiaKeelModules
|
NostalgiaKeelModules
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <ox/clargs/clargs.hpp>
|
#include <ox/clargs/clargs.hpp>
|
||||||
#include <ox/fs/fs.hpp>
|
#include <ox/fs/fs.hpp>
|
||||||
|
#include <ox/logconn/def.hpp>
|
||||||
#include <ox/logconn/logconn.hpp>
|
#include <ox/logconn/logconn.hpp>
|
||||||
|
|
||||||
#include <keel/keel.hpp>
|
#include <keel/keel.hpp>
|
||||||
@ -50,7 +51,6 @@ static ox::Error generateTypes(ox::TypeStore *ts) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ox::Error run(const ox::ClArgs &args) noexcept {
|
static ox::Error run(const ox::ClArgs &args) noexcept {
|
||||||
nostalgia::registerKeelModules();
|
|
||||||
const auto argSrc = args.getString("src", "");
|
const auto argSrc = args.getString("src", "");
|
||||||
const auto argRomBin = args.getString("rom-bin", "");
|
const auto argRomBin = args.getString("rom-bin", "");
|
||||||
if (argSrc == "") {
|
if (argSrc == "") {
|
||||||
@ -63,7 +63,7 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
|
|||||||
}
|
}
|
||||||
ox::Buffer dstBuff(32 * ox::units::MB);
|
ox::Buffer dstBuff(32 * ox::units::MB);
|
||||||
oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size()));
|
oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size()));
|
||||||
ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size()));
|
ox::FileSystem32 dst(dstBuff);
|
||||||
oxRequire(ctx, keel::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack"));
|
oxRequire(ctx, keel::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack"));
|
||||||
keel::TypeStore ts(ctx->rom.get(), "/.nostalgia/type_descriptors");
|
keel::TypeStore ts(ctx->rom.get(), "/.nostalgia/type_descriptors");
|
||||||
oxReturnError(generateTypes(&ts));
|
oxReturnError(generateTypes(&ts));
|
||||||
@ -87,16 +87,8 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char **args) {
|
int main(int argc, const char **args) {
|
||||||
ox::trace::init();
|
OX_INIT_DEBUG_LOGGER(loggerConn, "nost-pack")
|
||||||
#ifdef DEBUG
|
nostalgia::registerKeelModules();
|
||||||
ox::LoggerConn loggerConn;
|
|
||||||
const auto loggerErr = loggerConn.initConn("nost-pack");
|
|
||||||
if (loggerErr) {
|
|
||||||
oxErrf("Could not connect to logger: {} ({}:{})\n", toStr(loggerErr), loggerErr.file, loggerErr.line);
|
|
||||||
} else {
|
|
||||||
ox::trace::setLogger(&loggerConn);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
const auto err = run(ox::ClArgs(argc, args));
|
const auto err = run(ox::ClArgs(argc, args));
|
||||||
oxAssert(err, "pack failed");
|
oxAssert(err, "pack failed");
|
||||||
return static_cast<int>(err);
|
return static_cast<int>(err);
|
||||||
|
@ -12,8 +12,15 @@ namespace studio {
|
|||||||
|
|
||||||
void registerModule(const studio::Module*) noexcept;
|
void registerModule(const studio::Module*) noexcept;
|
||||||
|
|
||||||
|
struct StudioOptions {
|
||||||
|
ox::String appName;
|
||||||
|
ox::String projectDataDir;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(StudioOptions&&);
|
||||||
|
|
||||||
int main(
|
int main(
|
||||||
const char *appName,
|
ox::CRStringView appName,
|
||||||
ox::String projectDataDir,
|
ox::String projectDataDir,
|
||||||
int argc,
|
int argc,
|
||||||
const char **argv);
|
const char **argv);
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include <ox/logconn/logconn.hpp>
|
#include <ox/logconn/logconn.hpp>
|
||||||
|
#include <ox/logconn/def.hpp>
|
||||||
#include <ox/std/trace.hpp>
|
#include <ox/std/trace.hpp>
|
||||||
#include <ox/std/uuid.hpp>
|
#include <ox/std/uuid.hpp>
|
||||||
#include <keel/media.hpp>
|
#include <keel/media.hpp>
|
||||||
#include <turbine/turbine.hpp>
|
#include <turbine/turbine.hpp>
|
||||||
|
|
||||||
#include <studio/context.hpp>
|
#include <studio/context.hpp>
|
||||||
|
#include <studioapp/studioapp.hpp>
|
||||||
#include "studioapp.hpp"
|
#include "studioapp.hpp"
|
||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
@ -61,30 +63,26 @@ static ox::Error runApp(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(
|
int main(
|
||||||
const char *appName,
|
ox::CRStringView appName,
|
||||||
ox::String projectDataDir,
|
ox::String projectDataDir,
|
||||||
int,
|
int,
|
||||||
const char **) {
|
const char**) {
|
||||||
#ifdef DEBUG
|
OX_INIT_DEBUG_LOGGER(loggerConn, appName)
|
||||||
ox::LoggerConn loggerConn;
|
// seed UUID generator
|
||||||
const auto loggerErr = loggerConn.initConn(appName);
|
|
||||||
if (loggerErr) {
|
|
||||||
oxErrf("Could not connect to logger: {}\n", toStr(loggerErr));
|
|
||||||
} else {
|
|
||||||
ox::trace::setLogger(&loggerConn);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ox::trace::init();
|
|
||||||
// run app
|
|
||||||
const auto time = std::time(nullptr);
|
const auto time = std::time(nullptr);
|
||||||
ox::UUID::seedGenerator({
|
ox::UUID::seedGenerator({
|
||||||
static_cast<uint64_t>(time),
|
static_cast<uint64_t>(time),
|
||||||
static_cast<uint64_t>(time << 1)
|
static_cast<uint64_t>(time << 1)
|
||||||
});
|
});
|
||||||
|
// run app
|
||||||
const auto err = runApp(appName, std::move(projectDataDir), ox::UniquePtr<ox::FileSystem>(nullptr));
|
const auto err = runApp(appName, std::move(projectDataDir), ox::UniquePtr<ox::FileSystem>(nullptr));
|
||||||
oxAssert(err, "Something went wrong...");
|
oxAssert(err, "Something went wrong...");
|
||||||
return static_cast<int>(err);
|
return static_cast<int>(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(StudioOptions &&opts, int argc = 0, const char **argv = nullptr) {
|
||||||
|
return main(opts.appName, std::move(opts.projectDataDir), argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ void NewMenu::drawNewItemType(turbine::Context *ctx) noexcept {
|
|||||||
drawWindow(ctx, &m_open, [this] {
|
drawWindow(ctx, &m_open, [this] {
|
||||||
auto items = ox_malloca(m_types.size() * sizeof(const char*), const char*, nullptr);
|
auto items = ox_malloca(m_types.size() * sizeof(const char*), const char*, nullptr);
|
||||||
for (auto i = 0u; const auto &im : m_types) {
|
for (auto i = 0u; const auto &im : m_types) {
|
||||||
items[i] = im->name.c_str();
|
items.get()[i] = im->name.c_str();
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
ImGui::ListBox("Item Type", &m_selectedType, items.get(), static_cast<int>(m_types.size()));
|
ImGui::ListBox("Item Type", &m_selectedType, items.get(), static_cast<int>(m_types.size()));
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
static ox::Result<ox::UniquePtr<ProjectTreeModel>>
|
static ox::Result<ox::UniquePtr<ProjectTreeModel>>
|
||||||
buildProjectTreeModel(ProjectExplorer *explorer, ox::CRStringView name, ox::CRStringView path, ProjectTreeModel *parent) noexcept {
|
buildProjectTreeModel(ProjectExplorer *explorer, ox::String name, ox::CRStringView path, ProjectTreeModel *parent) noexcept {
|
||||||
const auto fs = explorer->romFs();
|
const auto fs = explorer->romFs();
|
||||||
oxRequire(stat, fs->stat(path));
|
oxRequire(stat, fs->stat(path));
|
||||||
auto out = ox::make_unique<ProjectTreeModel>(explorer, name, parent);
|
auto out = ox::make_unique<ProjectTreeModel>(explorer, name, parent);
|
||||||
|
@ -305,7 +305,7 @@ ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
|
|||||||
oxRequireM(fs, keel::loadRomFs(path));
|
oxRequireM(fs, keel::loadRomFs(path));
|
||||||
oxReturnError(keel::setRomFs(&m_ctx->keelCtx, std::move(fs)));
|
oxReturnError(keel::setRomFs(&m_ctx->keelCtx, std::move(fs)));
|
||||||
turbine::setWindowTitle(*m_ctx, ox::sfmt("{} - {}", m_ctx->keelCtx.appName, path));
|
turbine::setWindowTitle(*m_ctx, ox::sfmt("{} - {}", m_ctx->keelCtx.appName, path));
|
||||||
m_project = ox::make_unique<studio::Project>(&m_ctx->keelCtx, path, m_projectDir);
|
m_project = ox::make_unique<studio::Project>(&m_ctx->keelCtx, ox::String(path), m_projectDir);
|
||||||
auto sctx = applicationData<studio::StudioContext>(*m_ctx);
|
auto sctx = applicationData<studio::StudioContext>(*m_ctx);
|
||||||
sctx->project = m_project.get();
|
sctx->project = m_project.get();
|
||||||
m_project->fileAdded.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel);
|
m_project->fileAdded.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel);
|
||||||
@ -313,7 +313,7 @@ ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
|
|||||||
m_openFiles.clear();
|
m_openFiles.clear();
|
||||||
m_editors.clear();
|
m_editors.clear();
|
||||||
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
|
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
|
||||||
config->projectPath = path;
|
config->projectPath = ox::String(path);
|
||||||
config->openFiles.clear();
|
config->openFiles.clear();
|
||||||
});
|
});
|
||||||
return m_projectExplorer->refreshProjectTreeModel();
|
return m_projectExplorer->refreshProjectTreeModel();
|
||||||
@ -324,7 +324,9 @@ ox::Error StudioUI::openFile(ox::CRStringView path) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab) noexcept {
|
ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab) noexcept {
|
||||||
if (m_openFiles.contains(path)) {
|
// Warning: StringView to String
|
||||||
|
auto const pathStr = ox::String(path);
|
||||||
|
if (m_openFiles.contains(pathStr)) {
|
||||||
for (auto &e : m_editors) {
|
for (auto &e : m_editors) {
|
||||||
if (makeActiveTab && e->itemName() == path) {
|
if (makeActiveTab && e->itemName() == path) {
|
||||||
m_activeEditor = e.get();
|
m_activeEditor = e.get();
|
||||||
@ -334,7 +336,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
|||||||
}
|
}
|
||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
oxRequire(ext, studio::fileExt(path));
|
oxRequire(ext, studio::fileExt(path).to<ox::String>([](auto const&v) {return ox::String(v);}));
|
||||||
// create Editor
|
// create Editor
|
||||||
studio::BaseEditor *editor = nullptr;
|
studio::BaseEditor *editor = nullptr;
|
||||||
if (!m_editorMakers.contains(ext)) {
|
if (!m_editorMakers.contains(ext)) {
|
||||||
@ -363,7 +365,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
|||||||
}
|
}
|
||||||
// save to config
|
// save to config
|
||||||
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
|
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
|
||||||
if (!config->openFiles.contains(path)) {
|
if (!config->openFiles.contains(pathStr)) {
|
||||||
config->openFiles.emplace_back(path);
|
config->openFiles.emplace_back(path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -88,10 +88,4 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
ox::Error closeFile(const ox::String &path) noexcept;
|
ox::Error closeFile(const ox::String &path) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(
|
|
||||||
const char *appName,
|
|
||||||
ox::String projectDataDir,
|
|
||||||
[[maybe_unused]] int argc,
|
|
||||||
[[maybe_unused]] const char **argv);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ bool Project::exists(ox::CRStringView path) const noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ox::Vector<ox::String> &Project::fileList(ox::CRStringView ext) noexcept {
|
const ox::Vector<ox::String> &Project::fileList(ox::CRStringView ext) noexcept {
|
||||||
return m_fileExtFileMap[ext];
|
// Warning: StringView to String
|
||||||
|
return m_fileExtFileMap[ox::String(ext)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::buildFileIndex() noexcept {
|
void Project::buildFileIndex() noexcept {
|
||||||
@ -80,7 +81,8 @@ void Project::indexFile(ox::CRStringView path) noexcept {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_fileExtFileMap[ext].emplace_back(path);
|
// Warning: StringView to String
|
||||||
|
m_fileExtFileMap[ox::String(ext)].emplace_back(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff) noexcept {
|
ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff) noexcept {
|
||||||
@ -88,7 +90,8 @@ ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff)
|
|||||||
ox::Buffer outBuff;
|
ox::Buffer outBuff;
|
||||||
outBuff.reserve(buff.size() + HdrSz);
|
outBuff.reserve(buff.size() + HdrSz);
|
||||||
ox::BufferWriter writer(&outBuff);
|
ox::BufferWriter writer(&outBuff);
|
||||||
const auto [uuid, err] = m_ctx->pathToUuid.at(path);
|
// Warning: StringView to String
|
||||||
|
const auto [uuid, err] = m_ctx->pathToUuid.at(ox::String(path));
|
||||||
if (!err) {
|
if (!err) {
|
||||||
oxReturnError(keel::writeUuidHeader(writer, *uuid));
|
oxReturnError(keel::writeUuidHeader(writer, *uuid));
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ void setClipboardText(Context &ctx, ox::CRStringView text) noexcept {
|
|||||||
auto &gctx = static_cast<GlfwContext&>(ctx);
|
auto &gctx = static_cast<GlfwContext&>(ctx);
|
||||||
auto cstr = ox_malloca(text.bytes() + 1, char);
|
auto cstr = ox_malloca(text.bytes() + 1, char);
|
||||||
ox_strncpy(cstr.get(), text.data(), text.bytes());
|
ox_strncpy(cstr.get(), text.data(), text.bytes());
|
||||||
glfwSetClipboardString(gctx.window, cstr);
|
glfwSetClipboardString(gctx.window, cstr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -220,8 +220,9 @@ ox::Error initGfx(Context &ctx) noexcept {
|
|||||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||||
auto cstr = ox_malloca(ctx.keelCtx.appName.bytes() + 1, char);
|
auto cstr = ox_malloca(ctx.keelCtx.appName.bytes() + 1, char);
|
||||||
ox_strncpy(cstr.get(), ctx.keelCtx.appName.data(), ctx.keelCtx.appName.bytes());
|
ox_strncpy(cstr.get(), ctx.keelCtx.appName.data(), ctx.keelCtx.appName.bytes());
|
||||||
constexpr auto Scale = 5;
|
//constexpr auto Scale = 5;
|
||||||
gctx.window = glfwCreateWindow(240 * Scale, 160 * Scale, cstr, nullptr, nullptr);
|
//gctx.window = glfwCreateWindow(240 * Scale, 160 * Scale, cstr, nullptr, nullptr);
|
||||||
|
gctx.window = glfwCreateWindow(868, 741, cstr.get(), nullptr, nullptr);
|
||||||
if (gctx.window == nullptr) {
|
if (gctx.window == nullptr) {
|
||||||
return OxError(1, "Could not open GLFW window");
|
return OxError(1, "Could not open GLFW window");
|
||||||
}
|
}
|
||||||
@ -250,7 +251,7 @@ void setWindowTitle(Context &ctx, ox::CRStringView title) noexcept {
|
|||||||
auto &gctx = glctx(ctx);
|
auto &gctx = glctx(ctx);
|
||||||
auto cstr = ox_malloca(title.bytes() + 1, char);
|
auto cstr = ox_malloca(title.bytes() + 1, char);
|
||||||
ox_strncpy(cstr.get(), title.data(), title.bytes());
|
ox_strncpy(cstr.get(), title.data(), title.bytes());
|
||||||
glfwSetWindowTitle(gctx.window, cstr);
|
glfwSetWindowTitle(gctx.window, cstr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void focusWindow(Context &ctx) noexcept {
|
void focusWindow(Context &ctx) noexcept {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user