From b064239ab19764d9b30f84c7ca3307d065c265f9 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 6 Feb 2023 00:18:16 -0600 Subject: [PATCH] [nostalgia] Remove World package --- src/nostalgia/CMakeLists.txt | 1 - src/nostalgia/world/CMakeLists.txt | 23 ------ src/nostalgia/world/studio/CMakeLists.txt | 20 ----- src/nostalgia/world/studio/consts.cpp | 11 --- src/nostalgia/world/studio/consts.hpp | 13 ---- src/nostalgia/world/studio/newworldwizard.cpp | 29 ------- src/nostalgia/world/studio/newworldwizard.hpp | 21 ----- src/nostalgia/world/studio/world-studio.json | 3 - src/nostalgia/world/studio/worldeditor.cpp | 14 ---- src/nostalgia/world/studio/worldeditor.hpp | 18 ----- .../world/studio/worldstudioplugin.cpp | 38 ---------- .../world/studio/worldstudioplugin.hpp | 23 ------ src/nostalgia/world/world.cpp | 47 ------------ src/nostalgia/world/world.hpp | 76 ------------------- 14 files changed, 337 deletions(-) delete mode 100644 src/nostalgia/world/CMakeLists.txt delete mode 100644 src/nostalgia/world/studio/CMakeLists.txt delete mode 100644 src/nostalgia/world/studio/consts.cpp delete mode 100644 src/nostalgia/world/studio/consts.hpp delete mode 100644 src/nostalgia/world/studio/newworldwizard.cpp delete mode 100644 src/nostalgia/world/studio/newworldwizard.hpp delete mode 100644 src/nostalgia/world/studio/world-studio.json delete mode 100644 src/nostalgia/world/studio/worldeditor.cpp delete mode 100644 src/nostalgia/world/studio/worldeditor.hpp delete mode 100644 src/nostalgia/world/studio/worldstudioplugin.cpp delete mode 100644 src/nostalgia/world/studio/worldstudioplugin.hpp delete mode 100644 src/nostalgia/world/world.cpp delete mode 100644 src/nostalgia/world/world.hpp diff --git a/src/nostalgia/CMakeLists.txt b/src/nostalgia/CMakeLists.txt index 8165e929..7683b90b 100644 --- a/src/nostalgia/CMakeLists.txt +++ b/src/nostalgia/CMakeLists.txt @@ -6,7 +6,6 @@ add_subdirectory(core) add_subdirectory(foundation) add_subdirectory(geo) add_subdirectory(scene) -add_subdirectory(world) if(NOSTALGIA_BUILD_PLAYER) add_subdirectory(player) diff --git a/src/nostalgia/world/CMakeLists.txt b/src/nostalgia/world/CMakeLists.txt deleted file mode 100644 index 0570d193..00000000 --- a/src/nostalgia/world/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ - -add_library( - NostalgiaWorld - world.cpp -) - -target_link_libraries( - NostalgiaWorld PUBLIC - NostalgiaCore - OxMetalClaw -) - -#install(TARGETS NostalgiaCommon DESTINATION lib) -install( - FILES - world.hpp - DESTINATION - include/nostalgia/world -) - -if(NOSTALGIA_BUILD_STUDIO) - #add_subdirectory(studio) -endif() diff --git a/src/nostalgia/world/studio/CMakeLists.txt b/src/nostalgia/world/studio/CMakeLists.txt deleted file mode 100644 index 6c3bced9..00000000 --- a/src/nostalgia/world/studio/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ - -add_library( - NostalgiaWorld-Studio OBJECT - consts.cpp - newworldwizard.cpp - worldstudioplugin.cpp - worldeditor.cpp -) - -target_link_libraries( - NostalgiaWorld-Studio - NostalgiaStudio -) - -install( - TARGETS - NostalgiaWorld-Studio - LIBRARY DESTINATION - ${NOSTALGIA_DIST_MODULE} -) diff --git a/src/nostalgia/world/studio/consts.cpp b/src/nostalgia/world/studio/consts.cpp deleted file mode 100644 index 28a62c88..00000000 --- a/src/nostalgia/world/studio/consts.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include "consts.hpp" - -namespace nostalgia::world { - -QString PATH_ZONES = "/World/Zones/"; - -} diff --git a/src/nostalgia/world/studio/consts.hpp b/src/nostalgia/world/studio/consts.hpp deleted file mode 100644 index 8e130035..00000000 --- a/src/nostalgia/world/studio/consts.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -namespace nostalgia::world { - -extern QString PATH_ZONES; - -} diff --git a/src/nostalgia/world/studio/newworldwizard.cpp b/src/nostalgia/world/studio/newworldwizard.cpp deleted file mode 100644 index b263d8cd..00000000 --- a/src/nostalgia/world/studio/newworldwizard.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include "consts.hpp" -#include "newworldwizard.hpp" - -namespace nostalgia::world { - -using namespace studio; - -const QString NewWorldWizard::FIELD_WORLD_PATH = "World.WorldPath"; - -NewWorldWizard::NewWorldWizard(const Context *ctx) { - addLineEdit(tr("&Name:"), FIELD_WORLD_PATH, "", [this, ctx](QString worldName) { - worldName = PATH_ZONES + worldName; - auto exists = ctx->project->exists(worldName); - if (exists) { - this->showValidationError(tr("World already exists: %1").arg(worldName)); - return 1; - } - return 0; - } - ); -} - -} diff --git a/src/nostalgia/world/studio/newworldwizard.hpp b/src/nostalgia/world/studio/newworldwizard.hpp deleted file mode 100644 index ca725501..00000000 --- a/src/nostalgia/world/studio/newworldwizard.hpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -#include - -namespace nostalgia::world { - -struct NewWorldWizard: public studio::WizardFormPage { - - static const QString FIELD_WORLD_PATH; - - NewWorldWizard(const studio::Context *ctx); - -}; - -} diff --git a/src/nostalgia/world/studio/world-studio.json b/src/nostalgia/world/studio/world-studio.json deleted file mode 100644 index c79fd351..00000000 --- a/src/nostalgia/world/studio/world-studio.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "module_name": "Nostalgia World" -} diff --git a/src/nostalgia/world/studio/worldeditor.cpp b/src/nostalgia/world/studio/worldeditor.cpp deleted file mode 100644 index 9e01f669..00000000 --- a/src/nostalgia/world/studio/worldeditor.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include "worldeditor.hpp" - -namespace nostalgia::world { - -using namespace studio; - -WorldEditor::WorldEditor(QString, const Context*) { -} - -} diff --git a/src/nostalgia/world/studio/worldeditor.hpp b/src/nostalgia/world/studio/worldeditor.hpp deleted file mode 100644 index 79b7ecce..00000000 --- a/src/nostalgia/world/studio/worldeditor.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -namespace nostalgia::world { - -class WorldEditor: public QWidget { - - public: - WorldEditor(QString path, const studio::Context *ctx); - -}; - -} diff --git a/src/nostalgia/world/studio/worldstudioplugin.cpp b/src/nostalgia/world/studio/worldstudioplugin.cpp deleted file mode 100644 index 3e858216..00000000 --- a/src/nostalgia/world/studio/worldstudioplugin.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include - -#include "consts.hpp" -#include "newworldwizard.hpp" -#include "worldeditor.hpp" - -#include "worldstudioplugin.hpp" - -namespace nostalgia::world { - -using namespace studio; - -QVector WorldEditorPlugin::newWizards(const Context *ctx) { - return { - { - tr("Zone"), - [ctx]() -> QVector { - return {new NewWorldWizard(ctx)}; - }, - [ctx](QWizard *w) { - qDebug() << "creating Region"; - auto path = PATH_ZONES + w->field(NewWorldWizard::FIELD_WORLD_PATH).toString(); - Region rgn; - ctx->project->mkdir(PATH_ZONES); - ctx->project->writeObj(path, &rgn); - return OxError(0); - } - } - }; -} - -} diff --git a/src/nostalgia/world/studio/worldstudioplugin.hpp b/src/nostalgia/world/studio/worldstudioplugin.hpp deleted file mode 100644 index 30536638..00000000 --- a/src/nostalgia/world/studio/worldstudioplugin.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -#include - -namespace nostalgia::world { - -class WorldEditorPlugin: public QObject, public studio::Module { - Q_OBJECT - Q_PLUGIN_METADATA(IID "net.drinkingtea.nostalgia.world.studio.Module" FILE "world-studio.json") - Q_INTERFACES(nostalgia::studio::Module) - - public: - QVector newWizards(const studio::Context *ctx) override; - -}; - -} diff --git a/src/nostalgia/world/world.cpp b/src/nostalgia/world/world.cpp deleted file mode 100644 index fad04513..00000000 --- a/src/nostalgia/world/world.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include "world.hpp" - -namespace nostalgia::world { - -using namespace geo; -using namespace core; - -ox::Error Zone::init(Context *ctx, Bounds bnds, ox::FileAddress tileSheet, ox::FileAddress palette) { - const auto size = static_cast(bnds.width * bnds.height); - m_tiles = new Tile[size]; - m_bounds = bnds; - return core::loadBgTileSheet(ctx, 0, tileSheet, palette); -} - -Zone::~Zone() { - ox::safeDeleteArray(m_tiles); -} - -void Zone::draw(Context *ctx) { - for (int x = 0; x < m_bounds.width; x++) { - for (int y = 0; y < m_bounds.height; y++) { - auto t = tile(x, y); - core::setTile(ctx, 0, x * 2, y * 2, t->bgTile); - core::setTile(ctx, 0, x * 2 + 1, y * 2, t->bgTile + 1); - core::setTile(ctx, 0, x * 2 + 1, y * 2 + 1, t->bgTile + 2); - core::setTile(ctx, 0, x * 2, y * 2 + 1, t->bgTile + 3); - } - } -} - -std::size_t Zone::size() { - return sizeof(Zone) + static_cast(m_bounds.width * m_bounds.height) * sizeof(Tile); -} - -Tile *Zone::tile(int x, int y) { - return &m_tiles[x * m_bounds.width + y]; -} - -void Zone::setTile(int x, int y, Tile *td) { - m_tiles[x * m_bounds.width + y] = *td; -} - -} diff --git a/src/nostalgia/world/world.hpp b/src/nostalgia/world/world.hpp deleted file mode 100644 index cb642569..00000000 --- a/src/nostalgia/world/world.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include -#include - -#include -#include - -namespace nostalgia::world { - -struct Tile { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.world.Tile"; - static constexpr auto TypeVersion = 1; - - uint8_t bgTile = 0; - uint8_t type = 0; -}; - -oxModelBegin(Tile) - oxModelField(bgTile) - oxModelField(type) -oxModelEnd() - - -struct Zone { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.world.Zone"; - static constexpr auto TypeVersion = 2; - - oxModelFriend(Zone); - - protected: - geo::Bounds m_bounds; - Tile *m_tiles = nullptr; - - public: - Zone() = default; - - ~Zone(); - - ox::Error init(core::Context *ctx, geo::Bounds bnds, ox::FileAddress tileSheet, ox::FileAddress palette = {}); - - void draw(core::Context *ctx); - - std::size_t size(); - - Tile *tile(int x, int y); - - void setTile(int x, int y, Tile *td); - -}; - -oxModelBegin(Zone) - oxModelFieldRename(bounds, m_bounds) -oxModelEnd() - -struct Region { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.world.Region"; - static constexpr auto TypeVersion = 1; - - oxModelFriend(Region); - - protected: - ox::Vector m_zones; - -}; - -oxModelBegin(Region) - oxModelFieldRename(zones, m_zones) -oxModelEnd() - - -}