[nostalgia/core] Rename core::Color to core::Color16 and add core::Color32

This commit is contained in:
2019-11-27 13:53:41 -06:00
parent 1b08d0f851
commit a9f55ebd02
9 changed files with 30 additions and 24 deletions
+1
View File
@@ -14,6 +14,7 @@ target_link_libraries(
Qt5::Widgets
Qt5::QuickWidgets
NostalgiaStudio
NostalgiaCore
OxFS
OxStd
)
@@ -14,7 +14,7 @@ Rectangle {
anchors.horizontalCenter: tileSheetEditor.horizontalCenter
anchors.verticalCenter: tileSheetEditor.verticalCenter
rows: 2
columns: 3
columns: 2
Repeater {
model: tileGrid.rows * tileGrid.columns
Tile {
+1 -1
View File
@@ -16,7 +16,7 @@ using namespace nostalgia::studio;
namespace nostalgia::core {
QVector<studio::WizardMaker> Plugin::newWizards(const Context *ctx) {
QVector<studio::WizardMaker> Plugin::newWizards(const studio::Context *ctx) {
return {
{
tr("Tile Sheet"),
+5 -15
View File
@@ -12,29 +12,19 @@
#include <QSplitter>
#include <QVBoxLayout>
#include <nostalgia/core/gfx.hpp>
#include "consts.hpp"
#include "tilesheeteditor.hpp"
namespace nostalgia::core {
uint32_t toColor32(Color nc) {
auto r = ((nc & 0b0000000000011111) >> 0) * 8;
auto g = ((nc & 0b0000001111100000) >> 5) * 8;
auto b = ((nc & 0b0111110000000000) >> 10) * 8;
auto a = 255;
return a | (b << 8) | (g << 16) | (r << 24);
}
[[nodiscard]]
QVector<uint32_t> toPixels(const NostalgiaGraphic *ng, const NostalgiaPalette *npal) {
QVector<Color32> toPixels(const NostalgiaGraphic *ng, const NostalgiaPalette *npal) {
if (!npal) {
npal = &ng->pal;
}
QVector<uint32_t> out;
out.reserve(ng->tiles.size() * sizeof(Color));
QVector<Color32> out;
out.reserve(ng->tiles.size() * sizeof(Color16));
if (ng->bpp == 8) {
for (std::size_t i = 0; i < ng->tiles.size(); i++) {
@@ -59,7 +49,7 @@ QVector<uint32_t> toPixels(const NostalgiaGraphic *ng, const NostalgiaPalette *n
}
[[nodiscard]]
QVector<uint32_t> toPixels(const studio::Context *ctx, QString ngPath, QString palPath = "") {
QVector<Color32> toPixels(const studio::Context *ctx, QString ngPath, QString palPath = "") {
auto ng = ctx->project->loadObj<NostalgiaGraphic>(ngPath);
std::unique_ptr<NostalgiaPalette> npal;
if (palPath == "" && ng->defaultPalette.type() == ox::FileAddressType::Path) {
@@ -124,7 +114,7 @@ void TileSheetEditor::saveState() {
void TileSheetEditor::restoreState() {
QSettings settings(m_ctx->orgName, PluginName);
settings.beginGroup("TileSheetEditor/state");
m_splitter->restoreState(settings.value("m_splitter/state").toByteArray());
m_splitter->restoreState(settings.value("m_splitter/state", m_splitter->saveState()).toByteArray());
settings.endGroup();
}
@@ -13,6 +13,7 @@
#include <QTableWidget>
#include <QWidget>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/studio/studio.hpp>
namespace nostalgia::core {
@@ -21,7 +22,7 @@ class SheetData: public QObject {
Q_OBJECT
private:
QVector<uint32_t> m_pixels;
QVector<Color32> m_pixels;
public:
Q_INVOKABLE QString pixel(int index);