APP: moved into app namespace

master
Martin Gerhardy 2020-08-30 22:46:21 +02:00
parent fccc6d17f0
commit e6a8427ee4
169 changed files with 708 additions and 708 deletions

View File

@ -115,8 +115,8 @@ void Client::onEvent(const voxelworld::WorldCreatedEvent& event) {
pushWindow("hud");
}
core::AppState Client::onConstruct() {
core::AppState state = Super::onConstruct();
app::AppState Client::onConstruct() {
app::AppState state = Super::onConstruct();
_soundManager->construct();
_volumeCache->construct();
@ -157,7 +157,7 @@ core::AppState Client::onConstruct() {
#define regHandler(type, handler, ...) \
r->registerHandler(network::EnumNameServerMsgType(type), std::make_shared<handler>(__VA_ARGS__));
core::AppState Client::onInit() {
app::AppState Client::onInit() {
eventBus()->subscribe<network::NewConnectionEvent>(*this);
eventBus()->subscribe<network::DisconnectEvent>(*this);
eventBus()->subscribe<voxelworld::WorldCreatedEvent>(*this);
@ -174,8 +174,8 @@ core::AppState Client::onInit() {
regHandler(network::ServerMsgType::VarUpdate, VarUpdateHandler);
regHandler(network::ServerMsgType::UserInfo, UserInfoHandler);
core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
@ -185,34 +185,34 @@ core::AppState Client::onInit() {
if (!_meshCache->init()) {
Log::error("Failed to initialize mesh cache");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_network->init()) {
Log::error("Failed to initialize network layer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_movement.init()) {
Log::error("Failed to initialize movement controller");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_action.init()) {
Log::error("Failed to initialize action controller");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_stockDataProvider->init(filesystem()->load("stock.lua"))) {
Log::error("Failed to initialize stock data provider: %s", _stockDataProvider->error().c_str());
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_camera.init(glm::ivec2(0), frameBufferDimension(), windowDimension());
if (!_animationCache->init()) {
Log::error("Failed to initialize character cache");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_soundManager->init()) {
@ -221,32 +221,32 @@ core::AppState Client::onInit() {
if (!voxel::initDefaultMaterialColors()) {
Log::error("Failed to initialize the palette data");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_volumeCache->init()) {
Log::error("Failed to initialize volume cache");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_worldMgr->init()) {
Log::error("Failed to initialize world manager");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_floorResolver.init(_worldMgr)) {
Log::error("Failed to initialize floor resolver");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_clientPager->init(_chunkUrl->strVal())) {
Log::error("Failed to initialize client pager");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_worldRenderer.init(_worldMgr->volumeData(), glm::ivec2(0), frameBufferDimension())) {
Log::error("Failed to initialize world renderer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
rootWindow("main");
@ -319,7 +319,7 @@ void Client::sendVars() const {
network::CreateVarUpdate(fbb, fbbVars).Union());
}
core::AppState Client::onCleanup() {
app::AppState Client::onCleanup() {
Log::info("shutting down the client");
eventBus()->unsubscribe<network::NewConnectionEvent>(*this);
eventBus()->unsubscribe<network::DisconnectEvent>(*this);
@ -353,8 +353,8 @@ core::AppState Client::onCleanup() {
return Super::onCleanup();
}
core::AppState Client::onRunning() {
const core::AppState state = Super::onRunning();
app::AppState Client::onRunning() {
const app::AppState state = Super::onRunning();
if (_network->isConnected()) {
const float pitch = _mouseRelativePos.y;
const float turn = _mouseRelativePos.x;
@ -362,7 +362,7 @@ core::AppState Client::onRunning() {
sendMovement();
sendTriggerAction();
}
if (state == core::AppState::Running) {
if (state == app::AppState::Running) {
_network->update();
_soundManager->update();
}

View File

@ -81,10 +81,10 @@ public:
const audio::SoundManagerPtr& soundManager);
~Client();
core::AppState onConstruct() override;
core::AppState onInit() override;
core::AppState onRunning() override;
core::AppState onCleanup() override;
app::AppState onConstruct() override;
app::AppState onInit() override;
app::AppState onRunning() override;
app::AppState onCleanup() override;
void onWindowResize(int windowWidth, int windowHeight) override;
client::CooldownHandler& cooldownHandler();

View File

@ -12,7 +12,7 @@
#include "animation/LUAAnimation.h"
class AnimationBenchmark: public core::AbstractBenchmark {
class AnimationBenchmark: public app::AbstractBenchmark {
};
#define CHR_ANIM_BENCHMARK_DEFINE_F(name) \

View File

@ -37,7 +37,7 @@ function init()
end
)";
class CharacterSettingsTest: public core::AbstractTest {
class CharacterSettingsTest: public app::AbstractTest {
};
TEST_F(CharacterSettingsTest, testLUA) {

View File

@ -12,7 +12,7 @@
namespace animation {
class LUAAnimationTest: public core::AbstractTest {
class LUAAnimationTest: public app::AbstractTest {
protected:
void exec(const char *scriptName, const char *animation) {
const core::String& script = io::filesystem()->load("%s", scriptName);

View File

@ -10,7 +10,7 @@
namespace animation {
class SkeletonTest: public core::AbstractTest {
class SkeletonTest: public app::AbstractTest {
protected:
void test(const char *file) {
CharacterSkeleton skel;

View File

@ -27,7 +27,7 @@
#endif
#include <signal.h>
namespace core {
namespace app {
static void catch_function(int signo) {
core_stacktrace();
@ -200,7 +200,7 @@ void App::onFrame() {
}
AppState App::onConstruct() {
VarPtr logVar = core::Var::get(cfg::CoreLogLevel, _initialLogLevel);
core::VarPtr logVar = core::Var::get(cfg::CoreLogLevel, _initialLogLevel);
// this ensures that we are sleeping 1 millisecond if there is enough room for it
_framesPerSecondsCap = core::Var::get(cfg::CoreMaxFPS, "1000.0");
registerArg("--loglevel").setShort("-l").setDescription("Change log level from 1 (trace) to 6 (only critical)");
@ -244,7 +244,7 @@ AppState App::onConstruct() {
core::String var = _argv[i + 1];
const char *value = _argv[i + 2];
i += 2;
core::Var::get(var, value, CV_FROMCOMMANDLINE);
core::Var::get(var, value, core::CV_FROMCOMMANDLINE);
Log::debug("Set %s to %s", var.c_str(), value);
}
}
@ -316,20 +316,20 @@ AppState App::onInit() {
break;
}
const core::String& flags = t.next();
uint32_t flagsMaskFromFile = CV_FROMFILE;
uint32_t flagsMaskFromFile = core::CV_FROMFILE;
for (char c : flags) {
if (c == 'R') {
flagsMaskFromFile |= CV_READONLY;
flagsMaskFromFile |= core::CV_READONLY;
Log::debug("read only flag for %s", name.c_str());
} else if (c == 'S') {
flagsMaskFromFile |= CV_SHADER;
flagsMaskFromFile |= core::CV_SHADER;
Log::debug("shader flag for %s", name.c_str());
} else if (c == 'X') {
flagsMaskFromFile |= CV_SECRET;
flagsMaskFromFile |= core::CV_SECRET;
Log::debug("secret flag for %s", name.c_str());
}
}
const VarPtr& old = core::Var::get(name);
const core::VarPtr& old = core::Var::get(name);
int32_t flagsMask;
if (old) {
flagsMask = (int32_t)(flagsMaskFromFile | old->getFlags());
@ -337,7 +337,7 @@ AppState App::onInit() {
flagsMask = (int32_t)(flagsMaskFromFile);
}
flagsMask &= ~(CV_FROMCOMMANDLINE | CV_FROMENV);
flagsMask &= ~(core::CV_FROMCOMMANDLINE | core::CV_FROMENV);
core::Var::get(name, value.c_str(), flagsMask);
}
@ -375,7 +375,7 @@ void App::onAfterInit() {
// already handled
continue;
}
if (Command::getCommand(command) == nullptr) {
if (core::Command::getCommand(command) == nullptr) {
continue;
}
core::String args;
@ -394,7 +394,7 @@ void App::onAfterInit() {
const core::String& autoexecCommands = filesystem()->load("autoexec.cfg");
if (!autoexecCommands.empty()) {
Log::debug("execute autoexec.cfg");
Command::execute(autoexecCommands);
core::Command::execute(autoexecCommands);
} else {
Log::debug("skip autoexec.cfg");
}
@ -402,7 +402,7 @@ void App::onAfterInit() {
const core::String& autoexecAppCommands = filesystem()->load("%s-autoexec.cfg", _appname.c_str());
if (!autoexecAppCommands.empty()) {
Log::debug("execute %s-autoexec.cfg", _appname.c_str());
Command::execute(autoexecAppCommands);
core::Command::execute(autoexecAppCommands);
}
// we might have changed the loglevel from the commandline
@ -452,16 +452,16 @@ void App::usage() const {
const uint32_t flags = v->getFlags();
core::String flagsStr = " ";
const char *value = v->strVal().c_str();
if ((flags & CV_READONLY) != 0) {
if ((flags & core::CV_READONLY) != 0) {
flagsStr[0] = 'R';
}
if ((flags & CV_NOPERSIST) != 0) {
if ((flags & core::CV_NOPERSIST) != 0) {
flagsStr[1] = 'N';
}
if ((flags & CV_SHADER) != 0) {
if ((flags & core::CV_SHADER) != 0) {
flagsStr[2] = 'S';
}
if ((flags & CV_SECRET) != 0) {
if ((flags & core::CV_SECRET) != 0) {
flagsStr[3] = 'X';
value = "***secret***";
}
@ -595,13 +595,13 @@ AppState App::onCleanup() {
const uint32_t flags = var->getFlags();
core::String flagsStr;
const char *value = var->strVal().c_str();
if ((flags & CV_READONLY) == CV_READONLY) {
if ((flags & core::CV_READONLY) == core::CV_READONLY) {
flagsStr.append("R");
}
if ((flags & CV_SHADER) == CV_SHADER) {
if ((flags & core::CV_SHADER) == core::CV_SHADER) {
flagsStr.append("S");
}
if ((flags & CV_SECRET) == CV_SECRET) {
if ((flags & core::CV_SECRET) == core::CV_SECRET) {
flagsStr.append("X");
}
ss += "\"";

View File

@ -26,14 +26,12 @@ class Metric;
using MetricPtr = std::shared_ptr<Metric>;
class IMetricSender;
using IMetricSenderPtr = std::shared_ptr<IMetricSender>;
}
/**
* Foundation classes
*/
namespace core {
class ThreadPool;
typedef std::shared_ptr<ThreadPool> ThreadPoolPtr;
@ -45,7 +43,9 @@ typedef std::shared_ptr<EventBus> EventBusPtr;
class TimeProvider;
typedef std::shared_ptr<TimeProvider> TimeProviderPtr;
}
namespace app {
enum class AppState : uint8_t {
Construct,
Init,
@ -319,7 +319,7 @@ inline AppState App::state() const {
namespace io {
inline io::FilesystemPtr filesystem() {
return core::App::getInstance()->filesystem();
return app::App::getInstance()->filesystem();
}
}

View File

@ -11,7 +11,7 @@
#include "core/Var.h"
#include <inttypes.h>
namespace core {
namespace app {
namespace AppCommand {
@ -21,7 +21,7 @@ void init(const core::TimeProviderPtr& timeProvider) {
Log::error("not enough arguments given. Expecting a variable name");
return;
}
const VarPtr& st = core::Var::get(args[0]);
const core::VarPtr& st = core::Var::get(args[0]);
if (st) {
st->clearHistory();
}
@ -115,7 +115,7 @@ void init(const core::TimeProviderPtr& timeProvider) {
Log::error("not enough arguments given. Expecting a variable name");
return;
}
const VarPtr& st = core::Var::get(args[0]);
const core::VarPtr& st = core::Var::get(args[0]);
if (st) {
Log::info(" -> %s ", st->strVal().c_str());
} else {
@ -208,16 +208,16 @@ void init(const core::TimeProviderPtr& timeProvider) {
const uint32_t flags = var->getFlags();
core::String flagsStr = " ";
const char *value = var->strVal().c_str();
if ((flags & CV_READONLY) != 0) {
if ((flags & core::CV_READONLY) != 0) {
flagsStr[0] = 'R';
}
if ((flags & CV_NOPERSIST) != 0) {
if ((flags & core::CV_NOPERSIST) != 0) {
flagsStr[1] = 'N';
}
if ((flags & CV_SHADER) != 0) {
if ((flags & core::CV_SHADER) != 0) {
flagsStr[2] = 'S';
}
if ((flags & CV_SECRET) != 0) {
if ((flags & core::CV_SECRET) != 0) {
flagsStr[3] = 'X';
value = "***secret***";
}

View File

@ -6,7 +6,7 @@
#include "core/TimeProvider.h"
namespace core {
namespace app {
namespace AppCommand {
extern void init(const core::TimeProviderPtr& timeProvider);
}

View File

@ -5,7 +5,7 @@
#include "CommandlineApp.h"
#include "core/Var.h"
namespace core {
namespace app {
CommandlineApp::CommandlineApp(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider, size_t threadPoolSize) :
Super(metric, filesystem, eventBus, timeProvider, threadPoolSize) {
@ -15,7 +15,7 @@ CommandlineApp::~CommandlineApp() {
}
AppState CommandlineApp::onConstruct() {
const core::AppState state = Super::onConstruct();
const app::AppState state = Super::onConstruct();
registerArg("--trace").setDescription("Change log level to trace");
registerArg("--debug").setDescription("Change log level to debug");

View File

@ -9,16 +9,16 @@
#include "core/EventBus.h"
#include "metric/Metric.h"
namespace core {
namespace app {
class CommandlineApp : public core::App {
class CommandlineApp : public app::App {
private:
using Super = core::App;
using Super = app::App;
public:
CommandlineApp(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider, size_t threadPoolSize = 1);
virtual ~CommandlineApp();
virtual core::AppState onConstruct() override;
virtual app::AppState onConstruct() override;
};
}

View File

@ -12,7 +12,7 @@
#include <SDL.h>
namespace core {
namespace app {
SDL_AssertState Test_AssertionHandler(const SDL_AssertData* data, void* userdata) {
return SDL_ASSERTION_BREAK;
@ -51,7 +51,7 @@ AppState AbstractBenchmark::BenchmarkApp::onCleanup() {
AppState AbstractBenchmark::BenchmarkApp::onInit() {
AppState state = Super::onInit();
if (state != core::AppState::Running) {
if (state != app::AppState::Running) {
return state;
}

View File

@ -10,21 +10,21 @@
#include "core/EventBus.h"
#include "core/TimeProvider.h"
namespace core {
namespace app {
class AbstractBenchmark : public benchmark::Fixture {
private:
class BenchmarkApp: public core::CommandlineApp {
class BenchmarkApp: public app::CommandlineApp {
friend class AbstractBenchmark;
protected:
using Super = core::CommandlineApp;
using Super = app::CommandlineApp;
AbstractBenchmark* _benchmark = nullptr;
public:
BenchmarkApp(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider, AbstractBenchmark* benchmark);
virtual ~BenchmarkApp();
virtual core::AppState onInit() override;
virtual core::AppState onCleanup() override;
virtual app::AppState onInit() override;
virtual app::AppState onCleanup() override;
};
protected:

View File

@ -14,7 +14,7 @@
extern char **_argv;
extern int _argc;
namespace core {
namespace app {
core::String AbstractTest::fileToString(const core::String& filename) const {
const io::FilesystemPtr& fs = _testApp->filesystem();
@ -62,7 +62,7 @@ AppState AbstractTest::TestApp::onCleanup() {
AppState AbstractTest::TestApp::onInit() {
AppState state = Super::onInit();
if (state != core::AppState::Running) {
if (state != app::AppState::Running) {
return state;
}

View File

@ -7,22 +7,22 @@
#include "core/tests/TestHelper.h"
#include "app/CommandlineApp.h"
namespace core {
namespace app {
class AbstractTest: public testing::Test {
private:
class TestApp: public core::CommandlineApp {
class TestApp: public app::CommandlineApp {
friend class AbstractTest;
private:
using Super = core::CommandlineApp;
using Super = app::CommandlineApp;
protected:
AbstractTest* _test = nullptr;
public:
TestApp(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider, AbstractTest* test);
virtual ~TestApp();
core::AppState onInit() override;
core::AppState onCleanup() override;
app::AppState onInit() override;
app::AppState onCleanup() override;
};
protected:

View File

@ -9,7 +9,7 @@
#include "core/EventBus.h"
#include "core/TimeProvider.h"
namespace core {
namespace app {
TEST(AppTest, testLifecycleManual) {
const metric::MetricPtr metric = std::make_shared<metric::Metric>();
@ -17,10 +17,10 @@ TEST(AppTest, testLifecycleManual) {
const core::EventBusPtr eventBus = std::make_shared<core::EventBus>();
const core::TimeProviderPtr timeProvider = std::make_shared<core::TimeProvider>();
App app(metric, filesystem, eventBus, timeProvider);
ASSERT_EQ(core::AppState::Init, app.onConstruct());
ASSERT_EQ(core::AppState::Running, app.onInit());
ASSERT_EQ(core::AppState::Cleanup, app.onRunning());
ASSERT_EQ(core::AppState::Destroy, app.onCleanup());
ASSERT_EQ(app::AppState::Init, app.onConstruct());
ASSERT_EQ(app::AppState::Running, app.onInit());
ASSERT_EQ(app::AppState::Cleanup, app.onRunning());
ASSERT_EQ(app::AppState::Destroy, app.onCleanup());
}
TEST(AppTest, testLifecycleOnFrame) {
@ -30,15 +30,15 @@ TEST(AppTest, testLifecycleOnFrame) {
const core::TimeProviderPtr timeProvider = std::make_shared<core::TimeProvider>();
App app(metric, filesystem, eventBus, timeProvider);
app.onFrame();
ASSERT_EQ(core::AppState::Construct, app.state());
ASSERT_EQ(app::AppState::Construct, app.state());
app.onFrame();
ASSERT_EQ(core::AppState::Init, app.state());
ASSERT_EQ(app::AppState::Init, app.state());
app.onFrame();
ASSERT_EQ(core::AppState::Running, app.state());
ASSERT_EQ(app::AppState::Running, app.state());
app.onFrame();
ASSERT_EQ(core::AppState::Cleanup, app.state());
ASSERT_EQ(app::AppState::Cleanup, app.state());
app.onFrame();
ASSERT_EQ(core::AppState::InvalidAppState, app.state());
ASSERT_EQ(app::AppState::InvalidAppState, app.state());
}
}

View File

@ -7,9 +7,9 @@
#include "io/Filesystem.h"
#include "core/tests/TestHelper.h"
namespace core {
namespace app {
class CommandCompleterTest: public core::AbstractTest {
class CommandCompleterTest: public app::AbstractTest {
public:
bool onInitApp() override{
const io::FilesystemPtr& fs = io::filesystem();
@ -28,7 +28,7 @@ public:
};
TEST_F(CommandCompleterTest, testComplete) {
auto func = fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
auto func = core::fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
core::DynamicArray<core::String> matches;
ASSERT_EQ(5, func("", matches)) << toString(matches);
EXPECT_EQ("dir1/", matches[0]) << toString(matches);
@ -39,7 +39,7 @@ TEST_F(CommandCompleterTest, testComplete) {
}
TEST_F(CommandCompleterTest, testCompleteOnlyFiles) {
auto func = fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
auto func = core::fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
core::DynamicArray<core::String> matches;
ASSERT_EQ(4, func("f", matches)) << toString(matches);
EXPECT_EQ("foo1.foo", matches[0]) << toString(matches);
@ -49,21 +49,21 @@ TEST_F(CommandCompleterTest, testCompleteOnlyFiles) {
}
TEST_F(CommandCompleterTest, testCompleteSubdir) {
auto func = fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
auto func = core::fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
core::DynamicArray<core::String> matches;
ASSERT_EQ(1, func("dir1", matches)) << toString(matches);
EXPECT_EQ("dir1/", matches[0]) << toString(matches);
}
TEST_F(CommandCompleterTest, testCompleteSubdirFile) {
auto func = fileCompleter(io::filesystem(), "commandcompletertest/dir1/", "*.foo");
auto func = core::fileCompleter(io::filesystem(), "commandcompletertest/dir1/", "*.foo");
core::DynamicArray<core::String> matches;
ASSERT_EQ(1, func("f", matches)) << toString(matches);
EXPECT_EQ("foo1.foo", matches[0]) << toString(matches);
}
TEST_F(CommandCompleterTest, testCompleteSubdirFile2) {
auto func = fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
auto func = core::fileCompleter(io::filesystem(), "commandcompletertest/", "*.foo");
core::DynamicArray<core::String> matches;
ASSERT_EQ(1, func("dir1/f", matches)) << toString(matches);
EXPECT_EQ("dir1/foo1.foo", matches[0]) << toString(matches);

View File

@ -7,7 +7,7 @@
namespace attrib {
class AttributesTest: public core::AbstractTest {
class AttributesTest: public app::AbstractTest {
};
TEST_F(AttributesTest, testCurrents) {

View File

@ -25,7 +25,7 @@ end
namespace attrib {
class ContainerProviderTest: public core::AbstractTest {
class ContainerProviderTest: public app::AbstractTest {
};
TEST_F(ContainerProviderTest, testLoadingSuccess) {

View File

@ -62,14 +62,14 @@ bool ServerLoop::addTimer(uv_timer_t* timer, uv_timer_cb cb, uint64_t repeatMill
void ServerLoop::signalCallback(uv_signal_t* handle, int signum) {
if (signum == SIGHUP) {
core::App::getInstance()->requestQuit();
app::App::getInstance()->requestQuit();
return;
}
if (signum == SIGINT) {
//ServerLoop* loop = (ServerLoop*)handle->data;
// TODO: only quit if this was hit twice in under 2 seconds
core::App::getInstance()->requestQuit();
app::App::getInstance()->requestQuit();
return;
}
}
@ -356,7 +356,7 @@ bool ServerLoop::init() {
const ServerLoop* loop = (const ServerLoop*)handle->data;
const long dt = handle->repeat;
const persistence::PersistenceMgrPtr& persistenceMgr = loop->_persistenceMgr;
core::App::getInstance()->threadPool().enqueue([=] () {
app::App::getInstance()->threadPool().enqueue([=] () {
persistenceMgr->update(dt);
});
}, 10000);

View File

@ -16,11 +16,11 @@
namespace backend {
class ConnectTest:
public core::AbstractTest,
public app::AbstractTest,
public core::IEventBusHandler<network::NewConnectionEvent>,
public core::IEventBusHandler<network::DisconnectEvent> {
private:
using Super = core::AbstractTest;
using Super = app::AbstractTest;
protected:
core::EventBusPtr _clientEventBus;
core::EventBusPtr _serverEventBus;

View File

@ -48,9 +48,9 @@ end)";
}
class EntityTest: public core::AbstractTest {
class EntityTest: public app::AbstractTest {
private:
using Super = core::AbstractTest;
using Super = app::AbstractTest;
protected:
EntityStoragePtr entityStorage;
network::ProtocolHandlerRegistryPtr protocolHandlerRegistry;

View File

@ -20,7 +20,7 @@
namespace backend {
class MapProviderTest: public core::AbstractTest {
class MapProviderTest: public app::AbstractTest {
public:
EntityStoragePtr _entityStorage;
network::ProtocolHandlerRegistryPtr _protocolHandlerRegistry;
@ -36,7 +36,7 @@ public:
persistence::DBHandlerPtr _dbHandler;
void SetUp() override {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
core::Var::get(cfg::ServerSeed, "1");
core::Var::get(cfg::VoxelMeshSize, "16", core::CV_READONLY);
voxel::initDefaultMaterialColors();
@ -74,7 +74,7 @@ public:
_persistenceMgr.reset();
_dbHandler.reset();
core::AbstractTest::TearDown();
app::AbstractTest::TearDown();
}
};

View File

@ -18,7 +18,7 @@
namespace backend {
class MapTest: public core::AbstractTest {
class MapTest: public app::AbstractTest {
public:
EntityStoragePtr _entityStorage;
network::ProtocolHandlerRegistryPtr _protocolHandlerRegistry;
@ -32,7 +32,7 @@ public:
persistence::DBHandlerPtr _dbHandler;
void SetUp() override {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
core::Var::get(cfg::ServerSeed, "1");
core::Var::get(cfg::VoxelMeshSize, "16", core::CV_READONLY);
voxel::initDefaultMaterialColors();
@ -69,7 +69,7 @@ public:
_persistenceMgr.reset();
_dbHandler.reset();
core::AbstractTest::TearDown();
app::AbstractTest::TearDown();
}
};

View File

@ -2,10 +2,10 @@
#include "backend/entity/ai/common/Random.h"
void TestSuite::SetUp() {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
backend::randomSeed(0);
}
void TestSuite::TearDown() {
core::AbstractTest::TearDown();
app::AbstractTest::TearDown();
}

View File

@ -29,7 +29,7 @@ inline bool operator==(const glm::vec3 &vecA, const glm::vec3 &vecB) {
return fabs(vecA[0] - vecB[0]) < epsilion && fabs(vecA[1] - vecB[1]) < epsilion && fabs(vecA[2] - vecB[2]) < epsilion;
}
class TestSuite: public core::AbstractTest {
class TestSuite: public app::AbstractTest {
protected:
backend::LUAAIRegistry _registry;
backend::GroupMgr _groupManager;

View File

@ -20,7 +20,7 @@
namespace backend {
class WorldTest: public core::AbstractTest {
class WorldTest: public app::AbstractTest {
public:
EntityStoragePtr _entityStorage;
network::ProtocolHandlerRegistryPtr _protocolHandlerRegistry;
@ -36,7 +36,7 @@ public:
http::HttpServerPtr _httpServer;
void SetUp() override {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
core::Var::get(cfg::ServerSeed, "1");
core::Var::get(cfg::VoxelMeshSize, "16", core::CV_READONLY);
voxel::initDefaultMaterialColors();
@ -80,7 +80,7 @@ public:
_persistenceMgr.reset();
_mapProvider.reset();
core::AbstractTest::TearDown();
app::AbstractTest::TearDown();
}
};

View File

@ -7,7 +7,7 @@
namespace lua {
class LUAFunctionsTest : public core::AbstractTest {
class LUAFunctionsTest : public app::AbstractTest {
};
TEST_F(LUAFunctionsTest, testVectorCtor) {

View File

@ -7,9 +7,9 @@
namespace compute {
class ComputeShaderTest: public core::AbstractTest {
class ComputeShaderTest: public app::AbstractTest {
private:
using Super = core::AbstractTest;
using Super = app::AbstractTest;
protected:
bool _supported = false;
public:

View File

@ -13,30 +13,30 @@ CursesApp::CursesApp(const metric::MetricPtr& metric, const io::FilesystemPtr& f
CursesApp::~CursesApp() {
}
core::AppState CursesApp::onConstruct() {
const core::AppState state = Super::onConstruct();
app::AppState CursesApp::onConstruct() {
const app::AppState state = Super::onConstruct();
_console.construct();
return state;
}
core::AppState CursesApp::onInit() {
const core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
app::AppState CursesApp::onInit() {
const app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
if (!_console.init()) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
return state;
}
core::AppState CursesApp::onCleanup() {
app::AppState CursesApp::onCleanup() {
_console.shutdown();
return Super::onCleanup();
}
core::AppState CursesApp::onRunning() {
const core::AppState state = Super::onRunning();
app::AppState CursesApp::onRunning() {
const app::AppState state = Super::onRunning();
_console.update(_deltaFrameSeconds);
return state;
}

View File

@ -7,19 +7,19 @@
namespace console {
class CursesApp : public core::CommandlineApp {
class CursesApp : public app::CommandlineApp {
private:
using Super = core::CommandlineApp;
using Super = app::CommandlineApp;
CursesConsole _console;
public:
CursesApp(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider, size_t threadPoolSize = 1);
virtual ~CursesApp();
core::AppState onConstruct() override;
core::AppState onInit() override;
core::AppState onCleanup() override;
core::AppState onRunning() override;
app::AppState onConstruct() override;
app::AppState onInit() override;
app::AppState onCleanup() override;
app::AppState onRunning() override;
};
}

View File

@ -11,7 +11,7 @@
namespace cooldown {
class CooldownMgrTest : public core::AbstractTest {
class CooldownMgrTest : public app::AbstractTest {
protected:
core::TimeProviderPtr _timeProvider;
cooldown::CooldownProviderPtr _cooldownProvider;
@ -24,7 +24,7 @@ public:
}
void SetUp() override {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
const core::String& cooldowns = io::filesystem()->load("cooldowns.lua");
_cooldownProvider->init(cooldowns);
}

View File

@ -8,7 +8,7 @@
namespace cooldown {
class CooldownDurationTest : public core::AbstractTest {
class CooldownDurationTest : public app::AbstractTest {
};
TEST_F(CooldownDurationTest, testLoading) {

View File

@ -12,7 +12,7 @@
namespace core {
// a singleton - available via core::App
// a singleton - available via app::App
class Trace {
public:
Trace();

View File

@ -4,7 +4,7 @@
#include <unordered_map>
#include <map>
class MapBenchmark: public core::AbstractBenchmark {
class MapBenchmark: public app::AbstractBenchmark {
};
BENCHMARK_DEFINE_F(MapBenchmark, compareToMapStd) (benchmark::State& state) {

View File

@ -237,7 +237,7 @@ void HttpServer::assembleError(Client& client, HttpStatus status) {
"\r\n",
(int)status,
toStatusString(status),
core::App::getInstance()->appname().c_str());
app::App::getInstance()->appname().c_str());
const char *errorPage = "";
_errorPages.get((int)status, errorPage);
@ -341,7 +341,7 @@ bool HttpServer::route(const RequestParser& request, HttpResponse& response) {
}
response.headers.put(header::CONTENT_TYPE, http::mimetype::TEXT_PLAIN);
response.headers.put(header::CONNECTION, "close");
response.headers.put(header::SERVER, core::App::getInstance()->appname().c_str());
response.headers.put(header::SERVER, app::App::getInstance()->appname().c_str());
// TODO urldecode of request data
//core::string::urlDecode(request.query);
i->value(request, &response);

View File

@ -14,7 +14,7 @@ namespace http {
Request::Request(const Url& url, HttpMethod method) :
_url(url), _socketFD(INVALID_SOCKET), _method(method) {
_headers.put(header::USER_AGENT, core::App::getInstance()->appname().c_str());
_headers.put(header::USER_AGENT, app::App::getInstance()->appname().c_str());
_headers.put(header::CONNECTION, "close");
// TODO:
// _headers.put(header::KEEP_ALIVE, "timeout=15");

View File

@ -9,7 +9,7 @@
namespace http {
class AbstractHttpParserTest : public core::AbstractTest {
class AbstractHttpParserTest : public app::AbstractTest {
public:
void validateMapEntry(const core::CharPointerMap& map, const char *key, const char *value) {
const char* mapValue = "";

View File

@ -12,7 +12,7 @@
namespace http {
class HttpClientTest : public core::AbstractTest {
class HttpClientTest : public app::AbstractTest {
};
TEST_F(HttpClientTest, testSimple) {
@ -37,7 +37,7 @@ TEST_F(HttpClientTest, testSimple) {
finishedSetup = true;
startCondition.notify_one();
while (_testApp->state() == core::AppState::Running) {
while (_testApp->state() == app::AppState::Running) {
_httpServer.update();
}
_httpServer.shutdown();

View File

@ -7,7 +7,7 @@
namespace http {
class HttpHeaderTest : public core::AbstractTest {
class HttpHeaderTest : public app::AbstractTest {
};
TEST_F(HttpHeaderTest, testSingle) {

View File

@ -7,7 +7,7 @@
namespace http {
class HttpServerTest : public core::AbstractTest {
class HttpServerTest : public app::AbstractTest {
};
TEST_F(HttpServerTest, testSimple) {

View File

@ -7,7 +7,7 @@
namespace http {
class UrlTest : public core::AbstractTest {
class UrlTest : public app::AbstractTest {
};
TEST_F(UrlTest, testSimple) {

View File

@ -60,7 +60,7 @@ bool Image::load(const io::FilePtr& file) {
ImagePtr loadImage(const io::FilePtr& file, bool async) {
const ImagePtr& i = createEmptyImage(file->name());
if (async) {
core::App::getInstance()->threadPool().enqueue([=] () { i->load(file); });
app::App::getInstance()->threadPool().enqueue([=] () { i->load(file); });
} else {
if (!i->load(file)) {
Log::warn("Failed to load image %s", i->name().c_str());

View File

@ -7,7 +7,7 @@
namespace math {
class AABBTest : public core::AbstractTest {
class AABBTest : public app::AbstractTest {
};
}

View File

@ -11,7 +11,7 @@
namespace math {
class FrustumTest : public core::AbstractTest {
class FrustumTest : public app::AbstractTest {
protected:
const float _farPlane = 500.0f;
const float _nearPlane = 0.1f;
@ -25,7 +25,7 @@ public:
}
void SetUp() override {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
/* Looking from origin to 1,0,0 (right) */
_view = glm::lookAt(glm::vec3(0.0f), glm::right, glm::up);
_projection = glm::perspective(glm::radians(45.0f), 0.75f, _nearPlane, _farPlane);

View File

@ -33,7 +33,7 @@ public:
};
}
class OctreeTest : public core::AbstractTest {
class OctreeTest : public app::AbstractTest {
public:
void test(const glm::vec3& mins, const glm::vec3& maxs, int& n, const glm::ivec3& expectedMins, const glm::ivec3& expectedMaxs, int size) {
EXPECT_TRUE(glm::isPowerOfTwo(size));

View File

@ -8,7 +8,7 @@
namespace math {
class PlaneTest : public core::AbstractTest {
class PlaneTest : public app::AbstractTest {
};
TEST_F(PlaneTest, testOrigin) {

View File

@ -11,7 +11,7 @@
namespace noise {
class IslandNoiseTest: public core::AbstractTest {
class IslandNoiseTest: public app::AbstractTest {
protected:
uint32_t biome(float e) {
if (e < 0.05)

View File

@ -11,7 +11,7 @@
namespace noise {
class NoiseTest: public core::AbstractTest {
class NoiseTest: public app::AbstractTest {
protected:
void onCleanupApp() override {
compute::shutdown();

View File

@ -7,7 +7,7 @@
namespace noise {
class PoissonDiskDistributionTest: public core::AbstractTest {
class PoissonDiskDistributionTest: public app::AbstractTest {
};
TEST_F(PoissonDiskDistributionTest, testAreaZeroOffset) {

View File

@ -10,9 +10,9 @@
namespace persistence {
class AbstractDatabaseTest : public core::AbstractTest {
class AbstractDatabaseTest : public app::AbstractTest {
private:
using Super = core::AbstractTest;
using Super = app::AbstractTest;
public:
void SetUp() override {
Super::SetUp();

View File

@ -7,7 +7,7 @@
namespace persistence {
class DBConditionTest : public core::AbstractTest {
class DBConditionTest : public app::AbstractTest {
};
TEST_F(DBConditionTest, testDBCondition) {

View File

@ -7,7 +7,7 @@
namespace persistence {
class LongCounterTest : public core::AbstractTest {
class LongCounterTest : public app::AbstractTest {
};
TEST_F(LongCounterTest, testUpdate) {

View File

@ -9,7 +9,7 @@
namespace persistence {
class SQLGeneratorTest : public core::AbstractTest {
class SQLGeneratorTest : public app::AbstractTest {
};
TEST_F(SQLGeneratorTest, testDelete) {

View File

@ -8,11 +8,11 @@
namespace poi {
class PoiProviderTest: public core::AbstractTest {
class PoiProviderTest: public app::AbstractTest {
public:
core::TimeProviderPtr _timeProvider;
void SetUp() override {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
_timeProvider = std::make_shared<core::TimeProvider>();
}
};

View File

@ -27,7 +27,7 @@ bool RandomColorTexture::init() {
delete[] colorTexture;
return true;
}
_noiseFuture.emplace_back(core::App::getInstance()->threadPool().enqueue([=] () {
_noiseFuture.emplace_back(app::App::getInstance()->threadPool().enqueue([=] () {
uint8_t *colorTexture = new uint8_t[ColorTextureSize * ColorTextureSize * ColorTextureDepth];
_noise.seamlessNoise(colorTexture, ColorTextureSize, ColorTextureOctaves, persistence, frequency, amplitude);
return NoiseGenerationTask(colorTexture, ColorTextureSize, ColorTextureSize, ColorTextureDepth);

View File

@ -11,7 +11,7 @@
namespace stock {
class AbstractStockTest: public core::AbstractTest {
class AbstractStockTest: public app::AbstractTest {
protected:
StockDataProviderPtr _provider;
ItemData *_itemData1;
@ -23,7 +23,7 @@ protected:
ItemPtr _item2;
public:
virtual void SetUp() override {
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
_provider = std::make_shared<StockDataProvider>();
_itemData1 = new ItemData(1, ItemType::WEAPON);
_itemData1->setSize(1, 2);
@ -55,7 +55,7 @@ public:
}
virtual void TearDown() override {
core::AbstractTest::TearDown();
app::AbstractTest::TearDown();
_provider->shutdown();
_itemData1 = nullptr;
_itemData2 = nullptr;

View File

@ -7,7 +7,7 @@
namespace stock {
class StockDataProviderTest: public core::AbstractTest {
class StockDataProviderTest: public app::AbstractTest {
};
TEST_F(StockDataProviderTest, testResetAndDuplicate) {

View File

@ -28,8 +28,8 @@ void TestApp::onWindowResize(int windowWidth, int windowHeight) {
camera().init(glm::ivec2(0), frameBufferDimension(), windowDimension());
}
core::AppState TestApp::onConstruct() {
core::AppState state = Super::onConstruct();
app::AppState TestApp::onConstruct() {
app::AppState state = Super::onConstruct();
core::Var::get(cfg::ClientFullscreen, "false");
core::Var::get(cfg::ClientWindowWidth, "1024");
core::Var::get(cfg::ClientWindowHeight, "768");
@ -55,13 +55,13 @@ core::AppState TestApp::onConstruct() {
return state;
}
core::AppState TestApp::onInit() {
app::AppState TestApp::onInit() {
// apps may provide their own keybindings
if (_appname != "test") {
_keybindingHandler.load("test-keybindings.cfg");
}
const core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
const app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
_logLevelVar->setVal(core::string::toString(SDL_LOG_PRIORITY_DEBUG));
@ -71,15 +71,15 @@ core::AppState TestApp::onInit() {
_axis.setSize(10.0f, 10.0f, 10.0f);
if (!_axis.init()) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_plane.init() || !_plane.plane(glm::zero<glm::vec3>(), 0, _planeColor)) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_movement.init()) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
Log::info("Set window dimensions: %ix%i (aspect: %f)", _frameBufferDimension.x, _frameBufferDimension.y, _aspect);
@ -129,9 +129,9 @@ void TestApp::beforeUI() {
}
}
core::AppState TestApp::onRunning() {
app::AppState TestApp::onRunning() {
video::clear(video::ClearFlag::Color | video::ClearFlag::Depth);
const core::AppState state = Super::onRunning();
const app::AppState state = Super::onRunning();
SDL_SetRelativeMouseMode(_cameraMotion ? SDL_TRUE : SDL_FALSE);
return state;
}
@ -153,7 +153,7 @@ void TestApp::onRenderUI() {
}
}
core::AppState TestApp::onCleanup() {
app::AppState TestApp::onCleanup() {
_axis.shutdown();
_plane.shutdown();
_movement.shutdown();

View File

@ -55,12 +55,12 @@ public:
video::Camera& camera();
virtual core::AppState onConstruct() override;
virtual core::AppState onInit() override;
virtual core::AppState onRunning() override;
virtual app::AppState onConstruct() override;
virtual app::AppState onInit() override;
virtual app::AppState onRunning() override;
virtual void beforeUI() override;
virtual void onRenderUI() override;
virtual core::AppState onCleanup() override;
virtual app::AppState onCleanup() override;
virtual bool onMouseWheel(int32_t x, int32_t y) override;
virtual void onWindowResize(int windowWidth, int windowHeight) override;
};

View File

@ -125,8 +125,8 @@ void IMGUIApp::onWindowResize(int windowWidth, int windowHeight) {
_shader.setModel(glm::mat4(1.0f));
}
core::AppState IMGUIApp::onConstruct() {
const core::AppState state = Super::onConstruct();
app::AppState IMGUIApp::onConstruct() {
const app::AppState state = Super::onConstruct();
_console.construct();
return state;
}
@ -157,10 +157,10 @@ static void _setClipboardText(void*, const char* text) {
SDL_SetClipboardText(text);
}
core::AppState IMGUIApp::onInit() {
const core::AppState state = Super::onInit();
app::AppState IMGUIApp::onInit() {
const app::AppState state = Super::onInit();
video::checkError();
if (state != core::AppState::Running) {
if (state != app::AppState::Running) {
return state;
}
@ -168,19 +168,19 @@ core::AppState IMGUIApp::onInit() {
if (!_shader.setup()) {
Log::error("Could not load the ui shader");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_bufferIndex = _vbo.create();
if (_bufferIndex < 0) {
Log::error("Failed to create ui vertex buffer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_vbo.setMode(_bufferIndex, video::BufferMode::Stream);
_indexBufferIndex = _vbo.create(nullptr, 0, video::BufferType::IndexBuffer);
if (_indexBufferIndex < 0) {
Log::error("Failed to create ui index buffer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_camera = video::uiCamera(glm::ivec2(0), frameBufferDimension(), windowDimension());
@ -259,11 +259,11 @@ core::AppState IMGUIApp::onInit() {
return state;
}
core::AppState IMGUIApp::onRunning() {
app::AppState IMGUIApp::onRunning() {
core_trace_scoped(IMGUIAppOnRunning);
core::AppState state = Super::onRunning();
app::AppState state = Super::onRunning();
if (state != core::AppState::Running) {
if (state != app::AppState::Running) {
return state;
}
video::clear(video::ClearFlag::Color);
@ -333,7 +333,7 @@ core::AppState IMGUIApp::onRunning() {
executeDrawCommands();
video::scissor(0, 0, _frameBufferDimension.x, _frameBufferDimension.y);
return core::AppState::Running;
return app::AppState::Running;
}
void IMGUIApp::executeDrawCommands() {
@ -368,7 +368,7 @@ void IMGUIApp::executeDrawCommands() {
core_trace_plot("UIDrawCommands", drawCommands);
}
core::AppState IMGUIApp::onCleanup() {
app::AppState IMGUIApp::onCleanup() {
if (ImGui::GetCurrentContext() != nullptr) {
ImGui::DestroyContext();
}

View File

@ -53,11 +53,11 @@ public:
}
virtual void onWindowResize(int windowWidth, int windowHeight) override;
virtual core::AppState onConstruct() override;
virtual core::AppState onInit() override;
virtual core::AppState onRunning() override;
virtual app::AppState onConstruct() override;
virtual app::AppState onInit() override;
virtual app::AppState onRunning() override;
virtual void onRenderUI() = 0;
virtual core::AppState onCleanup() override;
virtual app::AppState onCleanup() override;
};
}

View File

@ -26,18 +26,18 @@ LUAUIApp::LUAUIApp(const metric::MetricPtr& metric,
LUAUIApp::~LUAUIApp() {
}
core::AppState LUAUIApp::onInit() {
const core::AppState state = Super::onInit();
app::AppState LUAUIApp::onInit() {
const app::AppState state = Super::onInit();
if (!_texturePool->init()) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
const core::String& path = core::string::format("ui/%s.lua", appname().c_str());
_uiScriptPath = core::Var::get("ui_script", path)->strVal();
if (!reload()) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
core::Command::registerCommand("ui_reload", [this] (const core::CmdArgs&) {
@ -75,7 +75,7 @@ core::AppState LUAUIApp::onInit() {
return state;
}
core::AppState LUAUIApp::onCleanup() {
app::AppState LUAUIApp::onCleanup() {
_texturePool->shutdown();
return Super::onCleanup();
}

View File

@ -53,8 +53,8 @@ public:
void popup(const core::String& message);
void setGlobalAlpha(float alpha);
core::AppState onInit() override;
core::AppState onCleanup() override;
app::AppState onInit() override;
app::AppState onCleanup() override;
bool reload();
bool onRenderUI() override;

View File

@ -155,13 +155,13 @@ struct nk_image NuklearApp::loadImageFile(const char *filename) {
return image;
}
core::AppState NuklearApp::onInit() {
const core::AppState state = Super::onInit();
app::AppState NuklearApp::onInit() {
const app::AppState state = Super::onInit();
SDL_StartTextInput();
showCursor(false);
centerMousePosition();
video::checkError();
if (state != core::AppState::Running) {
if (state != app::AppState::Running) {
return state;
}
@ -174,7 +174,7 @@ core::AppState NuklearApp::onInit() {
alloc.free = nk_core_free;
if (nk_init(&_ctx, &alloc, nullptr) == 0) {
Log::error("Could not init the ui");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
};
_ctx.clip.copy = nk_sdl_clipbard_copy;
_ctx.clip.paste = nk_sdl_clipbard_paste;
@ -209,7 +209,7 @@ core::AppState NuklearApp::onInit() {
const void *image = nk_font_atlas_bake(&_atlas, &w, &h, NK_FONT_ATLAS_RGBA32);
if (image == nullptr) {
Log::error("Failed to bake font atlas");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_fontTexture->upload(w, h, (const uint8_t*) image);
nk_font_atlas_end(&_atlas, nk_handle_id((int)_fontTexture->handle()), &_null);
@ -223,35 +223,35 @@ core::AppState NuklearApp::onInit() {
if (!_shader.setup()) {
Log::error("Could not load the ui shader");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!voxel::initDefaultMaterialColors()) {
Log::error("Failed to initialize the material colors");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_meshRenderer->init()) {
Log::error("Could not initialize the mesh renderer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_textureAtlasRenderer->init()) {
Log::error("Could not initialize the texture atlas renderer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_vertexBufferIndex = _vbo.create();
if (_vertexBufferIndex < 0) {
Log::error("Failed to create ui vbo");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_vbo.setMode(_vertexBufferIndex, video::BufferMode::Stream);
_elementBufferIndex = _vbo.create(nullptr, 0, video::BufferType::IndexBuffer);
if (_elementBufferIndex < 0) {
Log::error("Failed to create ui ibo");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_camera = video::uiCamera(glm::ivec2(0), frameBufferDimension(), windowDimension());
@ -262,11 +262,11 @@ core::AppState NuklearApp::onInit() {
if (!_vbo.update(_vertexBufferIndex, nullptr, MAX_VERTEX_MEMORY)) {
Log::error("Failed to upload vertex buffer data with %i bytes", MAX_VERTEX_MEMORY);
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_vbo.update(_elementBufferIndex, nullptr, MAX_ELEMENT_MEMORY)) {
Log::error("Failed to upload index buffer data with %i bytes", MAX_ELEMENT_MEMORY);
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
static const struct nk_draw_vertex_layout_element vertexLayout[] = {
@ -284,7 +284,7 @@ core::AppState NuklearApp::onInit() {
if (!_console.init()) {
Log::error("Failed to initialize the console");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
return state;
@ -308,8 +308,8 @@ void NuklearApp::onWindowResize(int windowWidth, int windowHeight) {
_camera.init(glm::zero<glm::ivec2>(), frameBufferDimension(), windowDimension());
}
core::AppState NuklearApp::onConstruct() {
const core::AppState state = Super::onConstruct();
app::AppState NuklearApp::onConstruct() {
const app::AppState state = Super::onConstruct();
_console.construct();
return state;
}
@ -329,9 +329,9 @@ struct nk_font* NuklearApp::font(int size) {
return _fonts[fontIndex];
}
core::AppState NuklearApp::onRunning() {
core::AppState state = Super::onRunning();
if (state != core::AppState::Running) {
app::AppState NuklearApp::onRunning() {
app::AppState state = Super::onRunning();
if (state != app::AppState::Running) {
return state;
}
video::clear(video::ClearFlag::Color);
@ -435,12 +435,12 @@ core::AppState NuklearApp::onRunning() {
void *vertices = _vbo.mapData(_vertexBufferIndex, video::AccessMode::Write);
if (vertices == nullptr) {
Log::warn("Failed to map vertices");
return core::AppState::Cleanup;
return app::AppState::Cleanup;
}
void *elements = _vbo.mapData(_elementBufferIndex, video::AccessMode::Write);
if (elements == nullptr) {
Log::warn("Failed to map indices");
return core::AppState::Cleanup;
return app::AppState::Cleanup;
}
struct nk_buffer vbuf;
@ -495,7 +495,7 @@ core::AppState NuklearApp::onRunning() {
return state;
}
core::AppState NuklearApp::onCleanup() {
app::AppState NuklearApp::onCleanup() {
nk_font_atlas_clear(&_atlas);
nk_buffer_free(&_cmds);
nk_free(&_ctx);

View File

@ -127,10 +127,10 @@ public:
struct nkc_context& context();
virtual void onWindowResize(int windowWidth, int windowHeight) override;
virtual core::AppState onConstruct() override;
virtual core::AppState onInit() override;
virtual core::AppState onRunning() override;
virtual core::AppState onCleanup() override;
virtual app::AppState onConstruct() override;
virtual app::AppState onInit() override;
virtual app::AppState onRunning() override;
virtual app::AppState onCleanup() override;
};
inline struct nkc_context& NuklearApp::context() {

View File

@ -387,8 +387,8 @@ void UIApp::onWindowResize(int windowWidth, int windowHeight) {
_root->setRect(tb::TBRect(0, 0, _frameBufferDimension.x, _frameBufferDimension.y));
}
core::AppState UIApp::onConstruct() {
const core::AppState state = Super::onConstruct();
app::AppState UIApp::onConstruct() {
const app::AppState state = Super::onConstruct();
core::Command::registerCommand("cl_ui_debug", [&] (const core::CmdArgs& args) {
#ifdef DEBUG
tb::ShowDebugInfoSettingsWindow(_root);
@ -417,15 +417,15 @@ void UIApp::afterRootWidget() {
_console.render(rect, _deltaFrameSeconds);
}
core::AppState UIApp::onInit() {
const core::AppState state = Super::onInit();
app::AppState UIApp::onInit() {
const app::AppState state = Super::onInit();
video::checkError();
if (state != core::AppState::Running) {
if (state != app::AppState::Running) {
return state;
}
if (!tb::tb_core_init(&_renderer)) {
Log::error(_logId, "failed to initialize the ui");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
tb::TBWidgetListener::addGlobalListener(this);
@ -447,19 +447,19 @@ core::AppState UIApp::onInit() {
if (!tb::g_tb_skin->load("ui/skin/skin.tb.txt", _applicationSkin.empty() ? nullptr : _applicationSkin.c_str())) {
Log::error(_logId, "could not load the skin at ui/skin/skin.tb.txt and/or %s",
_applicationSkin.empty() ? "none" : _applicationSkin.c_str());
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_renderer.init(frameBufferDimension(), windowDimension())) {
Log::error(_logId, "could not init ui renderer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
initFonts();
tb::TBFontFace *font = getFont(_uiFontSize->intVal(), true);
if (font == nullptr) {
Log::error(_logId, "could not create the font face");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_root = new tb::TBWidget();
@ -484,8 +484,8 @@ tb::TBWidget* UIApp::getWidgetAt(int x, int y, bool includeChildren) {
return _root->getWidgetAt(x, y, includeChildren);
}
core::AppState UIApp::onRunning() {
core::AppState state = Super::onRunning();
app::AppState UIApp::onRunning() {
app::AppState state = Super::onRunning();
_console.update(_deltaFrameSeconds);
_lastShowTextY = 5;
@ -498,7 +498,7 @@ core::AppState UIApp::onRunning() {
}
}
const bool running = state == core::AppState::Running;
const bool running = state == app::AppState::Running;
if (running) {
{
core_trace_scoped(UIAppBeforeUI);
@ -536,7 +536,7 @@ core::AppState UIApp::onRunning() {
return state;
}
core::AppState UIApp::onCleanup() {
app::AppState UIApp::onCleanup() {
tb::TBAnimationManager::abortAllAnimations();
if (_uiInitialized) {
tb::TBWidgetListener::removeGlobalListener(this);

View File

@ -69,10 +69,10 @@ public:
void fileDialog(const std::function<void(const core::String&)>& callback, OpenFileMode mode, const core::String& filter) override;
virtual void onWindowResize(int windowWidth, int windowHeight) override;
virtual core::AppState onConstruct() override;
virtual core::AppState onInit() override;
virtual core::AppState onRunning() override;
virtual core::AppState onCleanup() override;
virtual app::AppState onConstruct() override;
virtual app::AppState onInit() override;
virtual app::AppState onRunning() override;
virtual app::AppState onCleanup() override;
};
template<class T>

View File

@ -41,12 +41,12 @@ tb::TBGenericStringItem* Window::addStringItem(tb::TBGenericStringItemSource& it
if (id == nullptr) {
const core::String& lowerId = core::String::lower(text);
item = new tb::TBGenericStringItem(translate ? tr(text) : text, TBIDC(lowerId.c_str()));
const core::String& iconId = core::App::getInstance()->appname() + "-" + lowerId;
const core::String& iconId = app::App::getInstance()->appname() + "-" + lowerId;
item->setSkinImage(TBIDC(iconId.c_str()));
} else {
item = new tb::TBGenericStringItem(translate ? tr(text) : text, TBIDC(id));
char buf[128];
SDL_snprintf(buf, sizeof(buf), "%s-%s", core::App::getInstance()->appname().c_str(), id);
SDL_snprintf(buf, sizeof(buf), "%s-%s", app::App::getInstance()->appname().c_str(), id);
item->setSkinImage(TBIDC(buf));
}
items.addItem(item);
@ -401,7 +401,7 @@ bool Window::setVisible(const char *name, bool visible) {
}
void Window::requestQuit() {
core::App::getInstance()->requestQuit();
app::App::getInstance()->requestQuit();
}
}

View File

@ -7,7 +7,7 @@
namespace util {
class BufferUtilTest : public core::AbstractTest {
class BufferUtilTest : public app::AbstractTest {
};
TEST_F(BufferUtilTest, testIndexCompress) {

View File

@ -9,7 +9,7 @@
namespace util {
class ConsoleTest: public core::AbstractTest {
class ConsoleTest: public app::AbstractTest {
};
class TestConsole : public util::Console {

View File

@ -7,7 +7,7 @@
#include "io/Filesystem.h"
#include <SDL_platform.h>
class IncludeUtilTest : public core::AbstractTest {
class IncludeUtilTest : public app::AbstractTest {
};
TEST_F(IncludeUtilTest, testInclude) {

View File

@ -22,7 +22,7 @@ left_alt altmodcommand
)";
}
class KeybindingHandlerTest : public core::AbstractTest {
class KeybindingHandlerTest : public app::AbstractTest {
protected:
KeybindingParser _parser;
KeyBindingHandler _handler;
@ -38,7 +38,7 @@ protected:
}
bool onInitApp() override {
if (!core::AbstractTest::onInitApp()) {
if (!app::AbstractTest::onInitApp()) {
return false;
}
if (_parser.invalidBindings() > 0) {
@ -64,7 +64,7 @@ protected:
}
void onCleanupApp() override {
core::AbstractTest::onCleanupApp();
app::AbstractTest::onCleanupApp();
_handler.shutdown();
}

View File

@ -49,7 +49,7 @@ void WindowedApp::onAfterRunning() {
video::endFrame(_window);
}
core::AppState WindowedApp::onRunning() {
app::AppState WindowedApp::onRunning() {
video_trace_scoped(Frame);
core_trace_scoped(WindowedAppOnRunning);
if (_keybindingHandler.isPressed(util::button::CUSTOM_SDLK_MOUSE_WHEEL_UP)) {
@ -97,7 +97,7 @@ core::AppState WindowedApp::onRunning() {
}
if (quit) {
return core::AppState::Cleanup;
return app::AppState::Cleanup;
}
core_trace_scoped(WindowedAppStartFrame);
@ -110,7 +110,7 @@ core::AppState WindowedApp::onRunning() {
video_trace_frame_end();
return core::AppState::Running;
return app::AppState::Running;
}
bool WindowedApp::onKeyRelease(int32_t key, int16_t modifier) {
@ -166,15 +166,15 @@ core::String WindowedApp::getKeyBindingsString(const char *cmd) const {
return _keybindingHandler.getKeyBindingsString(cmd);
}
core::AppState WindowedApp::onInit() {
core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
app::AppState WindowedApp::onInit() {
app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
sdlCheckError();
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
SDL_EventState(SDL_MOUSEMOTION, SDL_DISABLE);
@ -182,7 +182,7 @@ core::AppState WindowedApp::onInit() {
if (!_keybindingHandler.init()) {
Log::error("Failed to initialize the key binding hendler");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_keybindingHandler.load("keybindings.cfg")) {
Log::warn("failed to init the global keybindings");
@ -215,7 +215,7 @@ core::AppState WindowedApp::onInit() {
Log::info("Try to use display %i", displayIndex);
if (SDL_GetDesktopDisplayMode(displayIndex, &displayMode) == -1) {
Log::error("%s", SDL_GetError());
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
for (int i = 0; i < numDisplays; ++i) {
@ -316,7 +316,7 @@ core::AppState WindowedApp::onInit() {
_window = InternalCreateWindow();
if (!_window) {
sdlCheckError();
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
}
@ -329,7 +329,7 @@ core::AppState WindowedApp::onInit() {
_rendererContext = video::createContext(_window);
if (_rendererContext == nullptr) {
sdlCheckError();
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
SDL_DisableScreenSaver();
@ -378,8 +378,8 @@ core::AppState WindowedApp::onInit() {
return state;
}
core::AppState WindowedApp::onConstruct() {
core::AppState state = Super::onConstruct();
app::AppState WindowedApp::onConstruct() {
app::AppState state = Super::onConstruct();
core::Var::get(cfg::ClientMultiSampleBuffers, "0");
core::Var::get(cfg::ClientMultiSampleSamples, "0");
core::Var::get(cfg::ClientFullscreen, "true");
@ -402,7 +402,7 @@ core::AppState WindowedApp::onConstruct() {
return state;
}
core::AppState WindowedApp::onCleanup() {
app::AppState WindowedApp::onCleanup() {
core::Singleton<io::EventHandler>::getInstance().removeObserver(this);
video::destroyContext(_rendererContext);
if (_window != nullptr) {

View File

@ -27,9 +27,9 @@ namespace video {
*
* This application also receives input events (and others) from @c io::IEventObserver
*/
class WindowedApp: public core::App, public io::IEventObserver {
class WindowedApp: public app::App, public io::IEventObserver {
private:
using Super = core::App;
using Super = app::App;
protected:
SDL_Window* _window = nullptr;
RendererContext _rendererContext = nullptr;
@ -119,16 +119,16 @@ public:
*/
void directoryDialog(const std::function<void(const core::String)>& callback);
virtual core::AppState onRunning() override;
virtual app::AppState onRunning() override;
virtual void onAfterRunning() override;
virtual bool onMouseWheel(int32_t x, int32_t y) override;
virtual void onMouseButtonPress(int32_t x, int32_t y, uint8_t button, uint8_t clicks) override;
virtual void onMouseButtonRelease(int32_t x, int32_t y, uint8_t button) override;
virtual bool onKeyRelease(int32_t key, int16_t modifier) override;
virtual bool onKeyPress(int32_t key, int16_t modifier) override;
virtual core::AppState onConstruct() override;
virtual core::AppState onInit() override;
virtual core::AppState onCleanup() override;
virtual app::AppState onConstruct() override;
virtual app::AppState onInit() override;
virtual app::AppState onCleanup() override;
static double fps() {
return getInstance()->_fps;

View File

@ -34,7 +34,7 @@ inline ::std::ostream& operator<<(::std::ostream& os, const ShaderVarState& stat
<< "]";
}
class AbstractGLTest : public core::AbstractTest {
class AbstractGLTest : public app::AbstractTest {
protected:
SDL_Window *_window = nullptr;
RendererContext _ctx = nullptr;
@ -59,7 +59,7 @@ public:
core::Var::get(cfg::ClientMultiSampleBuffers, "0");
core::Var::get(cfg::ClientMultiSampleSamples, "0");
core::Var::get(cfg::ClientVSync, "false");
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
SDL_Init(SDL_INIT_VIDEO);
video::setup();
_window = SDL_CreateWindow("test", 0, 0, 640, 480, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN);
@ -72,7 +72,7 @@ public:
}
void TearDown() override {
core::AbstractTest::TearDown();
app::AbstractTest::TearDown();
if (_ctx != nullptr) {
video::destroyContext(_ctx);
}

View File

@ -12,7 +12,7 @@
namespace video {
class CameraTest : public core::AbstractTest {
class CameraTest : public app::AbstractTest {
public:
virtual ~CameraTest() {}
protected:

View File

@ -7,7 +7,7 @@
namespace video {
class RendererTest : public core::AbstractTest {
class RendererTest : public app::AbstractTest {
};
TEST_F(RendererTest, testMapType) {

View File

@ -10,7 +10,7 @@
namespace video {
class ShaderTest : public core::AbstractTest {
class ShaderTest : public app::AbstractTest {
};
TEST_F(ShaderTest, testInclude) {

View File

@ -12,7 +12,7 @@
static constexpr int MAX_BENCHMARK_VOLUME_SIZE = 64;
static const int meshSize = voxel::MAX_MESH_CHUNK_HEIGHT;
class CubicSurfaceExtractorBenchmark : public core::AbstractBenchmark {
class CubicSurfaceExtractorBenchmark : public app::AbstractBenchmark {
public:
void onCleanupApp() override {
}

View File

@ -97,7 +97,7 @@ inline ::std::ostream& operator<<(::std::ostream& os, const voxel::RawVolume& vo
return os;
}
class AbstractVoxelTest: public core::AbstractTest {
class AbstractVoxelTest: public app::AbstractTest {
protected:
class Pager: public PagedVolume::Pager {
AbstractVoxelTest* _test;
@ -147,7 +147,7 @@ protected:
public:
void SetUp() override {
_volData.flushAll();
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
ASSERT_TRUE(voxel::initDefaultMaterialColors());
_random.setSeed(_seed);
_ctx = PagedVolumeWrapper(&_volData, _volData.chunk(_region.getCenter()), _region);

View File

@ -8,7 +8,7 @@
namespace voxel {
class FaceTest: public core::AbstractTest {
class FaceTest: public app::AbstractTest {
};
TEST_F(FaceTest, testNegativeX) {

View File

@ -7,7 +7,7 @@
namespace voxel {
class RawVolumeWrapperTest: public core::AbstractTest {
class RawVolumeWrapperTest: public app::AbstractTest {
};
TEST_F(RawVolumeWrapperTest, testSetOneVoxelVolume) {

View File

@ -7,7 +7,7 @@
namespace voxel {
class RegionTest: public core::AbstractTest {
class RegionTest: public app::AbstractTest {
};
TEST_F(RegionTest, testContains) {

View File

@ -12,7 +12,7 @@
namespace voxelgenerator {
class LUAGeneratorTest: public core::AbstractTest {
class LUAGeneratorTest: public app::AbstractTest {
};
TEST_F(LUAGeneratorTest, testInit) {

View File

@ -15,9 +15,9 @@
namespace voxelgenerator {
class ShapeGeneratorTest: public core::AbstractTest {
class ShapeGeneratorTest: public app::AbstractTest {
private:
using Super = core::AbstractTest;
using Super = app::AbstractTest;
protected:
static constexpr voxel::Region _region {0, 31};
static constexpr glm::ivec3 _center { 15 };

View File

@ -11,7 +11,7 @@
namespace voxelrender {
class MaterialTest: public core::AbstractTest {
class MaterialTest: public app::AbstractTest {
protected:
const int components = 4;
const int w = 256;

View File

@ -9,7 +9,7 @@
namespace voxel {
class PickingTest: public core::AbstractTest {
class PickingTest: public app::AbstractTest {
};
TEST_F(PickingTest, testPicking) {

View File

@ -7,7 +7,7 @@
namespace voxel {
class VolumeRotatorTest: public core::AbstractTest {
class VolumeRotatorTest: public app::AbstractTest {
protected:
inline core::String str(const voxel::Region& region) const {
return region.toString();

View File

@ -9,7 +9,7 @@
#include "voxel/Constants.h"
#include "voxelformat/VolumeCache.h"
class PagedVolumeBenchmark: public core::AbstractBenchmark {
class PagedVolumeBenchmark: public app::AbstractBenchmark {
protected:
voxelformat::VolumeCachePtr _volumeCache;

View File

@ -16,7 +16,7 @@
namespace voxelworld {
class AbstractVoxelTest: public core::AbstractTest {
class AbstractVoxelTest: public app::AbstractTest {
protected:
class Pager: public voxel::PagedVolume::Pager {
AbstractVoxelTest* _test;
@ -66,7 +66,7 @@ protected:
public:
void SetUp() override {
_volData.flushAll();
core::AbstractTest::SetUp();
app::AbstractTest::SetUp();
ASSERT_TRUE(voxel::initDefaultMaterialColors());
_random.setSeed(_seed);
_ctx = voxel::PagedVolumeWrapper(&_volData, _volData.chunk(_region.getCenter()), _region);

View File

@ -39,8 +39,8 @@ Server::Server(const metric::MetricPtr& metric, const backend::ServerLoopPtr& se
init(ORGANISATION, "server");
}
core::AppState Server::onConstruct() {
const core::AppState state = Super::onConstruct();
app::AppState Server::onConstruct() {
const app::AppState state = Super::onConstruct();
core::Var::get(cfg::DatabaseName, "vengi");
core::Var::get(cfg::DatabaseHost, "localhost");
@ -74,9 +74,9 @@ core::AppState Server::onConstruct() {
return state;
}
core::AppState Server::onInit() {
const core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
app::AppState Server::onInit() {
const app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
@ -87,21 +87,21 @@ core::AppState Server::onInit() {
if (!_serverLoop->init()) {
Log::error("Failed to initialize the main loop - can't run server");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
return core::AppState::Running;
return app::AppState::Running;
}
core::AppState Server::onCleanup() {
app::AppState Server::onCleanup() {
_serverLoop->shutdown();
return Super::onCleanup();
}
core::AppState Server::onRunning() {
app::AppState Server::onRunning() {
Super::onRunning();
_serverLoop->update();
return core::AppState::Running;
return app::AppState::Running;
}
int main(int argc, char *argv[]) {

View File

@ -18,8 +18,8 @@ public:
const core::TimeProviderPtr& timeProvider, const io::FilesystemPtr& filesystem,
const core::EventBusPtr& eventBus, const http::HttpServerPtr& httpServer);
core::AppState onConstruct() override;
core::AppState onInit() override;
core::AppState onCleanup() override;
core::AppState onRunning() override;
app::AppState onConstruct() override;
app::AppState onInit() override;
app::AppState onCleanup() override;
app::AppState onRunning() override;
};

View File

@ -58,8 +58,8 @@ animation::AnimationEntity* TestAnimation::animationEntity() {
return &_character;
}
core::AppState TestAnimation::onConstruct() {
core::AppState state = Super::onConstruct();
app::AppState TestAnimation::onConstruct() {
app::AppState state = Super::onConstruct();
core::Command::registerCommand("animation_cycle", [this] (const core::CmdArgs& argv) {
int offset = 1;
@ -132,9 +132,9 @@ bool TestAnimation::loadAnimationEntity() {
return true;
}
core::AppState TestAnimation::onInit() {
core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
app::AppState TestAnimation::onInit() {
app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
@ -147,17 +147,17 @@ core::AppState TestAnimation::onInit() {
if (!voxel::initDefaultMaterialColors()) {
Log::error("Failed to initialize the default material colors");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_stockDataProvider->init(filesystem()->load("stock.lua"))) {
Log::error("Failed to init stock data provider: %s", _stockDataProvider->error().c_str());
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_stock.init()) {
Log::error("Failed to init stock");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
const auto& items = _stockDataProvider->items();
@ -171,21 +171,21 @@ core::AppState TestAnimation::onInit() {
if (_items.empty()) {
Log::error("Failed to load items");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_animationCache->init()) {
Log::error("Failed to initialize the character mesh cache");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!loadAnimationEntity()) {
Log::error("Failed to initialize the animation entity");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!_renderer.init()) {
Log::error("Failed to initialize the character renderer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_attrib.setCurrent(attrib::Type::SPEED, 10.0);
@ -200,7 +200,7 @@ core::AppState TestAnimation::onInit() {
const stock::ItemData* itemData = _stockDataProvider->itemData(_items[0]);
if (!addItem(itemData->id())) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
return state;
@ -265,7 +265,7 @@ void TestAnimation::onRenderUI() {
Super::onRenderUI();
}
core::AppState TestAnimation::onCleanup() {
app::AppState TestAnimation::onCleanup() {
_stock.shutdown();
_animationCache->shutdown();
_stockDataProvider->shutdown();

View File

@ -51,7 +51,7 @@ public:
const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider,
const animation::AnimationCachePtr& animationCache);
core::AppState onConstruct() override;
core::AppState onInit() override;
core::AppState onCleanup() override;
app::AppState onConstruct() override;
app::AppState onInit() override;
app::AppState onCleanup() override;
};

View File

@ -28,9 +28,9 @@ void TestBiomes::recalcBiomes(const glm::ivec3& pos) {
_resultQueue.push(new BiomesTextureResult(humidity, _biomesTextureSize));
}
core::AppState TestBiomes::onInit() {
core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
app::AppState TestBiomes::onInit() {
app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
@ -40,17 +40,17 @@ core::AppState TestBiomes::onInit() {
if (!_renderer.init(frameBufferDimension())) {
Log::error("Failed to setup the renderer");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
if (!voxel::initDefaultMaterialColors()) {
Log::error("Failed to initialize the material colors");
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
const core::String& biomesData = io::filesystem()->load("biomes.lua");
if (!_biomeMgr.init(biomesData)) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
video::TextureConfig cfg2d;
@ -80,8 +80,8 @@ core::AppState TestBiomes::onInit() {
return state;
}
core::AppState TestBiomes::onRunning() {
core::AppState state = Super::onRunning();
app::AppState TestBiomes::onRunning() {
app::AppState state = Super::onRunning();
Result* result = nullptr;
if (_resultQueue.pop(result)) {
switch (result->type) {
@ -96,7 +96,7 @@ core::AppState TestBiomes::onRunning() {
return state;
}
core::AppState TestBiomes::onCleanup() {
app::AppState TestBiomes::onCleanup() {
_biomeMgr.shutdown();
_workQueue.abortWait();
// TODO: clear mem: while () {}

View File

@ -32,7 +32,7 @@ private:
public:
TestBiomes(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider);
virtual core::AppState onInit() override;
virtual core::AppState onRunning() override;
virtual core::AppState onCleanup() override;
virtual app::AppState onInit() override;
virtual app::AppState onRunning() override;
virtual app::AppState onCleanup() override;
};

View File

@ -15,9 +15,9 @@ TestCamera::TestCamera(const metric::MetricPtr& metric, const io::FilesystemPtr&
setRenderAxis(true);
}
core::AppState TestCamera::onInit() {
core::AppState state = Super::onInit();
if (state != core::AppState::Running) {
app::AppState TestCamera::onInit() {
app::AppState state = Super::onInit();
if (state != app::AppState::Running) {
return state;
}
@ -62,7 +62,7 @@ core::AppState TestCamera::onInit() {
_renderCamera[i].update(0l);
if (!_frustums[i].init(_renderCamera[i], colors[i], renderSplitFrustum ? 4 : 0)) {
return core::AppState::InitFailure;
return app::AppState::InitFailure;
}
_frustums[i].setRenderAABB(renderAABB);
}
@ -122,8 +122,8 @@ void TestCamera::onRenderUI() {
Super::onRenderUI();
}
core::AppState TestCamera::onRunning() {
core::AppState state = Super::onRunning();
app::AppState TestCamera::onRunning() {
app::AppState state = Super::onRunning();
video::Camera& c = _renderCamera[_targetCamera];
const SDL_Keymod mods = SDL_GetModState();
if (mods & KMOD_SHIFT) {
@ -133,7 +133,7 @@ core::AppState TestCamera::onRunning() {
return state;
}
core::AppState TestCamera::onCleanup() {
app::AppState TestCamera::onCleanup() {
for (int i = 0; i < CAMERAS; ++i) {
_frustums[i].shutdown();
}

View File

@ -30,9 +30,9 @@ private:
public:
TestCamera(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider);
core::AppState onInit() override;
core::AppState onRunning() override;
core::AppState onCleanup() override;
app::AppState onInit() override;
app::AppState onRunning() override;
app::AppState onCleanup() override;
void onRenderUI() override;

Some files were not shown because too many files have changed in this diff Show More