Squashed 'deps/nostalgia/' changes from 5433fd9b..e3675759
e3675759 [olympic/studio] Fix NewMenu not to overwrite existing files or create a file without name 2bc2003c [nostalgia/core/studio] Add key shortcuts for switching Palette pages b31062e6 [nostalgia] Update liccor file e4285bd4 [nostalgia/studio] Tweak background color of TileSheet editor a76638cc [olympic/studio] Make Project::romFS return a reference git-subtree-dir: deps/nostalgia git-subtree-split: e367575974a65633d4ad1e1335b2f24d8d0c2649
This commit is contained in:
@@ -57,7 +57,7 @@ void NewMenu::addItemMaker(ox::UniquePtr<studio::ItemMaker> &&im) noexcept {
|
||||
std::sort(
|
||||
m_types.begin(), m_types.end(),
|
||||
[](ox::UPtr<ItemMaker> const&im1, ox::UPtr<ItemMaker> const&im2) {
|
||||
return im1->name < im2->name;
|
||||
return im1->typeName < im2->typeName;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ void NewMenu::drawNewItemType(turbine::Context &ctx) noexcept {
|
||||
drawWindow(ctx, &m_open, [this] {
|
||||
auto items = ox_malloca(m_types.size() * sizeof(char const*), char const*, nullptr);
|
||||
for (auto i = 0u; auto const&im : m_types) {
|
||||
items.get()[i] = im->name.c_str();
|
||||
items.get()[i] = im->typeName.c_str();
|
||||
++i;
|
||||
}
|
||||
ImGui::ListBox("Item Type", &m_selectedType, items.get(), static_cast<int>(m_types.size()));
|
||||
@@ -115,7 +115,16 @@ void NewMenu::drawLastPageButtons(turbine::Context &ctx) noexcept {
|
||||
}
|
||||
|
||||
void NewMenu::finish(turbine::Context &ctx) noexcept {
|
||||
auto const [path, err] = m_types[static_cast<std::size_t>(m_selectedType)]->write(ctx, m_itemName);
|
||||
if (m_itemName.len() == 0) {
|
||||
return;
|
||||
}
|
||||
auto const sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
||||
auto const&typeMaker = *m_types[static_cast<std::size_t>(m_selectedType)];
|
||||
if (sctx->project->exists(typeMaker.itemPath(m_itemName))) {
|
||||
oxLogError(OxError(1, "New file error: File already exists"));
|
||||
return;
|
||||
}
|
||||
auto const [path, err] = typeMaker.write(ctx, m_itemName);
|
||||
if (err) {
|
||||
oxLogError(err);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user