-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
492 changed files
with
177,213 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/****************************************************************************** | ||
* File: Logic.hpp | ||
* Authors: see AUTHORS file | ||
* Date: May 3, 2024 | ||
* Description: This file contains the API requests methods | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <iostream> | ||
#include <algorithm> | ||
#include <cpr/cpr.h> | ||
#include "rapidjson/document.h" | ||
#include "rapidjson/error/en.h" | ||
|
||
using namespace rapidjson; | ||
|
||
namespace Stuckfish | ||
{ | ||
// consider creating a C-style structure to hold games data and a vector of this structure in Logic. | ||
struct GamesData | ||
{ | ||
std::string pgn; | ||
std::string timeClass; | ||
std::string gameResult; | ||
std::string whiteRating; | ||
std::string blackRating; | ||
std::string whiteUsername; | ||
std::string blackUsername; | ||
}; | ||
|
||
class Logic | ||
{ | ||
public: | ||
Logic() : _gamesData() | ||
{}; | ||
|
||
bool IsChessDotComUser(const std::string& username); | ||
void GamesPlayedWithinPeriod(const std::string& username, const std::string& year, const std::string& month); | ||
void GetInfosFromListOfGamesPlayed(const std::string& username, const Document& doc); | ||
|
||
private: | ||
std::vector<GamesData> _gamesData; | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/****************************************************************************** | ||
* File: Stuckfish.hpp | ||
* Authors: see AUTHORS file | ||
* Date: May 3, 2024 | ||
* Description: This file contains the Core class and setup methods | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <stdio.h> | ||
#include <iostream> | ||
|
||
#include "imgui.h" | ||
#include "imgui_impl_glfw.h" | ||
#include "imgui_impl_opengl3.h" | ||
#include "imgui_stdlib.h" | ||
|
||
#include "fonts.hpp" | ||
#include "Page.hpp" | ||
|
||
#include <vector> | ||
|
||
#if defined(IMGUI_IMPL_OPENGL_ES2) | ||
#include <GLES2/gl2.h> | ||
#endif | ||
|
||
#include <GLFW/glfw3.h> // Will drag system OpenGL headers | ||
|
||
|
||
#ifdef __EMSCRIPTEN__ | ||
#include "../emscripten/emscripten_mainloop_stub.h" | ||
#endif | ||
|
||
#define GLSL_VERSION "#version 330" | ||
|
||
|
||
namespace Stuckfish | ||
{ | ||
struct WindowSpecs | ||
{ | ||
std::string name = "Stuckfish"; | ||
uint32_t width = 1500; | ||
uint32_t height = 800; | ||
}; | ||
|
||
class Core | ||
{ | ||
public: | ||
Core(const WindowSpecs& win_specs = WindowSpecs()); | ||
~Core(); | ||
|
||
void Run(void); | ||
|
||
static Core& Get(void); | ||
|
||
template<typename T, typename... Args> | ||
void PushLayer(Args&&... args) { | ||
static_assert(std::is_base_of<Page, T>::value, "Pushed type is not subclass of Page!"); | ||
_pageStack.emplace_back(std::make_shared<T>(std::forward<Args>(args)...)); | ||
} | ||
|
||
/*template<typename T> | ||
T& GetLayer() { | ||
return dynamic_cast<T&>(*(_pageStack.front())); | ||
}*/ | ||
|
||
std::vector<std::shared_ptr<Page>>& GetPageStack(void) | ||
{ | ||
return _pageStack; | ||
} | ||
|
||
void DisplayErrorPopup(const char *error_message); | ||
void RemoveErrorPopup(void); | ||
|
||
public: | ||
ImFont* _robotoFontHeader = nullptr; | ||
ImFont* _robotoFontBody = nullptr; | ||
ImFont* _robotoFontBodyMedium = nullptr; | ||
|
||
WindowSpecs _specs; | ||
Logic _appLogic; | ||
UserData _userData; | ||
private: | ||
void Init(void); | ||
void Quit(void); | ||
|
||
private: | ||
GLFWwindow* _window = nullptr; | ||
|
||
std::vector<std::shared_ptr<Page>> _pageStack; | ||
}; | ||
|
||
std::unique_ptr<Core> CreateApplication(void); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/****************************************************************************** | ||
* File: GamesPlayedPage.hpp | ||
* Authors: see AUTHORS file | ||
* Date: May 3, 2024 | ||
* Description: This file contains the required method to render the 2nd Page | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "Stuckfish.hpp" | ||
|
||
namespace Stuckfish | ||
{ | ||
class GamesPlayedPage : public Page | ||
{ | ||
public: | ||
GamesPlayedPage(Core& app, Logic& logic, UserData& userData) : _app(app), _logic(logic), _userdata(userData) | ||
{}; | ||
|
||
void OnUpdate() override; | ||
void OnUIRender() override; | ||
void OnAttach() override; | ||
void OnDetach() override; | ||
|
||
private: | ||
Core& _app; | ||
Logic& _logic; | ||
UserData& _userdata; | ||
|
||
bool _hasRetrievedGames = false; | ||
}; | ||
} |
Oops, something went wrong.