#2 - Static linking & dependency reduction
This commit is contained in:
@@ -53,7 +53,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
if (!channel_set) {
|
||||
std::println(stderr, "Usage: {} [--host <ip>] [--port <port>] --channel <id>", argv[0]);
|
||||
// std::println(stderr, "Usage: {} [--host <ip>] [--port <port>] --channel <id>", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
messages.set_handler<mmo::chat::ChatMessageBroadcastRequest>(
|
||||
[](tw::msg::PeerId, const mmo::chat::ChatMessageBroadcastRequest& bcast) {
|
||||
std::println("[ch:{}] <{}> {}", bcast.channel_id(), bcast.sender_id(), bcast.message());
|
||||
// std::println("[ch:{}] <{}> {}", bcast.channel_id(), bcast.sender_id(), bcast.message());
|
||||
});
|
||||
|
||||
mmo::chat::JoinChannelRequest join;
|
||||
@@ -98,10 +98,10 @@ int main(int argc, char* argv[]) {
|
||||
[channel_id](std::span<const std::byte> data) {
|
||||
mmo::chat::JoinChannelResponse resp;
|
||||
resp.ParseFromArray(data.data(), static_cast<int>(data.size()));
|
||||
std::println("Joined channel {} successfully.", channel_id);
|
||||
// std::println("Joined channel {} successfully.", channel_id);
|
||||
});
|
||||
|
||||
std::println("Joined channel {}. Type a message and press Enter. Ctrl+C to quit.", channel_id);
|
||||
// std::println("Joined channel {}. Type a message and press Enter. Ctrl+C to quit.", channel_id);
|
||||
|
||||
while (!g_quit.load()) {
|
||||
fd_set fds;
|
||||
@@ -121,7 +121,7 @@ int main(int argc, char* argv[]) {
|
||||
[channel_id](std::span<const std::byte> data) {
|
||||
mmo::chat::SendChatMessageResponse resp;
|
||||
resp.ParseFromArray(data.data(), static_cast<int>(data.size()));
|
||||
std::println("Message sent to channel {}.", channel_id);
|
||||
// std::println("Message sent to channel {}.", channel_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||
tw::quicr
|
||||
loft::common
|
||||
loft::base
|
||||
${LIBDECOR_LIB}
|
||||
loft_window
|
||||
loft::render_graph
|
||||
tw::protocol
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL_events.h>
|
||||
#include <SDL3/SDL_keycode.h>
|
||||
#include <imgui_impl_sdl3.h>
|
||||
|
||||
#include <Window.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "debug/ComponentGui.hpp"
|
||||
#include "imgui.h"
|
||||
|
||||
namespace tw::io {
|
||||
|
||||
class InputManager {
|
||||
private:
|
||||
lft::win::Window* m_window;
|
||||
|
||||
bool m_is_quit;
|
||||
|
||||
float m_velocity_x;
|
||||
float m_velocity_y;
|
||||
|
||||
bool m_is_jumping;
|
||||
|
||||
bool m_is_pressed[4];
|
||||
|
||||
float m_motion_x;
|
||||
float m_motion_y;
|
||||
|
||||
public:
|
||||
GET(m_is_quit, is_quit);
|
||||
|
||||
float axis_y() const {
|
||||
float result = 0.0f;
|
||||
if(m_is_pressed[0]) {
|
||||
result += 1.0f;
|
||||
} if(m_is_pressed[1]) {
|
||||
result -= 1.0f;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float axis_x() const {
|
||||
float result = 0.0f;
|
||||
if(m_is_pressed[2]) {
|
||||
result += 1.0f;
|
||||
} if(m_is_pressed[3]) {
|
||||
result -= 1.0f;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GET(m_motion_x, motion_x);
|
||||
GET(m_motion_y, motion_y);
|
||||
|
||||
InputManager(lft::win::Window* window) :
|
||||
m_window(window),
|
||||
m_is_quit(false)
|
||||
{
|
||||
m_is_pressed[0] = m_is_pressed[1] = m_is_pressed[2] = m_is_pressed[3] = false;
|
||||
}
|
||||
|
||||
void update() {
|
||||
SDL_Event event;
|
||||
m_motion_x = 0.0f;
|
||||
m_motion_y = 0.0f;
|
||||
|
||||
while(m_window->poll_event(&event)) {
|
||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||
|
||||
switch(event.type) {
|
||||
case SDL_EVENT_QUIT:
|
||||
m_is_quit = true;
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP: {
|
||||
switch(event.key.key) {
|
||||
case SDLK_W:
|
||||
m_is_pressed[0] = event.key.down;
|
||||
break;
|
||||
case SDLK_S:
|
||||
m_is_pressed[1] = event.key.down;
|
||||
break;
|
||||
case SDLK_A:
|
||||
m_is_pressed[2] = event.key.down;
|
||||
break;
|
||||
case SDLK_D:
|
||||
m_is_pressed[3] = event.key.down;
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
m_motion_x = event.motion.xrel;
|
||||
m_motion_y = event.motion.yrel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class InputState {
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tw::dbg {
|
||||
|
||||
template<>
|
||||
class ComponentGui<tw::io::InputManager> {
|
||||
public:
|
||||
void draw(tw::io::InputManager* instance) {
|
||||
ImGui::SeparatorText("Character Body Component");
|
||||
|
||||
float motion[2] = {instance->motion_x(), instance->motion_y()};
|
||||
ImGui::InputFloat2("Motion", motion);
|
||||
|
||||
float axis[2] = {instance->axis_x(), instance->axis_y()};
|
||||
ImGui::InputFloat2("Axis", axis);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_vulkan.h"
|
||||
#include "imgui_impl_sdl2.h"
|
||||
#include "imgui_impl_sdl3.h"
|
||||
|
||||
#include "implot.h"
|
||||
#include "implot_internal.h"
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#include <SDL_events.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <tracy/Tracy.hpp>
|
||||
#include <memory>
|
||||
@@ -105,7 +104,7 @@ void Runtime::run() {
|
||||
}
|
||||
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
m_input_manager.update();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "imgui.h"
|
||||
#include "backends/imgui_impl_vulkan.h"
|
||||
#include "backends/imgui_impl_sdl2.h"
|
||||
#include "backends/imgui_impl_sdl3.h"
|
||||
|
||||
namespace tw::drw::gui {
|
||||
|
||||
@@ -73,7 +73,7 @@ lft::rg::RenderTaskBuilder ImGuiRenderPass::create_render_task() {
|
||||
const std::string font_path = "/home/martin/projects/mmo/external/imgui/misc/fonts/ProggyClean.ttf";
|
||||
io.Fonts->AddFontFromFileTTF(font_path.c_str(), 13.0f);
|
||||
auto init_info = create_imgui_init_info(info.gpu(), info.renderpass());
|
||||
ImGui_ImplSDL2_InitForVulkan(context->m_window->get_handle());
|
||||
ImGui_ImplSDL3_InitForVulkan(context->m_window->get_handle());
|
||||
ImGui_ImplVulkan_Init(&init_info);
|
||||
|
||||
context->is_initialized = true;
|
||||
|
||||
@@ -35,6 +35,7 @@ target_link_libraries(tw_server_lib
|
||||
Jolt
|
||||
protobuf::libprotobuf
|
||||
${Boost_LIBRARIES}
|
||||
${LIBDECOR_LIB}
|
||||
Tracy::TracyClient
|
||||
pqxx
|
||||
pq
|
||||
|
||||
Reference in New Issue
Block a user