Skip to content

Commit

Permalink
fix(style): fix styles and remove previous solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
tolstenko committed Jun 11, 2024
1 parent 099ebb2 commit c01ad5b
Show file tree
Hide file tree
Showing 35 changed files with 319 additions and 317 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ if(EMSCRIPTEN)
set(ENABLE_TEST_COVERAGE OFF)
endif()

include(cmake/subdirlist.cmake)

include(external/external.cmake)

add_subdirectory(modules)
Expand Down
14 changes: 14 additions & 0 deletions cmake/subdirlist.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
macro(SUBDIRLIST result curdir)
file(
GLOB children CONFIGURE_DEPENDS
RELATIVE ${curdir}
${curdir}/*
)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
12 changes: 6 additions & 6 deletions core/WebRequest.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//#include "WebRequest.h"
//#ifndef __EMSCRIPTEN__
//# include "cpr/cpr.h"
//#endif
// #include "WebRequest.h"
// #ifndef __EMSCRIPTEN__
// # include "cpr/cpr.h"
// #endif
//
//// ref.: see https://github.com/libcpr/cpr/blob/master/test/post_tests.cpp
// WebRequest::WebRequest(std::string uri, WebRequestVerb verb = WebRequestVerb::GET, std::map<std::string, std::string> headers = {}) {
//#ifndef __EMSCRIPTEN__
// #ifndef __EMSCRIPTEN__
// cpr::Payload payload{};
// cpr::Session session;
// cpr::Header header;
Expand All @@ -16,5 +16,5 @@
// if (verb == WebRequestVerb::GET) {
// r = session.Get();
// }
//#endif
// #endif
// }
92 changes: 46 additions & 46 deletions core/WebRequest.h
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
//#ifndef MOBAGEN_WEBREQUEST_H
//#define MOBAGEN_WEBREQUEST_H
// #ifndef MOBAGEN_WEBREQUEST_H
// #define MOBAGEN_WEBREQUEST_H
//
//#include <memory>
//#include <string>
//#include <map>
// #include <memory>
// #include <string>
// #include <map>
//
// enum class WebRequestVerb { GET, POST, PUT };
// enum class WebRequestVerb { GET, POST, PUT };
//
// enum class ErrorCode {
// OK = 0,
// CONNECTION_FAILURE,
// EMPTY_RESPONSE,
// HOST_RESOLUTION_FAILURE,
// INTERNAL_ERROR,
// INVALID_URL_FORMAT,
// NETWORK_RECEIVE_ERROR,
// NETWORK_SEND_FAILURE,
// OPERATION_TIMEDOUT,
// PROXY_RESOLUTION_FAILURE,
// SSL_CONNECT_ERROR,
// SSL_LOCAL_CERTIFICATE_ERROR,
// SSL_REMOTE_CERTIFICATE_ERROR,
// SSL_CACERT_ERROR,
// GENERIC_SSL_ERROR,
// UNSUPPORTED_PROTOCOL,
// REQUEST_CANCELLED,
// TOO_MANY_REDIRECTS,
// UNKNOWN_ERROR = 1000,
//};
// enum class ErrorCode {
// OK = 0,
// CONNECTION_FAILURE,
// EMPTY_RESPONSE,
// HOST_RESOLUTION_FAILURE,
// INTERNAL_ERROR,
// INVALID_URL_FORMAT,
// NETWORK_RECEIVE_ERROR,
// NETWORK_SEND_FAILURE,
// OPERATION_TIMEDOUT,
// PROXY_RESOLUTION_FAILURE,
// SSL_CONNECT_ERROR,
// SSL_LOCAL_CERTIFICATE_ERROR,
// SSL_REMOTE_CERTIFICATE_ERROR,
// SSL_CACERT_ERROR,
// GENERIC_SSL_ERROR,
// UNSUPPORTED_PROTOCOL,
// REQUEST_CANCELLED,
// TOO_MANY_REDIRECTS,
// UNKNOWN_ERROR = 1000,
// };
//
// struct WebResponse {
// public:
// uint32_t status_code;
// std::string text;
// std::map<std::string, std::string> header;
// std::string url;
// // todo: cookies
// ErrorCode errorCode;
// std::string ErrorMessage;
// std::string raw_header{};
// std::string status_line{};
// std::string reason{};
// // todo: uploaded_bytes{};
// // todo: downloaded_bytes{};
//};
// struct WebResponse {
// public:
// uint32_t status_code;
// std::string text;
// std::map<std::string, std::string> header;
// std::string url;
// // todo: cookies
// ErrorCode errorCode;
// std::string ErrorMessage;
// std::string raw_header{};
// std::string status_line{};
// std::string reason{};
// // todo: uploaded_bytes{};
// // todo: downloaded_bytes{};
// };
//
// struct WebRequest {
// WebRequest(std::string uri, WebRequestVerb verb, std::map<std::string, std::string> headers);
//};
// struct WebRequest {
// WebRequest(std::string uri, WebRequestVerb verb, std::map<std::string, std::string> headers);
// };
//
//#endif // MOBAGEN_WEBREQUEST_H
// #endif // MOBAGEN_WEBREQUEST_H
82 changes: 41 additions & 41 deletions core/datastructures/Tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@
#include <vector>

// binary tree
template <Sortable T> struct BinaryTree {
struct Node {
T value;
Node* left = nullptr;
Node* right = nullptr;
explicit Node(T value) : value(value) {}
Node(T value, Node* left, Node* right) : value(value), left(left), right(right) {}

~Node() {
if (left) delete left;
if (right) delete right;
}
};

Node* root = nullptr;

void Add(T value) {
if (!root) {
root = new Node(value);
return;
}
Node* current = root;
while (true) {
if (value < current->value) {
if (current->left != nullptr) {
current = current->left;
} else {
current->left = new Node(value);
break;
}
} else {
if (current->right != nullptr) {
current = current->right;
} else {
current->right = new Node(value);
break;
}
}
}
}
};
// template <Sortable T> struct BinaryTree {
// struct Node {
// T value;
// Node* left = nullptr;
// Node* right = nullptr;
// explicit Node(T value) : value(value) {}
// Node(T value, Node* left, Node* right) : value(value), left(left), right(right) {}
//
// ~Node() {
// if (left) delete left;
// if (right) delete right;
// }
// };
//
// Node* root = nullptr;
//
// void Add(T value) {
// if (!root) {
// root = new Node(value);
// return;
// }
// Node* current = root;
// while (true) {
// if (value < current->value) {
// if (current->left != nullptr) {
// current = current->left;
// } else {
// current->left = new Node(value);
// break;
// }
// } else {
// if (current->right != nullptr) {
// current = current->right;
// } else {
// current->right = new Node(value);
// break;
// }
// }
// }
// }
//};

#endif // MOBAGEN_TREE_H
5 changes: 5 additions & 0 deletions core/datastructures/Vector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by Alexandre Tolstenko Nogueira on 2023.10.25.
//

#include "Vector.h"
37 changes: 37 additions & 0 deletions core/datastructures/Vector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef MOBAGEN_VECTOR_H
#define MOBAGEN_VECTOR_H
/***
*
* @brief This is just me trying to improve my skills dont use this as a vector replacement
*
* @tparam T data type to hold inside the container
*/
template <typename T> struct Vector {
private:
T* buffer;
// Constructors
// default (1)
// vector();
// explicit vector (const allocator_type& alloc);

// fill (2)
// explicit vector (size_type n, const allocator_type& alloc = allocator_type());
// vector (size_type n, const value_type& val, const allocator_type& alloc = allocator_type());

// range (3)
// template <class InputIterator> vector (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());

// copy (4)
// vector (const vector& x);vector (const vector& x, const allocator_type& alloc);

// move (5)
// vector (vector&& x);
// vector (vector&& x, const allocator_type& alloc);

// initializer list (6)
// vector (initializer_list<value_type> il, const allocator_type& alloc = allocator_type());

~Vector();
};

#endif // MOBAGEN_VECTOR_H
11 changes: 7 additions & 4 deletions core/datastructures/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
#include <functional>

template <typename T>
concept Hashable = requires(T a) {
concept HashableConcept = requires(T a) {
{ std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
};

template <typename T>
concept Integral = std::is_integral<T>::value;
concept IntegralConcept = std::integral<T>;

template <typename T>
concept Float = std::is_floating_point<T>::value;
concept FloatConcept = std::floating_point<T>;

template <typename T>
concept Sortable = requires(T a, T b) {
concept NumberConcept = std::integral<T> || std::floating_point<T>;

template <typename T>
concept SortableConcept = requires(T a, T b) {
{ a < b } -> std::convertible_to<bool>;
};

Expand Down
2 changes: 1 addition & 1 deletion core/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void Engine::Tick() {
toDestroy.clear();
}

ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(),window->sdlRenderer);
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(), window->sdlRenderer);
SDL_RenderPresent(window->sdlRenderer);
}

Expand Down
2 changes: 1 addition & 1 deletion core/scene/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Object {
static void DontDestroyOnLoad(const Object& object){};

public:
std::string ToString(){return _name;};
std::string ToString() { return _name; };
};

#endif // MOBAGEN_ENGINE_OBJECT_H_
3 changes: 2 additions & 1 deletion core/scene/ScriptableObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ScriptableObject : public Object {

// methods
template <typename T>
requires std::is_base_of<ScriptableObject, T>::value static T* CreateInstance(Engine* engine) { // todo: remove dependency of engine
requires std::is_base_of<ScriptableObject, T>::value
static T* CreateInstance(Engine* engine) { // todo: remove dependency of engine
return new T(engine);
}
};
Expand Down
12 changes: 6 additions & 6 deletions core/script/Script.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//#ifndef MOBAGEN_SCRIPT_H
//#define MOBAGEN_SCRIPT_H
// #ifndef MOBAGEN_SCRIPT_H
// #define MOBAGEN_SCRIPT_H
//
//#include <quickjspp.hpp>
// #include <quickjspp.hpp>
//
// class Script {
// class Script {
//
//};
// };
//
//#endif // MOBAGEN_SCRIPT_H
// #endif // MOBAGEN_SCRIPT_H
8 changes: 4 additions & 4 deletions core/script/ScriptManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//#include "ScriptManager.h"
//#include "quickjspp.hpp"
// #include "ScriptManager.h"
// #include "quickjspp.hpp"
//
// void ScriptManager::Initialize() {
// void ScriptManager::Initialize() {
//
//}
// }
8 changes: 4 additions & 4 deletions core/script/ScriptManager.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//#ifndef MOBAGEN_SCRIPTMANAGER_H
//#define MOBAGEN_SCRIPTMANAGER_H
// #ifndef MOBAGEN_SCRIPTMANAGER_H
// #define MOBAGEN_SCRIPTMANAGER_H
//
//#include "quickjspp.hpp"
// #include "quickjspp.hpp"
//
//// todo: generate bindings for quickjs. see https://github.com/ftk/quickjspp/tree/master/binding-generator
//
Expand All @@ -25,4 +25,4 @@
// ScriptManager() = default;
// };
//
//#endif // MOBAGEN_SCRIPTMANAGER_H
// #endif // MOBAGEN_SCRIPTMANAGER_H
6 changes: 3 additions & 3 deletions documentation/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
https://playground.diagram.codes/d/system-layers

```
V[core,engine,editor] with label "Architecture"
V[Interfaces,glue,engine,editor] with label "Architecture"
core=H["Math","Containers &\nData Converters","Log",platform] with label "Core"
glue=H["Math","Containers &\nData Converters","Log",platform] with label "Glue"
platform=H[mobile,desktop,web] with label "Platform Specific"
mobile=H["android","ios"] with label "Mobile"
desktop=H["win","osx","linux"] with label "Desktop"
web=H["wasm"] with label "WEB"
engine=H[orchestrator,rendering,physics,resource,animation,networking,gameplay] with label "Engine Modules"
engine=H[orchestrator,rendering,physics,resource,animation,networking,gameplay] with label "Modules"
rendering=V["GUI","Rendering","Shaders","Scripting","Materials"] with label "Graphics"
physics=V["Particles","Collision","RigidBody","Constraints"] with label "Physics"
Expand Down
Loading

0 comments on commit c01ad5b

Please sign in to comment.