reduce extra includes
This commit is contained in:
parent
dbe9ca5efe
commit
b3feb5945b
@ -6,6 +6,7 @@
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "data/dv.hpp"
|
||||
#include "util/data_io.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
|
||||
|
||||
6
src/data/dv_fwd.hpp
Normal file
6
src/data/dv_fwd.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace dv {
|
||||
class value;
|
||||
struct optionalvalue;
|
||||
}
|
||||
@ -4,7 +4,6 @@
|
||||
#include "typedefs.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#include "assets/Assets.hpp"
|
||||
#include "content/content_fwd.hpp"
|
||||
#include "content/ContentPack.hpp"
|
||||
#include "content/PacksManager.hpp"
|
||||
@ -15,10 +14,10 @@
|
||||
#include "Time.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Assets;
|
||||
class Level;
|
||||
class Screen;
|
||||
class EnginePaths;
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "content/Content.hpp"
|
||||
#include "content/ContentPack.hpp"
|
||||
#include "graphics/core/Atlas.hpp"
|
||||
#include "graphics/commons/Model.hpp"
|
||||
#include "maths/UVRegion.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
#include "core_defs.hpp"
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "graphics/commons/Model.hpp"
|
||||
#include "maths/UVRegion.hpp"
|
||||
|
||||
class Content;
|
||||
class Assets;
|
||||
|
||||
@ -21,11 +21,11 @@ void UiDocument::rebuildIndices() {
|
||||
gui::UINode::getIndices(root, map);
|
||||
}
|
||||
|
||||
const uinodes_map& UiDocument::getMap() const {
|
||||
const UINodesMap& UiDocument::getMap() const {
|
||||
return map;
|
||||
}
|
||||
|
||||
uinodes_map& UiDocument::getMapWriteable() {
|
||||
UINodesMap& UiDocument::getMapWriteable() {
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@ -19,12 +19,12 @@ struct uidocscript {
|
||||
bool onclose : 1;
|
||||
};
|
||||
|
||||
using uinodes_map = std::unordered_map<std::string, std::shared_ptr<gui::UINode>>;
|
||||
using UINodesMap = std::unordered_map<std::string, std::shared_ptr<gui::UINode>>;
|
||||
|
||||
class UiDocument {
|
||||
std::string id;
|
||||
uidocscript script;
|
||||
uinodes_map map;
|
||||
UINodesMap map;
|
||||
std::shared_ptr<gui::UINode> root;
|
||||
scriptenv env;
|
||||
public:
|
||||
@ -38,8 +38,8 @@ public:
|
||||
void rebuildIndices();
|
||||
|
||||
const std::string& getId() const;
|
||||
const uinodes_map& getMap() const;
|
||||
uinodes_map& getMapWriteable();
|
||||
const UINodesMap& getMap() const;
|
||||
UINodesMap& getMapWriteable();
|
||||
std::shared_ptr<gui::UINode> getRoot() const;
|
||||
std::shared_ptr<gui::UINode> get(const std::string& id) const;
|
||||
const uidocscript& getScript() const;
|
||||
|
||||
@ -13,8 +13,6 @@
|
||||
#include "graphics/core/Batch2D.hpp"
|
||||
#include "graphics/core/Batch3D.hpp"
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
#include "graphics/core/Font.hpp"
|
||||
#include "graphics/core/Mesh.hpp"
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "graphics/core/Texture.hpp"
|
||||
#include "graphics/core/ImageData.hpp"
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
#include "menu.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "UiDocument.hpp"
|
||||
@ -18,9 +17,8 @@
|
||||
#include "screens/MenuScreen.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "assets/assetload_funcs.hpp"
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
using namespace gui;
|
||||
|
||||
void menus::create_version_label(gui::GUI& gui) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "data/dv.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
#include "delegates.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -12,6 +12,10 @@ class Engine;
|
||||
|
||||
class UiDocument;
|
||||
|
||||
namespace gui {
|
||||
class GUI;
|
||||
}
|
||||
|
||||
namespace menus {
|
||||
/// @brief Create development version label at the top-right screen corner
|
||||
void create_version_label(gui::GUI& gui);
|
||||
@ -22,7 +26,11 @@ namespace menus {
|
||||
std::vector<dv::value> args
|
||||
);
|
||||
|
||||
void show_process_panel(Engine& engine, const std::shared_ptr<Task>& task, const std::wstring& text=L"");
|
||||
void show_process_panel(
|
||||
Engine& engine,
|
||||
const std::shared_ptr<Task>& task,
|
||||
const std::wstring& text = L""
|
||||
);
|
||||
|
||||
bool call(Engine& engine, runnable func);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "core_defs.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "frontend/ContentGfxCache.hpp"
|
||||
#include "frontend/LevelFrontend.hpp"
|
||||
#include "frontend/hud.hpp"
|
||||
@ -17,6 +18,7 @@
|
||||
#include "graphics/render/WorldRenderer.hpp"
|
||||
#include "graphics/ui/GUI.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
#include "graphics/core/TextureAnimation.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "logic/LevelController.hpp"
|
||||
#include "logic/PlayerController.hpp"
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "graphics/core/Batch2D.hpp"
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "graphics/core/Texture.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "maths/UVRegion.hpp"
|
||||
#include "window/Window.hpp"
|
||||
#include "window/Camera.hpp"
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "graphics/core/Texture.hpp"
|
||||
#include "graphics/core/Viewport.hpp"
|
||||
#include "graphics/commons/Model.hpp"
|
||||
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "WorldRenderer.hpp"
|
||||
#include "TextsRenderer.hpp"
|
||||
#include "TextNote.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "assets/assets_util.hpp"
|
||||
#include "content/Content.hpp"
|
||||
#include "voxels/Chunks.hpp"
|
||||
|
||||
@ -1,18 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "data/dv.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include "data/dv_fwd.hpp"
|
||||
|
||||
class Serializable {
|
||||
public:
|
||||
virtual ~Serializable() {}
|
||||
virtual dv::value serialize() const = 0;
|
||||
virtual void deserialize(const dv::value& src) = 0;
|
||||
|
||||
void deserializeOpt(const dv::optionalvalue& opt) {
|
||||
if (opt.ptr) {
|
||||
deserialize(*opt.ptr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "audio/audio.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "api_lua.hpp"
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "api_lua.hpp"
|
||||
#include "coders/png.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "content/Content.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "io/fwd.hpp"
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "data/dv.hpp"
|
||||
#include "data/dv_fwd.hpp"
|
||||
#include "delegates.hpp"
|
||||
#include "typedefs.hpp"
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "debug/Logger.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "frontend/hud.hpp"
|
||||
#include "frontend/UiDocument.hpp"
|
||||
#include "graphics/render/WorldRenderer.hpp"
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "interfaces/Serializable.hpp"
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "interfaces/Serializable.hpp"
|
||||
|
||||
|
||||
27
src/world/Weather.cpp
Normal file
27
src/world/Weather.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "Weather.hpp"
|
||||
|
||||
#include "data/dv.hpp"
|
||||
|
||||
dv::value Weather::serialize() const {
|
||||
return dv::object({
|
||||
{"a", a.serialize()},
|
||||
{"b", b.serialize()},
|
||||
{"name-a", nameA},
|
||||
{"name-b", nameB},
|
||||
{"t", t},
|
||||
{"speed", speed},
|
||||
});
|
||||
}
|
||||
|
||||
void Weather::deserialize(const dv::value& src) {
|
||||
if (src.has("a")) {
|
||||
a.deserialize(src["a"]);
|
||||
}
|
||||
if (src.has("b")) {
|
||||
b.deserialize(src["b"]);
|
||||
}
|
||||
src.at("name-a").get(nameA);
|
||||
src.at("name-b").get(nameB);
|
||||
src.at("t").get(t);
|
||||
src.at("speed").get(speed);
|
||||
}
|
||||
@ -45,23 +45,6 @@ struct Weather : Serializable {
|
||||
return b.thunderRate * t + a.thunderRate * (1.0f - t);
|
||||
}
|
||||
|
||||
dv::value serialize() const override {
|
||||
return dv::object({
|
||||
{"a", a.serialize()},
|
||||
{"b", b.serialize()},
|
||||
{"name-a", nameA},
|
||||
{"name-b", nameB},
|
||||
{"t", t},
|
||||
{"speed", speed},
|
||||
});
|
||||
}
|
||||
|
||||
void deserialize(const dv::value& src) override {
|
||||
a.deserializeOpt(src.at("a"));
|
||||
b.deserializeOpt(src.at("b"));
|
||||
src.at("name-a").get(nameA);
|
||||
src.at("name-b").get(nameB);
|
||||
src.at("t").get(t);
|
||||
src.at("speed").get(speed);
|
||||
}
|
||||
dv::value serialize() const override;
|
||||
void deserialize(const dv::value& src) override;
|
||||
};
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
|
||||
#include "data/dv.hpp"
|
||||
|
||||
using namespace data;
|
||||
|
||||
TEST(StructLayout, ReadWrite) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user