2025-07-06 20:43:53 +03:00
|
|
|
#pragma once
|
|
|
|
|
#include "DrawData.hpp"
|
2025-11-20 12:38:28 +03:00
|
|
|
#include <SDL3/SDL_render.h>
|
2025-08-26 12:03:09 +03:00
|
|
|
#include <chrono>
|
2025-07-06 20:43:53 +03:00
|
|
|
#include <include/core/SkCanvas.h>
|
|
|
|
|
#include "InputManager.hpp"
|
|
|
|
|
#include "FontData.hpp"
|
|
|
|
|
#include "TimePoint.hpp"
|
|
|
|
|
#include "SharedTypes.hpp"
|
|
|
|
|
#include <Eigen/Dense>
|
|
|
|
|
#include <include/core/SkSurfaceProps.h>
|
|
|
|
|
#include "Toolbar.hpp"
|
|
|
|
|
#include "World.hpp"
|
|
|
|
|
|
|
|
|
|
#ifdef USE_SKIA_BACKEND_GRAPHITE
|
|
|
|
|
#include "include/gpu/graphite/Recorder.h"
|
|
|
|
|
#elif USE_SKIA_BACKEND_GANESH
|
|
|
|
|
#include "include/gpu/ganesh/GrDirectContext.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
using namespace Eigen;
|
|
|
|
|
|
|
|
|
|
class MainProgram {
|
|
|
|
|
public:
|
|
|
|
|
static constexpr size_t LOG_SIZE = 30;
|
|
|
|
|
|
|
|
|
|
InputManager input;
|
|
|
|
|
|
|
|
|
|
std::chrono::steady_clock::time_point lastFrameTime = std::chrono::steady_clock::now();
|
|
|
|
|
float fpsLimit = 10000.0f;
|
|
|
|
|
|
|
|
|
|
Vector3f userColor;
|
|
|
|
|
|
|
|
|
|
struct Window {
|
2025-08-26 12:03:09 +03:00
|
|
|
std::chrono::steady_clock::duration lastFrameTime = std::chrono::milliseconds(16);
|
2025-07-06 20:43:53 +03:00
|
|
|
Vector2i size = {-1, -1};
|
|
|
|
|
Vector2i pos = {-1, -1};
|
|
|
|
|
Vector2i writtenSize = {-1, -1};
|
|
|
|
|
Vector2i writtenPos = {-1, -1};
|
|
|
|
|
bool maximized = false;
|
|
|
|
|
bool fullscreen = false;
|
|
|
|
|
SkColorType defaultColorType;
|
|
|
|
|
SkAlphaType defaultAlphaType;
|
2025-11-20 12:38:28 +03:00
|
|
|
int vsyncValue = 1;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
2025-11-23 12:53:50 +03:00
|
|
|
float density = 1.0f;
|
2025-07-06 20:43:53 +03:00
|
|
|
float scale = 1.0f;
|
2025-11-23 20:51:14 +03:00
|
|
|
#ifndef __EMSCRIPTEN__
|
|
|
|
|
bool applyDisplayScale = true;
|
|
|
|
|
#endif
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
int defaultMSAASampleCount = 0;
|
|
|
|
|
SkSurfaceProps defaultMSAASurfaceProps;
|
|
|
|
|
|
|
|
|
|
#ifdef USE_SKIA_BACKEND_GRAPHITE
|
|
|
|
|
std::function<skgpu::graphite::Recorder*()> recorder;
|
|
|
|
|
#elif USE_SKIA_BACKEND_GANESH
|
|
|
|
|
sk_sp<GrDirectContext> ctx;
|
|
|
|
|
#endif
|
|
|
|
|
sk_sp<SkSurface> surface;
|
|
|
|
|
|
|
|
|
|
SDL_Window* sdlWindow;
|
|
|
|
|
} window;
|
|
|
|
|
|
2025-11-16 10:42:01 +03:00
|
|
|
std::shared_ptr<FontData> fonts;
|
2025-07-06 20:43:53 +03:00
|
|
|
TimePoint deltaTime;
|
|
|
|
|
Toolbar toolbar;
|
|
|
|
|
std::shared_ptr<World> world;
|
|
|
|
|
|
|
|
|
|
std::ofstream* logFile;
|
|
|
|
|
std::deque<Toolbar::LogMessage> logMessages;
|
|
|
|
|
|
|
|
|
|
std::string newAddr;
|
|
|
|
|
|
|
|
|
|
MainProgram();
|
|
|
|
|
void update();
|
|
|
|
|
void draw(SkCanvas* canvas);
|
|
|
|
|
|
|
|
|
|
bool setToQuit = false;
|
|
|
|
|
|
|
|
|
|
void early_destroy();
|
|
|
|
|
|
|
|
|
|
void new_tab(const World::OpenWorldInfo& tabInfo, bool createSameThread = false);
|
|
|
|
|
void set_tab_to_close(size_t tabToClose);
|
|
|
|
|
bool network_being_used();
|
|
|
|
|
bool net_server_hosted();
|
2025-07-08 12:18:55 +03:00
|
|
|
void update_display_names();
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
void save_config();
|
|
|
|
|
void load_config();
|
|
|
|
|
|
2025-10-27 20:19:47 +03:00
|
|
|
void init_net_library();
|
2025-11-20 12:38:28 +03:00
|
|
|
void set_vsync_value(int vsyncValue);
|
2025-11-23 12:53:50 +03:00
|
|
|
void update_scale_and_density();
|
|
|
|
|
float get_scale_and_density_factor_gui();
|
2025-10-27 20:19:47 +03:00
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
std::filesystem::path homePath;
|
|
|
|
|
std::filesystem::path configPath;
|
|
|
|
|
|
|
|
|
|
bool drawGui = true;
|
|
|
|
|
bool takingScreenshot = false;
|
|
|
|
|
bool transparentBackground = false;
|
|
|
|
|
|
2025-08-01 20:07:47 +03:00
|
|
|
Vector3f defaultCanvasBackgroundColor = DEFAULT_CANVAS_BACKGROUND_COLOR;
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
size_t worldIndex = 0;
|
|
|
|
|
std::vector<std::shared_ptr<World>> worlds;
|
|
|
|
|
|
|
|
|
|
std::string displayName;
|
|
|
|
|
|
|
|
|
|
~MainProgram();
|
|
|
|
|
private:
|
|
|
|
|
void new_tab_open();
|
|
|
|
|
std::atomic<bool> tabSetToOpen = false;
|
|
|
|
|
World::OpenWorldInfo newTabToOpenInfo;
|
|
|
|
|
|
|
|
|
|
std::optional<size_t> setTabToClose;
|
|
|
|
|
|
|
|
|
|
std::string gen_random_display_name();
|
|
|
|
|
|
|
|
|
|
void gui();
|
|
|
|
|
void draw_grid(SkCanvas* canvas);
|
|
|
|
|
};
|