BoredProject
This commit is contained in:
parent
3f2e6fdb4e
commit
b3d06906ff
9 changed files with 195 additions and 3 deletions
|
|
@ -25,3 +25,4 @@ add_subdirectory(Externals)
|
||||||
add_subdirectory(Connection)
|
add_subdirectory(Connection)
|
||||||
add_subdirectory(Graphics)
|
add_subdirectory(Graphics)
|
||||||
add_subdirectory(Objects)
|
add_subdirectory(Objects)
|
||||||
|
add_subdirectory(Chat)
|
||||||
|
|
|
||||||
33
Chat/CMakeLists.txt
Normal file
33
Chat/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.2)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
|
project(Chat)
|
||||||
|
|
||||||
|
### ---------------------- Externals --------------------- ###
|
||||||
|
set(BINDINGS_INCLUDE ${EXTERNALS}/glfw/include ${EXTERNALS}/glew/include)
|
||||||
|
set(BINDINGS_LIBS glfw glew_s Imgui Nanovg)
|
||||||
|
|
||||||
|
### ---------------------- Static Library --------------------- ###
|
||||||
|
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
|
||||||
|
file(GLOB HEADERS "./public/*.hpp")
|
||||||
|
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||||
|
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
|
||||||
|
target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${BINDINGS_LIBS})
|
||||||
|
|
||||||
|
### -------------------------- Examples -------------------------- ###
|
||||||
|
add_executable(ChatGUI applications/ChatGUI.cpp)
|
||||||
|
target_link_libraries(ChatGUI ${PROJECT_NAME} ${BINDINGS_LIBS})
|
||||||
|
target_include_directories(ChatGUI PRIVATE ${BINDINGS_INCLUDE})
|
||||||
|
|
||||||
|
### -------------------------- Tests -------------------------- ###
|
||||||
|
enable_testing()
|
||||||
|
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
||||||
|
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
||||||
|
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} Utils)
|
||||||
|
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib)
|
||||||
39
Chat/applications/ChatGUI.cpp
Normal file
39
Chat/applications/ChatGUI.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
#include "ClientGui.hpp"
|
||||||
|
#include "Window.hpp"
|
||||||
|
|
||||||
|
using namespace tp;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
ModuleManifest* deps[] = { &tp::gModuleChat, nullptr };
|
||||||
|
ModuleManifest testModule("ClientGUI", nullptr, nullptr, deps);
|
||||||
|
|
||||||
|
if (!testModule.initialize()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ChatAPI chat;
|
||||||
|
ClientGUI gui;
|
||||||
|
|
||||||
|
auto window = Window::createWindow(1000, 700, "Window 1");
|
||||||
|
|
||||||
|
if (window) {
|
||||||
|
|
||||||
|
window->getGraphics().getDebugGui().setFontSize(4);
|
||||||
|
|
||||||
|
while (!window->shouldClose()) {
|
||||||
|
window->processEvents();
|
||||||
|
|
||||||
|
gui.draw(chat);
|
||||||
|
|
||||||
|
window->draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window::destroyWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
testModule.deinitialize();
|
||||||
|
}
|
||||||
18
Chat/private/Chat.cpp
Normal file
18
Chat/private/Chat.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
#include "Chat.hpp"
|
||||||
|
|
||||||
|
#include "Graphics.hpp"
|
||||||
|
|
||||||
|
using namespace tp;
|
||||||
|
|
||||||
|
static ModuleManifest* deps[] = { &gModuleGraphics, nullptr };
|
||||||
|
|
||||||
|
ModuleManifest tp::gModuleChat = ModuleManifest("Chat", nullptr, nullptr, deps );
|
||||||
|
|
||||||
|
bool ChatAPI::isLogged() const {
|
||||||
|
return mLogged;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatAPI::login(const Credentials& credentials) {
|
||||||
|
mLogged = String::Logic::isEqualLogic(credentials.name, "111");
|
||||||
|
}
|
||||||
46
Chat/private/ClientGUI.cpp
Normal file
46
Chat/private/ClientGUI.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
#include "ClientGui.hpp"
|
||||||
|
#include "imgui.h"
|
||||||
|
|
||||||
|
using namespace tp;
|
||||||
|
using namespace ImGui;
|
||||||
|
|
||||||
|
void ClientGUI::draw(ChatAPI& api) {
|
||||||
|
|
||||||
|
if (Begin("window_name")) {
|
||||||
|
|
||||||
|
if (api.isLogged()) {
|
||||||
|
|
||||||
|
static int item_current1 = 0;
|
||||||
|
const char *items1[] = {"Never", "Gonna", "Give", "You", "Up"};
|
||||||
|
Combo("User", &item_current1, items1, IM_ARRAYSIZE(items1));
|
||||||
|
|
||||||
|
BeginListBox("History");
|
||||||
|
Text("as");
|
||||||
|
Text("asa");
|
||||||
|
EndListBox();
|
||||||
|
|
||||||
|
static char buff[1000];
|
||||||
|
InputTextMultiline("Message", buff, 1000);
|
||||||
|
|
||||||
|
if (Button("Send")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
InputText("Name", mCredentials.name, ChatAPI::Credentials::SIZE);
|
||||||
|
InputText("Pass", mCredentials.pass, ChatAPI::Credentials::SIZE);
|
||||||
|
|
||||||
|
if (mInvalidCredentials) {
|
||||||
|
Text("Invalid Credentials");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Button("Login")) {
|
||||||
|
api.login(mCredentials);
|
||||||
|
mInvalidCredentials = !api.isLogged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} End();
|
||||||
|
}
|
||||||
27
Chat/public/Chat.hpp
Normal file
27
Chat/public/Chat.hpp
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Module.hpp"
|
||||||
|
|
||||||
|
namespace tp {
|
||||||
|
|
||||||
|
extern ModuleManifest gModuleChat;
|
||||||
|
|
||||||
|
class ChatAPI {
|
||||||
|
public:
|
||||||
|
struct Credentials {
|
||||||
|
enum { SIZE = 64 };
|
||||||
|
tp::int1 name[SIZE] {0};
|
||||||
|
tp::int1 pass[SIZE] {0};
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
ChatAPI() = default;
|
||||||
|
[[nodiscard]] bool isLogged() const;
|
||||||
|
void login(const Credentials& credentials);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool mLogged = false;
|
||||||
|
Credentials mCredentials;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
13
Chat/public/ClientGui.hpp
Normal file
13
Chat/public/ClientGui.hpp
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Chat.hpp"
|
||||||
|
|
||||||
|
namespace tp {
|
||||||
|
class ClientGUI {
|
||||||
|
ChatAPI::Credentials mCredentials;
|
||||||
|
bool mInvalidCredentials = false;
|
||||||
|
public:
|
||||||
|
ClientGUI() = default;
|
||||||
|
void draw(ChatAPI& api);
|
||||||
|
};
|
||||||
|
}
|
||||||
4
Chat/tests/Tests.cpp
Normal file
4
Chat/tests/Tests.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -88,9 +88,20 @@ void Graphics::GUI::draw() {
|
||||||
halnf Graphics::GUI::getFontSize() const { return mContext->fontSizeMM; }
|
halnf Graphics::GUI::getFontSize() const { return mContext->fontSizeMM; }
|
||||||
halnf Graphics::GUI::getUIScale() const { return mContext->uiScale; }
|
halnf Graphics::GUI::getUIScale() const { return mContext->uiScale; }
|
||||||
|
|
||||||
void Graphics::GUI::setDPMM(ualni dpmm) { mContext->dpmm = dpmm; }
|
void Graphics::GUI::setDPMM(ualni dpmm) {
|
||||||
void Graphics::GUI::setFontSize(ualni size) { mContext->fontSizeMM = size; }
|
mContext->dpmm = dpmm;
|
||||||
void Graphics::GUI::setUIScale(ualni scale) { mContext->uiScale = scale; }
|
setStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::GUI::setFontSize(ualni size) {
|
||||||
|
mContext->fontSizeMM = size;
|
||||||
|
setStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::GUI::setUIScale(ualni scale) {
|
||||||
|
mContext->uiScale = scale;
|
||||||
|
setStyle();
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::GUI::drawDebugInfoWindow() {
|
void Graphics::GUI::drawDebugInfoWindow() {
|
||||||
ImGui::Begin("Debug Info");
|
ImGui::Begin("Debug Info");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue