Compare commits

..

3 Commits

Author SHA1 Message Date
207e930b1c add sqlite to view 2025-02-03 16:11:32 +01:00
1cf439ef03 Add Vapp 2025-02-03 14:24:55 +01:00
3651d07750 fix bug 2025-02-01 12:27:32 +01:00
6 changed files with 78 additions and 36 deletions

View File

@ -51,7 +51,7 @@ target_include_directories(server PRIVATE server/inc shared/inc)
add_executable(view
view/src/main.cpp
view/src/Vapp.cpp
shared/src/canvas/BackGround.cpp
shared/src/canvas/BackGroundColors.cpp
shared/src/canvas/Canvas.cpp

View File

@ -111,17 +111,16 @@ void checker()
if (type != SQL_NULL)
{
user_table_id = sql::column_int64(get_user_table_id_stmt, 0);
sql::bind_int64(rem_like_w_user_table_id_stmt, 1, user_table_id);
sql::step(rem_like_w_user_table_id_stmt);
sql::reset(rem_like_w_user_table_id_stmt);
sql::bind_int64(rem_user_table_id_stmt, 1, user_table_id);
sql::step(rem_user_table_id_stmt);
sql::reset(rem_user_table_id_stmt);
}
}
sql::reset(get_user_table_id_stmt);
sql::bind_int64(rem_like_w_user_table_id_stmt, 1, user_table_id);
sql::step(rem_like_w_user_table_id_stmt);
sql::reset(rem_like_w_user_table_id_stmt);
sql::bind_int64(rem_user_table_id_stmt, 1, user_table_id);
sql::step(rem_user_table_id_stmt);
sql::reset(rem_user_table_id_stmt);
}
if (new_gen)

View File

@ -14,7 +14,7 @@ const char get_unchecked[] = "SELECT USER_ID FROM user_table WHERE CHECKED = 0;"
const char get_gen[] = "SELECT lt.HASH, lt.POS, lt.LIKED FROM like_table lt JOIN user_table ut ON lt.USER_TABLE_ID = ut.ID WHERE ut.USER_ID = ? AND ut.GEN = ? ORDER BY lt.POS ASC;";
const char get_user_table_id[] = "SELECT ID FROM user_table WHERE USER_ID = ? AND GEN = ?;";
const char get_user_table_id[] = "SELECT ID FROM user_table WHERE USER_ID = ? AND GEN >= ?;";
const char rem_like_w_user_table_id[] = "DELETE FROM like_table WHERE USER_TABLE_ID = ?;";

15
view/inc/Vapp.hpp Normal file
View File

@ -0,0 +1,15 @@
#include "sql.hpp"
class Vapp
{
public:
void init();
void update();
void draw();
void deinit();
private:
bool showDemoWindow;
sqlite3 *db;
};

45
view/src/Vapp.cpp Normal file
View File

@ -0,0 +1,45 @@
#include <cinttypes>
#include "Vapp.hpp"
#include "values/Dna.hpp"
#include <rlImGui.h>
#include <imgui.h>
#include <raylib.h>
void Vapp::init()
{
sql::init();
sql::open(DB_NAME, &db);
}
void Vapp::update()
{
}
void Vapp::draw()
{
ClearBackground(RAYWHITE);
ImGui::DockSpaceOverViewport(0, NULL, ImGuiDockNodeFlags_PassthruCentralNode);
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("Window"))
{
if (ImGui::MenuItem("Demo Window", nullptr, showDemoWindow))
showDemoWindow = !showDemoWindow;
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
if (showDemoWindow)
ImGui::ShowDemoWindow(&showDemoWindow);
}
void Vapp::deinit()
{
sql::close(db);
}

View File

@ -1,51 +1,34 @@
#include <raylib.h>
#include <imgui.h>
#include <rlImGui.h>
#include "Vapp.hpp"
int main(int argc, char *argv[])
{
int screenWidth = 800;
int screenHeight = 800;
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
Vapp app;
InitWindow(screenWidth, screenHeight, "VIEW");
SetTargetFPS(60);
rlImGuiSetup(true);
app.init();
bool showDemoWindow = true;
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_DockingEnable;
while (!WindowShouldClose())
while (!WindowShouldClose())
{
app.update();
BeginDrawing();
rlImGuiBegin();
ClearBackground(RAYWHITE);
ImGui::DockSpaceOverViewport(0, NULL, ImGuiDockNodeFlags_PassthruCentralNode);
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("Window"))
{
if (ImGui::MenuItem("Demo Window", nullptr, showDemoWindow))
showDemoWindow = !showDemoWindow;
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
if (showDemoWindow)
ImGui::ShowDemoWindow(&showDemoWindow);
app.draw();
rlImGuiEnd();
EndDrawing();
}
app.deinit();
rlImGuiShutdown();
CloseWindow();
CloseWindow();
return 0;
}