Current State !! <3

This commit is contained in:
2025-02-12 11:44:50 -05:00
parent 3bd4716fcd
commit 0121af5178
9 changed files with 108 additions and 50 deletions

View File

@@ -15,16 +15,14 @@
#include <Client/Console.hpp>
#include <Client/TileTool.hpp>
namespace CaveGame::ClientApp
{
namespace CaveGame::ClientApp {
using CaveGame::Client::Scene;
using CaveGame::Client::SceneManager;
/// The main program class. Everything originates here.
/// This class is derived from RWindow class.
class CaveGameWindow : public ReWindow::OpenGLWindow, public SceneManager
{
class CaveGameWindow : public ReWindow::OpenGLWindow, public SceneManager {
public:
[[nodiscard]] bool InGameSession() const;
[[nodiscard]] bool InMainMenu() const;
@@ -70,13 +68,7 @@ namespace CaveGame::ClientApp
void create_console_window();
void create_stats_window();
void create_settings_window();
void create_window_widgets();
/// This function sets up the initial program state, particularly that which must be performed **after** the window is opened.
void Init();
@@ -102,6 +94,12 @@ namespace CaveGame::ClientApp
void OnClosing() override;
protected:
void create_tool_window();
void create_console_window();
void create_stats_window();
void create_settings_window();
void create_window_widgets();
/// Draws a sequence of 'debug' information strings to the screen, in a descending list.
void draw_debug_info(std::vector<std::string> tokens);
void CreateMenuWindows();
@@ -109,13 +107,11 @@ namespace CaveGame::ClientApp
void CreateContexts();
void Gameloop();
void Step();
bool wanna_die = false; // This field indicates the program is ready to close.
void InGameControls(float elapsed);
void OnConsoleCommandInput(const std::string &command);
protected:
float tool_radius = 8.f;
float tool_percent = 100.f;
void create_tool_window();
bool wanna_die = false; // This field indicates the program is ready to close.
};
}

View File

@@ -110,15 +110,17 @@ namespace CaveGame::ClientApp
void CaveGameWindow::create_tool_window()
{
tile_tool = new Client::TileTool(wm);
tile_tool->BrushSizeChanged += [this] (float value)
{
tile_tool->BrushSizeChanged += [this] (float value) {
tool_radius = value;
};
tile_tool->BrushPercentChanged += [this] (float value)
{
tile_tool->BrushPercentChanged += [this] (float value) {
tool_percent = value;
};
tile_tool->TileSimulationDisabledChanged += [this] (bool value) {
// TODO: Check that current ctx is game context
game_ctx->world->SetTileSimulationEnabled(!value);
};
}
void CaveGameWindow::create_window_widgets()
@@ -137,7 +139,7 @@ namespace CaveGame::ClientApp
// Init Josh Graphics
auto size = GetSize();
Vector2 vsize = Vector2(size.x, size.y);
Vector2i vsize = Vector2i(size.x, size.y);
bool result = JGL::Init(vsize, 0.f, 0.f);
//JGL::InitTextEngine();
JGL::Update(vsize);
@@ -285,15 +287,15 @@ namespace CaveGame::ClientApp
InGameControls(elapsed);
}
tile_tool->Visible(InGame());
tile_tool->Enable(InGame());
//tile_tool->Visible(InGame());
//tile_tool->Enable(InGame());
}
void CaveGameWindow::Draw()
{
auto isize = GetSize();
Vector2 size = Vector2(isize.x, isize.y);
Vector2i size = Vector2i(isize.x, isize.y);
JGL::Update(size);
@@ -545,18 +547,30 @@ namespace CaveGame::ClientApp
wanna_die = true;
}
std::string str_tolower(const std::string& s)
{
std::string copy = s;
std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
return copy;
}
void CaveGameWindow::OnConsoleCommandInput(const std::string& command)
{
auto tokens = string_split(command, ' ');
if (str_tolower(tokens[0]) == "worldedit") {
tile_tool->Enable(!tile_tool->IsEnabled());
}
}
void CaveGameWindow::create_console_window() {
console_window = new Client::Console(this->wm);
console_window->Visible(false);
//console_window->
console_window->OnInput += [this] (const std::string& msg)
{
auto tokens = string_split(msg, ' ');
if (tokens[0] == "tp")
{
std::cout << "Teleport Command" << std::endl;
}
OnConsoleCommandInput(msg);
};
}