Bunch of edits.

This commit is contained in:
2025-06-09 20:50:23 -05:00
parent 54eb43044d
commit 791f6bf4c3
22 changed files with 97 additions and 78 deletions

View File

@@ -34,7 +34,7 @@ include(cmake/CPM.cmake)
CPMAddPackage( CPMAddPackage(
NAME mcolor 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( CPMAddPackage(
@@ -44,7 +44,7 @@ CPMAddPackage(
CPMAddPackage( CPMAddPackage(
NAME jlog 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( CPMAddPackage(
@@ -54,22 +54,22 @@ CPMAddPackage(
CPMAddPackage( CPMAddPackage(
NAME jstick 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( CPMAddPackage(
NAME ReWindow 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( CPMAddPackage(
NAME JGL 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( CPMAddPackage(
NAME JUI NAME JUI
URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-5.16.zip URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-6.2.zip
) )
CPMAddPackage( CPMAddPackage(

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ namespace CaveGame::Client {
using namespace JUI::UDimLiterals; using namespace JUI::UDimLiterals;
SetTitle("Settings"); Title("Settings");
Size({400_px, 400_px}); Size({400_px, 400_px});
auto* root_layout = new JUI::VerticalListLayout(this->ViewportInstance()); auto* root_layout = new JUI::VerticalListLayout(this->ViewportInstance());

View File

@@ -44,7 +44,7 @@ void CaveGame::Client::AssetService::EnqueueSound(const std::string& name, const
} }
bool CaveGame::Client::AssetService::LoadAsset(const CaveGame::Client::AssetRequest &request) { bool CaveGame::Client::AssetService::LoadAsset(const CaveGame::Client::AssetRequest &request) {
last_asset_processed = request.path; last_asset_processed = request.path.string();
switch(request.type) { switch(request.type) {
case AssetType::TEXTURE: { case AssetType::TEXTURE: {
@@ -58,7 +58,7 @@ bool CaveGame::Client::AssetService::LoadAsset(const CaveGame::Client::AssetRequ
// TODO: We don't support this asset type yet!!! // 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++; total_loaded++;
return true; return true;
} }

View File

@@ -13,7 +13,11 @@ namespace CaveGame::Client
// TODO: implement freecam panning via mouse. // 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) if (m.Magnitude() > 0.1f)
Move(m*elapsed); Move(m*elapsed);

View File

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

View File

@@ -178,7 +178,9 @@ void CaveGame::Client::GameSession::Update(float elapsed) {
} }
// Move the tile cursor when controller thumbstick is moved. // 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) if (rstick.Magnitude() > 0.1f)
{ {

View File

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

View File

@@ -335,7 +335,7 @@ namespace CaveGame::Client {
TileID t_id; TileID t_id;
Core::Tile t_data; 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 x = 0; x < Core::Chunk::ChunkSize; x++)
{ {
for (int y = 0; y < Core::Chunk::ChunkSize; y++) for (int y = 0; y < Core::Chunk::ChunkSize; y++)

View File

@@ -55,9 +55,9 @@ T* create_widget(JUI::Widget* parent)
JUI::TextButton* CaveGame::Client::MainMenu::create_mainmenu_btn(const std::string& content, 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); auto* btn = create_widget<JUI::TextButton>(parent);
btn->SetFont(JGL::Fonts::Jupiteroid); btn->Font(JGL::Fonts::Jupiteroid);
btn->SetTextSize(24); btn->TextSize(24);
btn->SetTextColor(Colors::White); btn->TextColor(Colors::White);
btn->BaseBGColor(Colors::DarkGray); btn->BaseBGColor(Colors::DarkGray);
btn->HoveredBGColor(Colors::Blues::LightSteelBlue); btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
btn->BGColor(btn->BaseBGColor()); btn->BGColor(btn->BaseBGColor());
@@ -65,7 +65,7 @@ JUI::TextButton* CaveGame::Client::MainMenu::create_mainmenu_btn(const std::stri
btn->Size({0, 40, 1.f, 0}); btn->Size({0, 40, 1.f, 0});
btn->Enable(); btn->Enable();
btn->Center(); btn->Center();
btn->SetContent(content); btn->Content(content);
return btn; return btn;
} }

View File

@@ -24,12 +24,12 @@ namespace CaveGame::Client
resume_btn->Size({100_percent, 50_px}); resume_btn->Size({100_percent, 50_px});
resume_btn->CornerRounding(7); resume_btn->CornerRounding(7);
resume_btn->Center(); resume_btn->Center();
resume_btn->SetTextSize(24); resume_btn->TextSize(24);
resume_btn->SetTextColor(Colors::White); resume_btn->TextColor(Colors::White);
resume_btn->BaseBGColor(Colors::DarkGray); resume_btn->BaseBGColor(Colors::DarkGray);
resume_btn->HoveredBGColor(Colors::Blues::LightSteelBlue); resume_btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
resume_btn->BGColor(resume_btn->BaseBGColor()); resume_btn->BGColor(resume_btn->BaseBGColor());
resume_btn->SetContent("Resume"); resume_btn->Content("Resume");
resume_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) { resume_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) {
OnResumeButtonPressed.Invoke(); OnResumeButtonPressed.Invoke();
@@ -39,12 +39,12 @@ namespace CaveGame::Client
settings_btn->Size({100_percent, 50_px}); settings_btn->Size({100_percent, 50_px});
settings_btn->CornerRounding(7); settings_btn->CornerRounding(7);
settings_btn->Center(); settings_btn->Center();
settings_btn->SetTextSize(24); settings_btn->TextSize(24);
settings_btn->SetTextColor(Colors::White); settings_btn->TextColor(Colors::White);
settings_btn->BaseBGColor(Colors::DarkGray); settings_btn->BaseBGColor(Colors::DarkGray);
settings_btn->HoveredBGColor(Colors::Blues::LightSteelBlue); settings_btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
settings_btn->BGColor(settings_btn->BaseBGColor()); settings_btn->BGColor(settings_btn->BaseBGColor());
settings_btn->SetContent("Settings"); settings_btn->Content("Settings");
settings_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) { settings_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) {
OnSettingsButtonPressed.Invoke(); OnSettingsButtonPressed.Invoke();
@@ -54,12 +54,12 @@ namespace CaveGame::Client
quit_btn->Size({100_percent, 50_px}); quit_btn->Size({100_percent, 50_px});
quit_btn->CornerRounding(7); quit_btn->CornerRounding(7);
quit_btn->Center(); quit_btn->Center();
quit_btn->SetTextSize(24); quit_btn->TextSize(24);
quit_btn->SetTextColor(Colors::White); quit_btn->TextColor(Colors::White);
quit_btn->BaseBGColor(Colors::DarkGray); quit_btn->BaseBGColor(Colors::DarkGray);
quit_btn->HoveredBGColor(Colors::Blues::LightSteelBlue); quit_btn->HoveredBGColor(Colors::Blues::LightSteelBlue);
quit_btn->BGColor(quit_btn->BaseBGColor()); quit_btn->BGColor(quit_btn->BaseBGColor());
quit_btn->SetContent("Save & Exit World"); quit_btn->Content("Save & Exit World");
quit_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) { quit_btn->OnClickEvent += [this] (Vector2 pos, JUI::MouseButton state) {
OnQuitButtonPressed.Invoke(); OnQuitButtonPressed.Invoke();

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::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::Red, RenderTopLeft(), texture_center * 2.f);
JGL::J2D::OutlineRect(Colors::Blue, TopLeft(), bounding_box); 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("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, 0.5f, 8); 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) { void CaveGame::Core::Player::Update(float elapsed) {
@@ -54,7 +54,7 @@ void CaveGame::Core::Player::Update(float elapsed) {
walking = false; walking = false;
Vector2 dpad = jstick::GetDPadAxisNormalized(); Vector2 dpad = jstick::GetDPadAxis();
if (noclip) { if (noclip) {
if (InputService::IsKeyDown(Keys::A) || dpad.x <= -0.5f) if (InputService::IsKeyDown(Keys::A) || dpad.x <= -0.5f)

View File

@@ -40,11 +40,11 @@ void CaveGame::Client::Splash::ComputeMatrixTextureCache()
Vector2i column_size = {(int) glyph_measurement.x, (int) glyph_measurement.y * 100}; Vector2i column_size = {(int) glyph_measurement.x, (int) glyph_measurement.y * 100};
auto* column = new JGL::RenderTarget(column_size, {0, 0, 0, 0}, false); 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++) { for (int col = 0; col < 50; col++) {
Color4 text_col = Color4(32, 192, 92, 255 - (col*4)); 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(); JGL::J2D::End();

View File

@@ -3,7 +3,7 @@
CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent) CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
{ {
this->SetTitle(tool_title); this->Title(tool_title);
this->MinSize({200, 400}); this->MinSize({200, 400});
this->Size({200, 400, 0, 0}); this->Size({200, 400, 0, 0});
this->Visible(false); 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 = new TextRect(left_row_layout);
tool_size_label->Size({0, row_height, 1, 0}); 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->BGColor(Colors::Transparent);
//tool_size_label->LayoutOrder(1); //tool_size_label->LayoutOrder(1);
auto* tool_percent_label = new TextRect(left_row_layout); auto* tool_percent_label = new TextRect(left_row_layout);
tool_percent_label->Size({0, row_height, 1, 0}); 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); tool_percent_label->BGColor(Colors::Transparent);
auto* tile_sim_label = new TextRect(left_row_layout); auto* tile_sim_label = new TextRect(left_row_layout);
tile_sim_label->Size({0, row_height, 1, 0}); 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); tile_sim_label->BGColor(Colors::Transparent);
auto* col_right = new Rect(column_layout); 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 brush_size_slider->ValueChanged += [&, this] (float val) mutable
{ {
float newval = val * 50; 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); BrushSizeChanged(newval);
}; };
brush_size_slider->CurrentValue(0.5f); 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 brush_percent_slider->ValueChanged += [&, this, tool_percent_label] (float val) mutable
{ {
float newval = val * 100.f; 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); BrushPercentChanged(newval);
}; };
brush_percent_slider->CurrentValue(1.f); 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 = new TextButton(left_row_layout);
step_btn->Size({100_percent, UDim(row_height, 0)}); step_btn->Size({100_percent, UDim(row_height, 0)});
step_btn->SetContent("Step"); step_btn->Content("Step");
step_btn->BGColor(Colors::LightGray); step_btn->BGColor(Colors::LightGray);
step_btn->BaseBGColor(Colors::LightGray); step_btn->BaseBGColor(Colors::LightGray);
step_btn->Disable(); 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 = new TextButton(left_row_layout);
step2_btn->Size({100_percent, UDim(row_height, 0)}); 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->BGColor(Colors::LightGray);
step2_btn->BaseBGColor(Colors::LightGray); step2_btn->BaseBGColor(Colors::LightGray);
step2_btn->Disable(); 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 = new TextButton(left_row_layout);
step3_btn->Size({100_percent, UDim(row_height, 0)}); 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->BGColor(Colors::LightGray);
step3_btn->BaseBGColor(Colors::LightGray); step3_btn->BaseBGColor(Colors::LightGray);
step3_btn->Disable(); step3_btn->Disable();
@@ -127,7 +127,7 @@ CaveGame::Client::TileTool::TileTool(JUI::Widget *parent) : JUI::Window(parent)
void CaveGame::Client::TileTool::BrushRadius(float size) { void CaveGame::Client::TileTool::BrushRadius(float size) {
brush_size_slider->CurrentValue(size/50.f); 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; brush_radius = size;
} }
@@ -144,7 +144,7 @@ float CaveGame::Client::TileTool::BrushRadius() { return brush_radius;}
void CaveGame::Client::TileTool::BrushDensity(float percent) { void CaveGame::Client::TileTool::BrushDensity(float percent) {
brush_percent_slider->CurrentValue(percent / 100.f); 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; brush_density = percent;
} }

View File

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

View File

@@ -1,7 +1,7 @@
#include <Client/CreditsWindow.hpp> #include <Client/CreditsWindow.hpp>
#include "ClientApp/CaveGameWindow.hpp" #include "ClientApp/CaveGameWindow.hpp"
#include <Client/SettingsMenu.hpp> #include <Client/SettingsMenu.hpp>
#include <bits/random.h>
#include <Core/Explosion.hpp> #include <Core/Explosion.hpp>
#include <Core/Loggers.hpp> #include <Core/Loggers.hpp>
#include <Core/Player.hpp> #include <Core/Player.hpp>
@@ -11,6 +11,7 @@
#include <Core/ItemRegistry.hpp> #include <Core/ItemRegistry.hpp>
#include <Core/TileRegistry.hpp> #include <Core/TileRegistry.hpp>
#include <JJX/JSON.hpp> #include <JJX/JSON.hpp>
#include <JUI/Widgets/FpsGraph.hpp>
namespace CaveGame::ClientApp { namespace CaveGame::ClientApp {
@@ -50,11 +51,11 @@ namespace CaveGame::ClientApp {
// TODO: Parse Info to construct gameworld files. // TODO: Parse Info to construct gameworld files.
ChangeScene(game_ctx); ChangeScene(game_ctx);
game_ctx->RequestToggleSettings += [&, this] mutable { game_ctx->RequestToggleSettings += [&, this] {
settings_window->Toggle(); settings_window->Toggle();
}; };
game_ctx->OnSessionExit += [&, this] mutable { game_ctx->OnSessionExit += [&, this] {
ChangeScene(menu_ctx); ChangeScene(menu_ctx);
}; };
} }
@@ -92,7 +93,9 @@ namespace CaveGame::ClientApp {
if (this->max_fps > 0) { if (this->max_fps > 0) {
float min_delta = 1.f / max_fps; float min_delta = 1.f / max_fps;
float delta_diff = min_delta - dt; 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(); auto sure_end = GetTimestamp();
@@ -109,7 +112,7 @@ namespace CaveGame::ClientApp {
void CaveGameWindow::Run() void CaveGameWindow::Run()
{ {
int js = jstick::Connect(); int js = 0;//jstick::Connect();
//this->SetRenderer(RenderingAPI::OPENGL); //this->SetRenderer(RenderingAPI::OPENGL);
bool success = this->Open(); bool success = this->Open();
@@ -170,6 +173,17 @@ namespace CaveGame::ClientApp {
credits_window = Client::CreateCreditsWindowWidget(wm); credits_window = Client::CreateCreditsWindowWidget(wm);
create_stats_window(); create_stats_window();
create_settings_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() void CaveGameWindow::Init()
@@ -215,7 +229,7 @@ namespace CaveGame::ClientApp {
{ {
text_size = JGL::Fonts::Jupiteroid.MeasureString(token, font_size); text_size = JGL::Fonts::Jupiteroid.MeasureString(token, font_size);
JGL::J2D::FillRect(bg_color, pos, text_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; pos.y += text_size.y;
} }
JGL::J2D::End(); JGL::J2D::End();

View File

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

View File

@@ -101,9 +101,6 @@ namespace CaveGame::Core {
std::unordered_map<Vector2i, Chunk*> GetChunkList(); std::unordered_map<Vector2i, Chunk*> GetChunkList();
void DoRandomTileTicks();
void DoForcedTileTicks();
void DoRandomTileTick(const Vector2i& coords, Chunk* chunk); void DoRandomTileTick(const Vector2i& coords, Chunk* chunk);
@@ -184,7 +181,7 @@ namespace CaveGame::Core {
std::vector<Vector2i> chunks_in_waiting; std::vector<Vector2i> chunks_in_waiting;
ConcurrentQueue<Core::Chunk*> ServedChunks; ConcurrentQueue<Core::Chunk*> ServedChunks;
float tile_ticc_counter; float tile_ticc_counter = 0;
float physics_ticc = 0; float physics_ticc = 0;
// Ticcs per second. // 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); std::ifstream file(file_path, std::ios::binary | std::ios::ate);
if (!file) 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; std::streamsize file_size;
file.seekg(0, std::ios::end); file.seekg(0, std::ios::end);

View File

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

View File

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