[nostalgia] Remove World package
This commit is contained in:
parent
24ea7fee39
commit
b064239ab1
@ -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)
|
||||
|
@ -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()
|
@ -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}
|
||||
)
|
@ -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/";
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace nostalgia::world {
|
||||
|
||||
extern QString PATH_ZONES;
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QPluginLoader>
|
||||
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::world {
|
||||
|
||||
struct NewWorldWizard: public studio::WizardFormPage {
|
||||
|
||||
static const QString FIELD_WORLD_PATH;
|
||||
|
||||
NewWorldWizard(const studio::Context *ctx);
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"module_name": "Nostalgia World"
|
||||
}
|
@ -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*) {
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::world {
|
||||
|
||||
class WorldEditor: public QWidget {
|
||||
|
||||
public:
|
||||
WorldEditor(QString path, const studio::Context *ctx);
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <nostalgia/world/world.hpp>
|
||||
|
||||
#include "consts.hpp"
|
||||
#include "newworldwizard.hpp"
|
||||
#include "worldeditor.hpp"
|
||||
|
||||
#include "worldstudioplugin.hpp"
|
||||
|
||||
namespace nostalgia::world {
|
||||
|
||||
using namespace studio;
|
||||
|
||||
QVector<WizardMaker> WorldEditorPlugin::newWizards(const Context *ctx) {
|
||||
return {
|
||||
{
|
||||
tr("Zone"),
|
||||
[ctx]() -> QVector<QWizardPage*> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QPluginLoader>
|
||||
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
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<studio::WizardMaker> newWizards(const studio::Context *ctx) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -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<std::size_t>(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<std::size_t>(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;
|
||||
}
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/mc/mc.hpp>
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <nostalgia/geo/geo.hpp>
|
||||
|
||||
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<Zone*> m_zones;
|
||||
|
||||
};
|
||||
|
||||
oxModelBegin(Region)
|
||||
oxModelFieldRename(zones, m_zones)
|
||||
oxModelEnd()
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user