8 Commits

32 changed files with 369 additions and 332 deletions

View File

@@ -34,7 +34,7 @@ include(cmake/CPM.cmake)
CPMAddPackage(
NAME mcolor
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-6.3.zip
URL https://git.redacted.cc/maxine/mcolor/archive/Release-1.zip
)
CPMAddPackage(
@@ -44,7 +44,7 @@ CPMAddPackage(
CPMAddPackage(
NAME jlog
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-17.zip
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-19.zip
)
CPMAddPackage(
@@ -54,22 +54,22 @@ CPMAddPackage(
CPMAddPackage(
NAME jstick
URL https://git.redacted.cc/josh/jstick/archive/Prerelease-3.zip
URL https://git.redacted.cc/josh/jstick/archive/Prerelease-4.zip
)
CPMAddPackage(
NAME ReWindow
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-32.zip
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-34.zip
)
CPMAddPackage(
NAME JGL
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-52.zip
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-58.zip
)
CPMAddPackage(
NAME JUI
URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-5.15.zip
URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-6.2.zip
)
CPMAddPackage(

View File

@@ -13,7 +13,6 @@ endif()
target_include_directories(CaveClient PUBLIC
${CaveCore_SOURCE_DIR}/include
# ${jstick_SOURCE_DIR}/include
${J3ML_SOURCE_DIR}/include
${JGL_SOURCE_DIR}/include
${JUI_SOURCE_DIR}/include

View File

@@ -74,16 +74,19 @@ namespace CaveGame::Client {
bool LoadFromQueue(float maxTimeExpenditure = 1e-3f);
bool LoadAsset(const AssetRequest& request);
bool IsLoadComplete() const { return queue.empty(); }
void EnqueueDefaultAssetsFolder();
std::string LastAsset() const { return last_asset_processed; }
unsigned int TotalQueued() const { return total_queued; }
unsigned int TotalLoaded() const { return total_loaded; }
/// Read the manifest.json file to know which assets to enqueue for the loading screen sequence.
void ParseManifest();
/// Load certain critical assets immediately.
void PreloadCertainAssets();
protected:

View File

@@ -1,46 +0,0 @@
/// CaveGame - A procedural 2D platformer sandbox.
/// Created by Josh O'Leary @ Redacted Software, 2020-2025
/// Contact: josh@redacted.cc
/// Contributors: william@redacted.cc maxi@redacted.cc
/// This work is dedicated to the public domain.
/// @file Console.hpp
/// @desc The client-side user interface for the command console.
/// @edit 1/28/2025
/// @auth Josh O'Leary
#pragma once
#include <JUI/Widgets/Window.hpp>
#include <JUI/Widgets/TextInputForm.hpp>
#include <JUI/Widgets/ScrollingRect.hpp>
#include <JUI/Widgets/ListLayout.hpp>
namespace CaveGame::Client {
using namespace JUI::UDimLiterals;
class Console : public JUI::Window {
public:
int index = 0;
Event<std::string> OnInput;
void OnInputEvent(const std::string& msg);
explicit Console(Widget* parent);
void Log(const std::string& message, const Color4& color = Colors::White);
void ObserveKeyInput(Key key, bool pressed) override;
bool IsOpen() const;
void SetOpen(bool open);
protected:
JUI::TextInputForm* input_box;
JUI::ScrollingRect* message_log_box;
JUI::VerticalListLayout* message_log_layout;
bool console_open = false;
std::vector<std::string> history;
private:
};
}

View File

@@ -26,7 +26,7 @@ namespace CaveGame {
: JUI::Window(parent)
{
auto layout = this->ViewportInstance();
this->SetTitle(title);
this->Title(title);
this->Size(JUI::UDim2::FromPixels(48*rows, 48*cols));
this->MinSize(Vector2(48*rows, 48*cols));
this->SetResizable(false);

View File

@@ -9,7 +9,6 @@
/// @edit 1/28/2025
/// @auth Josh O'Leary
#pragma once
#include <Client/Scene.hpp>
@@ -39,6 +38,9 @@ namespace CaveGame::Client {
class GameSession : public Scene {
public:
Event<> OnSessionExit;
Event<> RequestToggleSettings;
GameSession() = default;
explicit GameSession(bool createNewWorld);
void Update(float elapsed) override;
@@ -46,27 +48,12 @@ namespace CaveGame::Client {
void Load() override;
void Unload() override;
void PassWindowSize(const J3ML::LinearAlgebra::Vector2 &size) override;
void PassMouseInput(unsigned int a, bool b) override {
hud->ObserveMouseInput((JUI::MouseButton)a, b);
}
void PassMouseMovement(const J3ML::LinearAlgebra::Vector2 &pos) override {
void PassMouseInput(unsigned int a, bool b) override;
mouse_pos = pos;
world->mouse_pos = pos;
hud->ObserveMouseMovement(pos);
}
void PassMouseWheel(int wheel) override {
if (InputService::IsKeyDown(Keys::LeftShift)) {
float radius = tile_tool->BrushRadius();
radius -= wheel / 2.f;
radius = Math::Max(radius, 0.45f); // TODO: perform clamping inside the setter maybe?
tile_tool->BrushRadius(radius);
} else {
// TODO: hud->ObserveMouseWheel(wheel);
hotbar.OnMouseWheel(wheel);
}
void PassMouseMovement(const J3ML::LinearAlgebra::Vector2 &pos) override;
void PassMouseWheel(int wheel) override;
}
void PassKeyInput(Key key, bool pressed) override;
void SaveAndExit();
@@ -94,14 +81,9 @@ namespace CaveGame::Client {
RNG tool_rng;
private:
void WorldEditToolDrawTiles(TileID tile);
void WorldEditToolDrawTiles(int x, int y, int radius, int density, TileID tile);
void WorldEditToolDrawOverlay();
Vector2 MouseWorldPos();
Vector2 MouseWorldPos() const;
};
}

View File

@@ -30,7 +30,9 @@ namespace CaveGame::Client
public:
Event<SingleplayerSessionInfo> RequestWorld;
Event<> RequestQuit;
Event<> RequestShowCredits;
Event<> RequestToggleCredits;
Event<> RequestToggleSettings;
MainMenu();
void Update(float elapsed) override;
void Draw() override;

View File

@@ -8,39 +8,37 @@ namespace CaveGame::Client
{
using namespace JUI::UDimLiterals;
/// CaveGame's pause menu is implemented as a JUI::Rect overlay, parented to the GameSession::HUD().
class PauseMenuWidget : public JUI::Rect {
public:
Event<> OnSettingsButtonPressed;
Event<> OnQuitButtonPressed;
Event<> OnResumeButtonPressed;
Event<> OnSettingsButtonPressed;
Event<> OnQuitButtonPressed;
PauseMenuWidget() {
this->Size({100_percent, 100_percent}); // Full Screen.
this->BGColor({128, 128, 128, 128}); // Transparent Gray.
/// The default constructor initializes the pause menu, subordinate widgets, and lays out the visual properties of each.
PauseMenuWidget();
button_box = new JUI::Rect(this);
button_box->Size({150_px, 150_px});
/// Construct the Pause menu by specifying it's parent widget.
/// It is safe to assume the parent will **ALWAYS** be the Scene* instance GameSession::hud.
explicit PauseMenuWidget(Widget* parent);
button_list = new JUI::VerticalListLayout(button_box);
bool ObserveMouseInput(JUI::MouseButton btn, bool pressed) override;
resume_btn = new JUI::TextButton(button_list);
resume_btn->SetContent("Resume");
/// Switches the PauseMenu to it's alternate state, which is either "Open" or "Closed".
void Toggle();
/// Sets the state of the PauseMenu.
void SetOpen(bool value);
settings_btn = new JUI::TextButton(button_list);
settings_btn->SetContent("Settings");
/// @return The state of the PauseMenu.
[[nodiscard]] bool GetOpen() const;
quit_btn = new JUI::TextButton(button_list);
quit_btn->SetContent("Save & Exit World");
}
/// Sets the state of the PauseMenu to "Open".
void Open();
explicit PauseMenuWidget(Widget* parent) : PauseMenuWidget() {
this->Parent(parent);
}
/// Sets the state of the Paus
void Close();
void Toggle() {
is_open = !is_open;
this->Visible(is_open);
}
protected:
JUI::Rect* button_box;
JUI::VerticalListLayout* button_list;
@@ -51,6 +49,4 @@ namespace CaveGame::Client
bool is_open;
private:
};
}

View File

@@ -21,7 +21,10 @@ namespace CaveGame::Client
void ChangeScene(Scene* new_scene);
Scene* CurrentScene();
protected:
void UpdateSceneState(float elapsed);
protected:
Scene* next_scene = nullptr;
Scene* current_scene = nullptr;
private:
Scene* prev_scene = nullptr;
};
}

View File

@@ -20,35 +20,53 @@
namespace CaveGame::Client {
// TODO: Analyze behavior of singleton on an object that requires specific initialization, like this.
class SettingsMenu : public JUI::Window, public Singleton<SettingsMenu>
class SettingsMenu : public JUI::Window
{
public:
SettingsMenu()
{
SetTitle("Settings");
auto* root_layout = new JUI::VerticalListLayout(this);
using namespace JUI::UDimLiterals;
Title("Settings");
Size({400_px, 400_px});
auto* root_layout = new JUI::VerticalListLayout(this->ViewportInstance());
general_section = new JUI::Collapsible(root_layout);
general_section->Size({100_percent, 100_px});
general_section->Title("General");
auto* gen_layout = new JUI::VerticalListLayout(general_section);
sound_section = new JUI::Collapsible(root_layout);
sound_section->Size({100_percent, 100_px});
sound_section->Title("Sound");
auto* snd_layout = new JUI::VerticalListLayout(sound_section);
graphics_section = new JUI::Collapsible(root_layout);
graphics_section->Size({100_percent, 100_px});
graphics_section->Title("Graphics");
auto* gfx_layout = new JUI::VerticalListLayout(graphics_section);
input_section = new JUI::Collapsible(root_layout);
input_section->Size({100_percent, 100_px});
input_section->Title("Input");
Close();
}
explicit SettingsMenu(Widget* parent) : SettingsMenu()
{
Parent(parent);
}
protected:
JUI::Collapsible* general_section;
JUI::Collapsible* sound_section;

View File

@@ -15,18 +15,7 @@ CaveGame::Client::AssetService::AssetService() {
ParseManifest();
}
void CaveGame::Client::AssetService::TempLoadSimple() {
//player_sprite = new JGL::Texture("assets/textures/player.png", JGL::FilteringMode::NEAREST);
//explosion_sprite = new JGL::Texture("assets/textures/explosion.png", JGL::FilteringMode::NEAREST);
//title_img = new JGL::Texture("assets/textures/title_1.png");
}
void CaveGame::Client::AssetService::EnqueueDefaultAssetsFolder() {
//EnqueueContents("assets");
//textures.emplace("player", new JGL::Texture("assets/textures/player.png"));
}
std::string CaveGame::Client::AssetService::FilenameFromPath(const std::filesystem::path &path) {
return path.string().substr(path.string().find_last_of("/\\") + 1);
@@ -55,7 +44,7 @@ void CaveGame::Client::AssetService::EnqueueSound(const std::string& name, const
}
bool CaveGame::Client::AssetService::LoadAsset(const CaveGame::Client::AssetRequest &request) {
last_asset_processed = request.path;
last_asset_processed = request.path.string();
switch(request.type) {
case AssetType::TEXTURE: {
@@ -69,7 +58,7 @@ bool CaveGame::Client::AssetService::LoadAsset(const CaveGame::Client::AssetRequ
// TODO: We don't support this asset type yet!!!
}
}
last_asset_processed = request.path; //FilenameFromPath(request.path);
last_asset_processed = request.path.string(); //FilenameFromPath(request.path);
total_loaded++;
return true;
}

View File

@@ -13,7 +13,11 @@ namespace CaveGame::Client
// TODO: implement freecam panning via mouse.
Vector2 m = jstick::GetLeftThumbstickAxisNormalized();
Vector2 m = {0,0};
if (jstick::GetLeftThumbstickAxis().Magnitude() > 0.f)
m = jstick::GetLeftThumbstickAxisNormalized();
if (m.Magnitude() > 0.1f)
Move(m*elapsed);

View File

@@ -1,87 +0,0 @@
#include <Client/Console.hpp>
#include <Core/Loggers.hpp>
void CaveGame::Client::Console::OnInputEvent(const std::string &msg) {
Log(std::format(">{}", msg));
OnInput.Invoke(msg);
// TODO: Handle within JUI
input_box->SetAutoCompleteText("");
input_box->SetContent("");
}
CaveGame::Client::Console::Console(JUI::Widget *parent) : JUI::Window(parent)
{
this->SetTitle("Console");
message_log_box = new JUI::ScrollingRect(this->ViewportInstance());
message_log_box->Size(JUI::UDim2(0, -20, 1, 1));
message_log_layout = new JUI::VerticalListLayout(message_log_box);
message_log_layout->LayoutOrder(JUI::LayoutOrder::V::BOTTOM);
//message_log_view->Position(JUI::UDim2());
input_box = new JUI::TextInputForm(this->ViewportInstance());
input_box->SetContent("Test");
input_box->Size(JUI::UDim2(0, 20, 1, 0));
input_box->Position(JUI::UDim2(0, -20, 0, 1));
input_box->BGColor(Colors::Grays::DarkSlateGray);
input_box->SetTextSize(16);
input_box->SetAutoCompleteText("");
input_box->SetTextColor(Colors::White);
input_box->SetAutocompleteTextColor(Colors::White);
// TODO: input_box->ClearTextOnReturn(true);
input_box->OnReturn += [this] (const std::string& msg) {
OnInputEvent(msg);
};
CaveGame::Logs::Info.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Debug.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Warning.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Error.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Fatal.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Client.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Server.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Generator.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Lighting.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
// TODO: Integrate loggers into game console.
}
void CaveGame::Client::Console::Log(const std::string &message, const Color4& color) {
Color4 col_a = {64, 64, 64};
Color4 col_b = {92, 92, 92};
auto* entry = new JUI::TextRect(message_log_layout);
entry->Size({100_percent, 16_px});
entry->SetContent(message);
entry->LayoutOrder(index++);
entry->SetTextColor(Colors::Black);
entry->BGColor(index%2==0 ? col_a : col_b);
entry->SetTextSize(14);
entry->SetTextColor(color);
}
void CaveGame::Client::Console::ObserveKeyInput(Key key, bool pressed) {
if (!IsVisible())
return;
Widget::ObserveKeyInput(key, pressed);
}
void CaveGame::Client::Console::SetOpen(bool open) {
console_open = open;
if (open)
input_box->GrabFocus();
else
input_box->DropFocus();
Visible(open);
}
bool CaveGame::Client::Console::IsOpen() const { return console_open;}

View File

@@ -3,14 +3,14 @@
int line_index = 0;
JUI::TextRect* line_item(const std::string& content, int size, const Color4& color = Colors::White) {
auto* item = new JUI::TextRect();
item->SetFont(JGL::Fonts::Jupiteroid);
item->Font(JGL::Fonts::Jupiteroid);
item->Size({0,4+size,1.f,0.f});
item->SetTextSize(size);
item->SetContent(content);
item->TextSize(size);
item->Content(content);
item->AlignCenterHorizontally();
item->AlignTop();
item->BGColor({0,0,0,0});
item->SetTextColor(color);
item->TextColor(color);
item->BorderWidth(0);
item->LayoutOrder(line_index++);
return item;
@@ -20,7 +20,7 @@ JUI::Window *CaveGame::Client::CreateCreditsWindowWidget(JUI::Widget *parent) {
auto* credits_window = new JUI::Window(parent);
credits_window->SetTitleFont(JGL::Fonts::Jupiteroid);
credits_window->SetTitle("Credits");
credits_window->Title("Credits");
//credits_window->MinSize({250, 450});
//credits_window->Size({300, 450, 0, 0});
credits_window->Visible(false);

View File

@@ -1,5 +1,6 @@
#include <Client/GameSession.hpp>
#include <Core/Loggers.hpp>
#include <Client/SettingsMenu.hpp>
#include <JUI/Widgets/Rect.hpp>
#include <JUI/Widgets/ListLayout.hpp>
#include <JUI/UDim.hpp>
@@ -26,6 +27,9 @@ void CaveGame::Client::GameSession::Load() {
hud = new JUI::Scene();
pause_menu = new PauseMenuWidget(hud);
pause_menu->OnQuitButtonPressed += [this] (){ SaveAndExit();};
pause_menu->OnResumeButtonPressed += [this] () { pause_menu->Close(); };
pause_menu->OnSettingsButtonPressed += [this] () { RequestToggleSettings.Invoke(); };
hotbar = TileHotbar();
// TODO: Redundant, use the constructor.
@@ -42,10 +46,8 @@ void CaveGame::Client::GameSession::Load() {
//conn.Invoke(jstick::XBoxButton::BumperR);
//jstick::ButtonPressed.Invoke(jstick::XBoxButton::BumperL);
tile_tool = new TileTool(hud);
tile_tool->TileSimulationDisabledChanged += [this] (bool value) {
@@ -56,8 +58,6 @@ void CaveGame::Client::GameSession::Load() {
for (int i = 0; i < steps; i++)
World()->DoTileTiccs(0.f);
};
}
void CaveGame::Client::GameSession::Draw() {
@@ -69,16 +69,14 @@ void CaveGame::Client::GameSession::Draw() {
void CaveGame::Client::GameSession::SaveAndExit() {
world->SaveAndExit();
OnSessionExit.Invoke();
}
void CaveGame::Client::GameSession::WorldEditToolDrawTiles(int x, int y, int radius, int density, TileID tile)
{
void CaveGame::Client::GameSession::WorldEditToolDrawTiles(int x, int y, int radius, int density, TileID tile) {
tool_rng = RNG(x + y);
World()->SetTile(x, y, tile);
for (int dx = -radius; dx <= radius; ++dx)
for (int dy = -radius; dy <= radius; ++dy)
if (density >= 100 || density > tool_rng.Float(0, 99))
@@ -90,8 +88,7 @@ bool following = false;
Vector2 last = {0,0};
Vector2 CaveGame::Client::GameSession::MouseWorldPos()
{
Vector2 CaveGame::Client::GameSession::MouseWorldPos() const {
return World()->camera.ScreenToWorld(mouse_pos);
}
@@ -126,9 +123,6 @@ void CaveGame::Client::GameSession::WorldEditToolDrawTiles(TileID tile) {
last = floor_wc;
//}
}
void CaveGame::Client::GameSession::WorldEditToolControlsUpdate(float elapsed){
@@ -140,7 +134,6 @@ void CaveGame::Client::GameSession::WorldEditToolControlsUpdate(float elapsed){
}
WorldEditToolDrawTiles(Tiles()["air"].numeric_id);
} else {
if (following)
@@ -185,7 +178,9 @@ void CaveGame::Client::GameSession::Update(float elapsed) {
}
// Move the tile cursor when controller thumbstick is moved.
auto rstick = jstick::GetRightThumbstickAxisNormalized();
Vector2 rstick = {0,0};
if (jstick::GetRightThumbstickAxis().Magnitude() > 0)
rstick = jstick::GetRightThumbstickAxisNormalized();
if (rstick.Magnitude() > 0.1f)
{
@@ -229,9 +224,6 @@ CaveGame::Client::GameSession::GameSession(bool overwite_world) : Scene() {
// Spawn in the player when the world is first loaded up.
world->AddEntity(new Core::Player({0, 0}));
//hud = new JUI::Scene();
}
void CaveGame::Client::GameSession::PassWindowSize(const Vector2 &size) {
@@ -239,17 +231,40 @@ void CaveGame::Client::GameSession::PassWindowSize(const Vector2 &size) {
hud->SetViewportSize(size);
}
void CaveGame::Client::GameSession::PassMouseInput(unsigned int a, bool b) {
hud->ObserveMouseInput((JUI::MouseButton)a, b);
}
void CaveGame::Client::GameSession::PassMouseMovement(const J3ML::LinearAlgebra::Vector2 &pos) {
mouse_pos = pos;
world->mouse_pos = pos;
hud->ObserveMouseMovement(pos);
}
void CaveGame::Client::GameSession::PassMouseWheel(int wheel) {
if (InputService::IsKeyDown(Keys::LeftShift)) {
float radius = tile_tool->BrushRadius();
radius -= wheel / 2.f;
radius = Math::Max(radius, 0.45f); // TODO: perform clamping inside the setter maybe?
tile_tool->BrushRadius(radius);
} else {
// TODO: hud->ObserveMouseWheel(wheel);
hotbar.OnMouseWheel(wheel);
}
}
void CaveGame::Client::GameSession::PassKeyInput(Key key, bool pressed) {
// DO NOT chain input conditions with else; you will introduce biasing
if (key == Keys::Escape)
if (key == Keys::Escape && pressed)
pause_menu->Toggle();
hud->ObserveKeyInput(key, pressed);
hotbar.OnKeyInput(key, pressed);
}
void CaveGame::Client::GameSession::UnloadHUD() {
Logs::Info("Unloading player HUD.");
delete hud;

View File

@@ -35,9 +35,9 @@ void CaveGame::Client::TileHotbar::Load(CaveGame::Client::LocalWorld *world) {
item_label->BorderWidth(0);
item_label->BGColor({0,0,0,0});
item_label->AnchorPoint({1,0});
item_label->SetContent("Item Name Here");
item_label->SetTextColor(Colors::White);
item_label->SetTextSize(22);
item_label->Content("Item Name Here");
item_label->TextColor(Colors::White);
item_label->TextSize(22);
item_label->Size({200_px, 30_px});
item_label->Position({0_percent, JUI::UDim(-25, 0)});
item_label->AlignRight();
@@ -73,7 +73,7 @@ void CaveGame::Client::TileHotbar::Load(CaveGame::Client::LocalWorld *world) {
auto* canvas_texture = new Texture(Vector2i( icon_size, icon_size));
auto* tile_icon_canvas = new RenderTarget(canvas_texture, {0, 0, 0, 0});
JGL::J2D::Begin(tile_icon_canvas, true);
JGL::J2D::Begin(tile_icon_canvas, nullptr, true);
for (int x = 0; x < icon_size; x++)
for (int y = 0; y < icon_size; y++)
world->RenderTile(item.numeric_id, x, y, x, y);
@@ -85,9 +85,9 @@ void CaveGame::Client::TileHotbar::Load(CaveGame::Client::LocalWorld *world) {
auto* amount_label = new JUI::TextRect(cell);
amount_label->BGColor({0,0,0,0});
amount_label->AnchorPoint({1,1});
amount_label->SetContent("99x");
amount_label->SetTextColor(Colors::White);
amount_label->SetTextSize(18);
amount_label->Content("99x");
amount_label->TextColor(Colors::White);
amount_label->TextSize(18);
amount_label->Size({30_px, 30_px});
amount_label->Position({95_percent, 95_percent});
amount_label->AlignRight();
@@ -134,7 +134,7 @@ void CaveGame::Client::TileHotbar::Update(float elapsed) {
// Update item name label.
Core::TileID active_item = slots[slot_index];
item_label->SetContent(Tiles()[active_item].display_name);
item_label->Content(Tiles()[active_item].display_name);
// Set appearance of selected slot.
hotbar_elements[slot_index]->CornerRounding(8);

View File

@@ -335,7 +335,7 @@ namespace CaveGame::Client {
TileID t_id;
Core::Tile t_data;
JGL::J2D::Begin(destination, true);
JGL::J2D::Begin(destination, nullptr, true);
for (int x = 0; x < Core::Chunk::ChunkSize; x++)
{
for (int y = 0; y < Core::Chunk::ChunkSize; y++)

View File

@@ -4,6 +4,7 @@
#include "JUI/Widgets/Button.hpp"
#include "JUI/Widgets/Image.hpp"
#include "Client/AssetService.hpp"
#include <Client/SettingsMenu.hpp>
CaveGame::Client::MainMenu::MainMenu() : Scene()
{
@@ -54,9 +55,9 @@ T* create_widget(JUI::Widget* parent)
JUI::TextButton* CaveGame::Client::MainMenu::create_mainmenu_btn(const std::string& content, JUI::Widget* parent)
{
auto* btn = create_widget<JUI::TextButton>(parent);
btn->SetFont(JGL::Fonts::Jupiteroid);
btn->SetTextSize(24);
btn->SetTextColor(Colors::White);
btn->Font(JGL::Fonts::Jupiteroid);
btn->TextSize(24);
btn->TextColor(Colors::White);
btn->BaseBGColor(Colors::DarkGray);
btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
btn->BGColor(btn->BaseBGColor());
@@ -64,7 +65,7 @@ JUI::TextButton* CaveGame::Client::MainMenu::create_mainmenu_btn(const std::stri
btn->Size({0, 40, 1.f, 0});
btn->Enable();
btn->Center();
btn->SetContent(content);
btn->Content(content);
return btn;
}
@@ -116,19 +117,18 @@ void CaveGame::Client::MainMenu::BuildWidgets() {
};
//auto *sp_btn = create_mainmenu_btn("Singleplayer", button_list);
auto *settings_btn = create_mainmenu_btn("Settings", button_list);
//sp_btn->OnReleaseEvent += [this](Vector2 pos, MouseButton btn, bool b) {
// if (b)
// RequestWorld.Invoke({});
//};
settings_btn->OnReleaseEvent += [this] (Vector2 pos, JUI::MouseButton btn, bool b) mutable {
if (b)
RequestToggleSettings.Invoke();
};
auto *mp_btn = create_mainmenu_btn("Multiplayer", button_list);
auto *credits_btn = create_mainmenu_btn("Credits", button_list);
credits_btn->OnReleaseEvent += [this](Vector2 pos, JUI::MouseButton btn, bool b) {
if (b)
RequestShowCredits.Invoke();
RequestToggleCredits.Invoke();
};
// TODO: Replace with IconButton with steam logo

View File

@@ -0,0 +1,98 @@
#include <Client/PauseMenu.hpp>
namespace CaveGame::Client
{
PauseMenuWidget::PauseMenuWidget() {
this->Size({100_percent, 100_percent}); // Full Screen.
this->BGColor({32, 32, 32, 128}); // Transparent Gray.
this->ZIndex(1);
button_box = new JUI::Rect(this);
button_box->Size({150_px, 170_px});
button_box->AnchorPoint({0.f, 1.f});
button_box->Position({50_px, 100_percent - 50_px});
button_box->BGColor(Colors::Transparent);
button_box->BorderWidth(0);
button_list = new JUI::VerticalListLayout(button_box);
button_list->PaddingBottom(5_px);
resume_btn = new JUI::TextButton(button_list);
resume_btn->Size({100_percent, 50_px});
resume_btn->CornerRounding(7);
resume_btn->Center();
resume_btn->TextSize(24);
resume_btn->TextColor(Colors::White);
resume_btn->BaseBGColor(Colors::DarkGray);
resume_btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
resume_btn->BGColor(resume_btn->BaseBGColor());
resume_btn->Content("Resume");
resume_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) {
OnResumeButtonPressed.Invoke();
};
settings_btn = new JUI::TextButton(button_list);
settings_btn->Size({100_percent, 50_px});
settings_btn->CornerRounding(7);
settings_btn->Center();
settings_btn->TextSize(24);
settings_btn->TextColor(Colors::White);
settings_btn->BaseBGColor(Colors::DarkGray);
settings_btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
settings_btn->BGColor(settings_btn->BaseBGColor());
settings_btn->Content("Settings");
settings_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) {
OnSettingsButtonPressed.Invoke();
};
quit_btn = new JUI::TextButton(button_list);
quit_btn->Size({100_percent, 50_px});
quit_btn->CornerRounding(7);
quit_btn->Center();
quit_btn->TextSize(24);
quit_btn->TextColor(Colors::White);
quit_btn->BaseBGColor(Colors::DarkGray);
quit_btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
quit_btn->BGColor(quit_btn->BaseBGColor());
quit_btn->Content("Save & Exit World");
quit_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) {
OnQuitButtonPressed.Invoke();
};
// Default-initialize as closed.
this->Close();
}
PauseMenuWidget::PauseMenuWidget(Widget *parent): PauseMenuWidget() {
this->Parent(parent);
}
bool PauseMenuWidget::ObserveMouseInput(JUI::MouseButton btn, bool pressed) {
if (is_open)
return Rect::ObserveMouseInput(btn, pressed);
return false;
}
void PauseMenuWidget::Toggle() {
SetOpen(!GetOpen());
}
void PauseMenuWidget::SetOpen(bool value) {
is_open = value;
this->Visible(is_open);
}
bool PauseMenuWidget::GetOpen() const { return is_open; }
void PauseMenuWidget::Open() { SetOpen(true); }
void PauseMenuWidget::Close() { SetOpen(false); }
}

View File

@@ -43,8 +43,8 @@ void CaveGame::Core::Player::Draw() {
JGL::J2D::DrawPartialSprite(myAsset.get(), RenderTopLeft(), quad.minPoint, {16, 24}, 0, {0,0}, {1,1}, Colors::White, dir);
JGL::J2D::OutlineRect(Colors::Red, RenderTopLeft(), texture_center * 2.f);
JGL::J2D::OutlineRect(Colors::Blue, TopLeft(), bounding_box);
J2D::DrawString(Colors::White, std::format("vel: {},{}", Math::Round(velocity.x, 2), Math::Round(velocity.y, 2)), position.x, position.y-8, 0.5f, 8);
J2D::DrawString(Colors::White, std::format("ct: {} cd: {}", coll_tests, coll_hits), position.x, position.y-16, 0.5f, 8);
J2D::DrawString(Colors::White, std::format("vel: {},{}", Math::Round(velocity.x, 2), Math::Round(velocity.y, 2)), position.x, position.y-8, 8, 0.5f);
J2D::DrawString(Colors::White, std::format("ct: {} cd: {}", coll_tests, coll_hits), position.x, position.y-16, 8, 0.5f);
}
void CaveGame::Core::Player::Update(float elapsed) {
@@ -54,7 +54,7 @@ void CaveGame::Core::Player::Update(float elapsed) {
walking = false;
Vector2 dpad = jstick::GetDPadAxisNormalized();
Vector2 dpad = jstick::GetDPadAxis();
if (noclip) {
if (InputService::IsKeyDown(Keys::A) || dpad.x <= -0.5f)

View File

@@ -6,11 +6,31 @@ namespace CaveGame::Client
{
void SceneManager::ChangeScene(Scene* new_scene)
{
if (current_scene != nullptr)
current_scene->Unload();
next_scene = new_scene;
current_scene = new_scene;
current_scene->Load();
//if (current_scene != nullptr)
// current_scene->Unload();
//current_scene = new_scene;
//current_scene->Load();
}
void SceneManager::UpdateSceneState(float elapsed)
{
if (next_scene != nullptr)
{
if (current_scene != nullptr)
{
current_scene->Unload();
prev_scene = current_scene;
}
current_scene = next_scene;
current_scene->Load();
next_scene = nullptr;
}
}
Scene* SceneManager::CurrentScene() { return current_scene; }

View File

@@ -3,11 +3,8 @@
#include "Client/AssetService.hpp"
CaveGame::Client::Splash::Splash() : Scene()
{
//font = JGL::Font();
ComputeMatrixGlyphTable();
}
@@ -43,11 +40,11 @@ void CaveGame::Client::Splash::ComputeMatrixTextureCache()
Vector2i column_size = {(int) glyph_measurement.x, (int) glyph_measurement.y * 100};
auto* column = new JGL::RenderTarget(column_size, {0, 0, 0, 0}, false);
JGL::J2D::Begin(column, true);
JGL::J2D::Begin(column, nullptr, true);
for (int col = 0; col < 50; col++) {
Color4 text_col = Color4(32, 192, 92, 255 - (col*4));
JGL::J2D::DrawString(text_col, std::to_string(rand() % 2), 0, glyph_measurement.y * col, 1, 16);
JGL::J2D::DrawString(text_col, std::to_string(rand() % 2), 0, glyph_measurement.y * col, 16);
}
JGL::J2D::End();
@@ -120,15 +117,9 @@ void CaveGame::Client::Splash::Update(float elapsed)
AssetService::Get()->LoadFromQueue();
load_percent = (float)AssetService::Get()->TotalLoaded() / (float)AssetService::Get()->TotalQueued();
//if (load_percent < 1)
//load_percent += elapsed/2.f;
//else
//load_percent = 1;
//splash_timer -= elapsed;
}
void CaveGame::Client::Splash::Load() {
@@ -137,7 +128,6 @@ void CaveGame::Client::Splash::Load() {
ComputeMatrixTextureCache();
Scene::Load();
}
void CaveGame::Client::Splash::Unload() {

View File

@@ -3,7 +3,7 @@
CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
{
this->SetTitle(tool_title);
this->Title(tool_title);
this->MinSize({200, 400});
this->Size({200, 400, 0, 0});
this->Visible(false);
@@ -18,18 +18,18 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
tool_size_label = new TextRect(left_row_layout);
tool_size_label->Size({0, row_height, 1, 0});
tool_size_label->SetContent("Size: 8");
tool_size_label->Content("Size: 8");
tool_size_label->BGColor(Colors::Transparent);
//tool_size_label->LayoutOrder(1);
auto* tool_percent_label = new TextRect(left_row_layout);
tool_percent_label->Size({0, row_height, 1, 0});
tool_percent_label->SetContent("Percent: 100%");
tool_percent_label->Content("Percent: 100%");
tool_percent_label->BGColor(Colors::Transparent);
auto* tile_sim_label = new TextRect(left_row_layout);
tile_sim_label->Size({0, row_height, 1, 0});
tile_sim_label->SetContent("Pause Tile Sim:");
tile_sim_label->Content("Pause Tile Sim:");
tile_sim_label->BGColor(Colors::Transparent);
auto* col_right = new Rect(column_layout);
@@ -47,7 +47,7 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
brush_size_slider->ValueChanged += [&, this] (float val) mutable
{
float newval = val * 50;
tool_size_label->SetContent(std::format("Size: {}", Math::Round(newval, 1)));
tool_size_label->Content(std::format("Size: {}", Math::Round(newval, 1)));
BrushSizeChanged(newval);
};
brush_size_slider->CurrentValue(0.5f);
@@ -62,7 +62,7 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
brush_percent_slider->ValueChanged += [&, this, tool_percent_label] (float val) mutable
{
float newval = val * 100.f;
tool_percent_label->SetContent(std::format("Percent: {}%", Math::Floor(newval)));
tool_percent_label->Content(std::format("Percent: {}%", Math::Floor(newval)));
BrushPercentChanged(newval);
};
brush_percent_slider->CurrentValue(1.f);
@@ -85,7 +85,7 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
step_btn = new TextButton(left_row_layout);
step_btn->Size({100_percent, UDim(row_height, 0)});
step_btn->SetContent("Step");
step_btn->Content("Step");
step_btn->BGColor(Colors::LightGray);
step_btn->BaseBGColor(Colors::LightGray);
step_btn->Disable();
@@ -95,7 +95,7 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
step2_btn = new TextButton(left_row_layout);
step2_btn->Size({100_percent, UDim(row_height, 0)});
step2_btn->SetContent("Step 10");
step2_btn->Content("Step 10");
step2_btn->BGColor(Colors::LightGray);
step2_btn->BaseBGColor(Colors::LightGray);
step2_btn->Disable();
@@ -105,7 +105,7 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
step3_btn = new TextButton(left_row_layout);
step3_btn->Size({100_percent, UDim(row_height, 0)});
step3_btn->SetContent("Step 100");
step3_btn->Content("Step 100");
step3_btn->BGColor(Colors::LightGray);
step3_btn->BaseBGColor(Colors::LightGray);
step3_btn->Disable();
@@ -127,7 +127,7 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
void CaveGame::Client::TileTool::BrushRadius(float size) {
brush_size_slider->CurrentValue(size/50.f);
tool_size_label->SetContent(std::format("Size: {}", Math::Round(size, 1)));
tool_size_label->Content(std::format("Size: {}", Math::Round(size, 1)));
brush_radius = size;
}
@@ -144,7 +144,7 @@ float CaveGame::Client::TileTool::BrushRadius() { return brush_radius;}
void CaveGame::Client::TileTool::BrushDensity(float percent) {
brush_percent_slider->CurrentValue(percent / 100.f);
tool_size_label->SetContent(std::format("Density: {}", Math::Round(percent, 1)));
tool_size_label->Content(std::format("Density: {}", Math::Round(percent, 1)));
brush_density = percent;
}

View File

@@ -23,7 +23,7 @@
#include <JUI/Widgets/Window.hpp>
#include <Client/Scene.hpp>
#include <Client/SceneManager.hpp>
#include <Client/Console.hpp>
#include <JUI/Widgets/CommandLine.hpp>
#include <Client/TileTool.hpp>
#include "Command.hpp"
#include <Core/Player.hpp>
@@ -69,7 +69,7 @@ namespace CaveGame::ClientApp {
bool ReadyToClose() const;
/// Returns the game's console GUI, which accepts commands and displays log messages.
Client::Console* Console();
JUI::CommandLine* Console();
/// Returns the Scene that holds global menu windows, which can appear in any game-context.
JUI::Scene* WindowManager();
/// Returns the active game-world session, if it exists.
@@ -165,7 +165,7 @@ namespace CaveGame::ClientApp {
}},
{"tilesim", {"q"}, [this](const CommandArgs& args) { return ToggleTileSim(args);}},
{"grid", {"q"}, [this](const CommandArgs& args) {}},
{"credits", {"q"}, [this](const CommandArgs& args) { credits_window->Visible(!credits_window->IsVisible()); }},
{"credits", {"q"}, [this](const CommandArgs& args) { credits_window->Toggle(); }},
{"settings", {"q"}, [this](const CommandArgs& args) {}},
{"spawn", {}, [this](const CommandArgs& args) {
if (!InGame())
@@ -261,7 +261,7 @@ namespace CaveGame::ClientApp {
JUI::Window* settings_window = nullptr;
JUI::Window* credits_window = nullptr;
Client::Console* console_window = nullptr;
JUI::CommandLine* console_window = nullptr;
JUI::Window* stats_window = nullptr;
protected: // Primitive class members.
/// This field indicates the program is ready to close.

View File

@@ -26,6 +26,7 @@
int main(int argc, char** argv) {
mcolor::windowsSaneify();
// Hide logs from engine components so we can focus on CaveGame.
JGL::Logger::Warning.EnableConsole(false);
JGL::Logger::Debug.EnableConsole(false);

View File

@@ -1,7 +1,7 @@
#include <Client/CreditsWindow.hpp>
#include "ClientApp/CaveGameWindow.hpp"
#include <Client/SettingsMenu.hpp>
#include <bits/random.h>
#include <Core/Explosion.hpp>
#include <Core/Loggers.hpp>
#include <Core/Player.hpp>
@@ -11,6 +11,7 @@
#include <Core/ItemRegistry.hpp>
#include <Core/TileRegistry.hpp>
#include <JJX/JSON.hpp>
#include <JUI/Widgets/FpsGraph.hpp>
namespace CaveGame::ClientApp {
@@ -46,8 +47,17 @@ namespace CaveGame::ClientApp {
{
Logs::Info(std::format("Game session requested.", info.NewWorld));
game_ctx = new CaveGame::Client::GameSession(info.NewWorld);
// TODO: Parse Info to construct gameworld files.
ChangeScene(game_ctx);
game_ctx->RequestToggleSettings += [&, this] {
settings_window->Toggle();
};
game_ctx->OnSessionExit += [&, this] {
ChangeScene(menu_ctx);
};
}
void CaveGameWindow::CreateContexts()
@@ -56,18 +66,15 @@ namespace CaveGame::ClientApp {
splash_ctx = new CaveGame::Client::Splash();
Logs::Info("Building main menu.");
menu_ctx = new CaveGame::Client::MainMenu();
game_ctx = new CaveGame::Client::GameSession();
menu_ctx->RequestWorld += [this](Client::SingleplayerSessionInfo info) {
OpenWorld(info);
};
menu_ctx->RequestQuit += [this]() {
Die();
};
menu_ctx->RequestShowCredits += [this]()
{
credits_window->Visible(true);
};
menu_ctx->RequestQuit += [this] { Die(); };
menu_ctx->RequestToggleCredits += [this]{ credits_window->Toggle(); };
menu_ctx->RequestToggleSettings += [this] { settings_window->Toggle(); };
game_ctx = new CaveGame::Client::GameSession();
}
void CaveGameWindow::CreateMenuWindows()
@@ -86,7 +93,9 @@ namespace CaveGame::ClientApp {
if (this->max_fps > 0) {
float min_delta = 1.f / max_fps;
float delta_diff = min_delta - dt;
std::this_thread::sleep_for(std::chrono::microseconds((int)(delta_diff*1000*1000)));
// TODO: only guaranteed to sleep *at least* as long as we request!
// Fake bias to sleep for less time than we want, so it averages out?
//std::this_thread::sleep_for(std::chrono::microseconds((long long)(delta_diff*1000*500)));
}
auto sure_end = GetTimestamp();
@@ -103,7 +112,7 @@ namespace CaveGame::ClientApp {
void CaveGameWindow::Run()
{
int js = jstick::Connect();
int js = 0;//jstick::Connect();
//this->SetRenderer(RenderingAPI::OPENGL);
bool success = this->Open();
@@ -121,10 +130,6 @@ namespace CaveGame::ClientApp {
this->assets.PreloadCertainAssets();
this->assets.ParseManifest();
// TODO: Replace w/ constructor?
this->assets.TempLoadSimple();
this->assets.EnqueueDefaultAssetsFolder();
//for (int i = 0; i < 10; i++)
//{
//assets.EnqueueTexture("assets/textures/redacted.png");
@@ -158,10 +163,7 @@ namespace CaveGame::ClientApp {
void CaveGameWindow::create_settings_window()
{
settings_window = new JUI::Window(wm);
settings_window->SetTitleFont(JGL::Fonts::Jupiteroid);
settings_window->SetTitle("Settings");
settings_window->Visible(false);
settings_window = new Client::SettingsMenu(wm);
}
@@ -171,6 +173,17 @@ namespace CaveGame::ClientApp {
credits_window = Client::CreateCreditsWindowWidget(wm);
create_stats_window();
create_settings_window();
// TODO: Swap out with FpsGraphWindow on next JUI release.
auto* graph_window = new JUI::Window(wm);
graph_window->Name("FPS Graph");
graph_window->Title("FPS Graph");
graph_window->Size({500_px, 50_px});
auto* graph = new JUI::FpsGraph(graph_window->Content());
graph->Name("Graph");
graph->Size({500_px, 50_px});
}
void CaveGameWindow::Init()
@@ -216,7 +229,7 @@ namespace CaveGame::ClientApp {
{
text_size = JGL::Fonts::Jupiteroid.MeasureString(token, font_size);
JGL::J2D::FillRect(bg_color, pos, text_size);
JGL::J2D::DrawString(text_color, token, pos.x, pos.y, 1.f, font_size);
JGL::J2D::DrawString(text_color, token, pos.x, pos.y, font_size);
pos.y += text_size.y;
}
JGL::J2D::End();
@@ -240,9 +253,10 @@ namespace CaveGame::ClientApp {
void CaveGameWindow::Update(float elapsed)
{
jstick::ReadEventLoop();
SceneManager::UpdateSceneState(elapsed);
// Update floating windows.
wm->Update(elapsed);
@@ -529,8 +543,22 @@ namespace CaveGame::ClientApp {
}
void CaveGameWindow::create_console_window() {
console_window = new Client::Console(this->wm);
console_window = new JUI::CommandLine(this->wm);
console_window->Visible(false);
CaveGame::Logs::Info.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Debug.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Warning.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Error.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Fatal.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Client.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Server.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Generator.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
CaveGame::Logs::Lighting.OnLog += [this](std::string m, Color4 c) {Log(m, c); };
//console_window->
console_window->OnInput += [this] (const std::string& msg)
{
@@ -573,7 +601,7 @@ namespace CaveGame::ClientApp {
JUI::Scene *CaveGameWindow::WindowManager() { return wm;}
Client::Console *CaveGameWindow::Console() { return console_window; }
JUI::CommandLine *CaveGameWindow::Console() { return console_window; }
bool CaveGameWindow::ToggleTileSim(const CommandArgs &args) {
if (InGame())

View File

@@ -4,10 +4,10 @@
#include <string>
#include <sstream>
#include <numeric>
#include <filesystem>
std::vector<std::string> string_split(const std::string& s, char delim);
std::string string_build(const std::vector<std::string> &list, const std::string& delim = " ");
std::string read_file(const std::string &file_path);
std::string read_file(const std::filesystem::path& file_path);

View File

@@ -32,6 +32,26 @@ namespace CaveGame::Core {
static std::map<std::string, TileTiccFunc> ticc_funcs;
// TODO: Tile light filling algorithm.
// TODO: Ambient light from surface / certain biomes.
// TODO: Directional lights.
// TODO: Entity lights.
// TODO: Tinting when interact with certain tiles.
// TODO: Research recursive flood-fill algorithm.
struct light {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t intensity;
};
// TODO: Implement params for tile color interaction
// * Opacity
// * Illumination
// * What if we want to make tiles reactive, glow under UV, absorb light energy?
struct Tile {
std::string mnemonic_id;
std::string display_name;
@@ -47,6 +67,9 @@ namespace CaveGame::Core {
TileTiccFunc random_ticc_func;
std::vector<std::string> tags;
bool gravity;
bool opaque = true;
std::optional<Color3> illumination;
};
/*
*

View File

@@ -101,9 +101,6 @@ namespace CaveGame::Core {
std::unordered_map<Vector2i, Chunk*> GetChunkList();
void DoRandomTileTicks();
void DoForcedTileTicks();
void DoRandomTileTick(const Vector2i& coords, Chunk* chunk);
@@ -184,7 +181,7 @@ namespace CaveGame::Core {
std::vector<Vector2i> chunks_in_waiting;
ConcurrentQueue<Core::Chunk*> ServedChunks;
float tile_ticc_counter;
float tile_ticc_counter = 0;
float physics_ticc = 0;
// Ticcs per second.

View File

@@ -31,10 +31,10 @@ std::string string_build(const std::vector<std::string> &list, const std::string
// });
}
std::string read_file(const std::string &file_path) {
std::string read_file(const std::filesystem::path& file_path) {
std::ifstream file(file_path, std::ios::binary | std::ios::ate);
if (!file)
throw std::runtime_error("We couldn't find the file: " + file_path);
throw std::runtime_error("We couldn't find the file: " + file_path.string());
std::streamsize file_size;
file.seekg(0, std::ios::end);

View File

@@ -8,9 +8,11 @@ namespace CaveGame::Core {
texture_center = {8, 12};
}
void Player::Draw() { /* See Client/Player.cpp */}
void Player::Update(float elapsed) {/* See Client/Player.cpp */}
// TODO: This is ridiculously dumb and weird.
#ifndef _WIN32
void Player::Draw() {}
void Player::Update(float elapsed) {}
#endif
void Player::PhysicsUpdate(float elapsed) {
Humanoid::PhysicsUpdate(elapsed);

View File

@@ -353,7 +353,7 @@ namespace CaveGame::Core {
}
void World::DoForcedTileTicks() {
/*void World::DoForcedTileTicks() {
Tile tile;
for (auto& [coords, chunk] : loaded_chunks) {
@@ -378,7 +378,7 @@ namespace CaveGame::Core {
//if (tile != nullptr) {
if (tile.does_forced_ticc) {
// tile->ForcedTicc(this, 0, wx, wy);
//chunk->SetTileUpdateFlag(x, y, true);
//}
}
@@ -416,16 +416,16 @@ namespace CaveGame::Core {
// tile = GetByNumeric(at);
/*
if (tile != nullptr)
if (tile->DoesRandomTicc())
tile->RandomTicc(this, 0, wx, wy);
*/
//if ((tile != nullptr) && (tile->DoesRandomTicc()))
// tile->RandomTicc(this, 0, wx, wy);
}
}
}
}*/
void World::Save() {
for (auto& [coords, chunk] : loaded_chunks)