/*
 * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#include "ox/std/memory.hpp"
#include "paletteeditor-imgui.hpp"
#include "tilesheeteditor-imgui.hpp"

#include "module.hpp"

namespace nostalgia::core {

ox::Vector<studio::EditorMaker> Module::editors(core::Context *ctx) noexcept {
	return {
		{
			{"ng"},
			[ctx](const ox::String &path) -> ox::Result<studio::BaseEditor*> {
				try {
					return new TileSheetEditorImGui(ctx, path);
				} catch (const ox::Exception &ex) {
					return ex.toError();
				}
			}
		},
		{
			{"npal"},
			[ctx](const ox::String &path) -> ox::Result<studio::BaseEditor*> {
				return PaletteEditorImGui::make(ctx, path);
			}
		}
	};
}

ox::Vector<ox::UniquePtr<studio::ItemMaker>> Module::itemMakers(core::Context*) noexcept {
	ox::Vector<ox::UniquePtr<studio::ItemMaker>> out;
	out.emplace_back(new studio::ItemMakerT<core::TileSheet>("Tile Sheet", "TileSheets", "ng"));
	out.emplace_back(new studio::ItemMakerT<core::Palette>("Palette", "Palettes", "npal"));
	return out;
}

}
