From f36632c9fdecec22d8344e73ea888af57180b0f5 Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Wed, 24 Jan 2024 15:04:38 +0100 Subject: [PATCH] Added diagrams for documentation --- .gitignore | 2 + docs/diagrams/.clang-uml | 62 ++++++++++++++++++++++++++ docs/diagrams/classes.svg | 1 + docs/diagrams/howto.md | 12 +++++ docs/diagrams/includes.svg | 1 + docs/diagrams/includes_no_external.svg | 1 + docs/diagrams/sequence.svg | 1 + 7 files changed, 80 insertions(+) create mode 100644 docs/diagrams/.clang-uml create mode 100644 docs/diagrams/classes.svg create mode 100644 docs/diagrams/howto.md create mode 100644 docs/diagrams/includes.svg create mode 100644 docs/diagrams/includes_no_external.svg create mode 100644 docs/diagrams/sequence.svg diff --git a/.gitignore b/.gitignore index 1bee96c..31d3def 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,5 @@ Thumbs.db Desktop.ini compile_commands.json + +*.puml diff --git a/docs/diagrams/.clang-uml b/docs/diagrams/.clang-uml new file mode 100644 index 0000000..f987536 --- /dev/null +++ b/docs/diagrams/.clang-uml @@ -0,0 +1,62 @@ +compilation_database_dir: ../.. +output_directory: . +diagrams: + + includes: + type: include + relative_to: ../.. + glob: + - src/*.cpp + - include/*.h + generate_system_headers: true + include: + paths: + - src + - include + plantuml: + before: + - 'skinparam linetype ortho' + + includes_no_external: + type: include + relative_to: ../.. + glob: + - src/*.cpp + - include/*.h + include: + paths: + - src + - include + plantuml: + before: + - 'skinparam linetype ortho' + + classes: + type: class + relative_to: ../.. + glob: + - src/*.cpp + - include/*.h + include: + paths: + - src + - include + plantuml: + before: + - 'skinparam linetype ortho' + + load_map_example_sequence: + type: sequence + relative_to: ../.. + glob: + - src/*.cpp + - include/*.h + include: + paths: + - src + - include + start_from: + - function: "Map::loadMap(const char *,int,int)" + plantuml: + before: + - 'skinparam linetype ortho' \ No newline at end of file diff --git a/docs/diagrams/classes.svg b/docs/diagrams/classes.svg new file mode 100644 index 0000000..f1154c0 --- /dev/null +++ b/docs/diagrams/classes.svg @@ -0,0 +1 @@ +GameGame() : void~Game() : voidaddTile(int id, int x, int y) : voidclean() : voidgetWinner() : boolhandleEvents() : voidinit(const char * title, int xpos, int ypos, int width, int height, bool fullscreen) : voidrender() : voidrunning() const : boolupdate() : voidassets : AssetManager *colliders : std::vector<ColliderComponent *>counter : intevent : SDL_EventisRunning : boolrenderer : SDL_Renderer *window : SDL_Window *winner : boolcmp_stroperator()(const char * a, const char * b) const : boolTextureManagerTextureManager() : voidTextureManager(const TextureManager &) = deleted : void~TextureManager() : voidoperator=(const TextureManager &) = deleted : voiddraw(SDL_Texture * texture, SDL_Rect src, SDL_Rect dest) : voidget() : TextureManager &loadTexture(const char * fileName) : SDL_Texture *splitSpriteSheet(SDL_Texture * spriteSheet, int width, int height, int spritesOnSheet) : std::vector<SDL_Rect>texture_cache : std::map<const char *,SDL_Texture *,cmp_str>ManageraddEntity() : Entity &addToGroup(Entity * mEntity, Group mGroup) : voiddraw() : voidgetGroup(Group mGroup) : std::vector<Entity *> &refresh() : voidupdate() : voidentities : std::vector<std::unique_ptr<Entity>>groupedEntities : std::array<std::vector<Entity *>,MAX_GROUPS>MapMap() = default : void~Map() constexpr = default : voidloadMap(const char * path, int sizeX, int sizeY) : voidGroupLabelMAPPLAYERSENEMIESCOLLIDERSPROJECTILEHEARTSComponent~Component() constexpr = default : voiddraw() : voidinit() : voidupdate() : voidentity : Entity *AnimationAnimation() : voidAnimation(int i, int f, int s) : voidframes : intindex : intspeed : intAnimationTypeIDLEWALKSpriteComponentSpriteComponent() = default : voidSpriteComponent(const char * path) : voidSpriteComponent(const char * path, bool isAnimated) : void~SpriteComponent() : voiddraw() : voidinit() : voidplay(AnimationType type) : voidsetTexture(const char * path) : voidupdate() : voidanimated : boolanimationIndex : intanimations : std::map<AnimationType,Animation *>destRect : SDL_Rectframes : intspeed : intsrcRect : SDL_Recttexture : SDL_Texture *transform : TransformComponent *EntityEntity(Manager & mManager) : voidaddComponent<T,TArgs...>(TArgs &&... mArgs) : T &addGroup(Group mGroup) : voiddelGroup(Group mGroup) : voiddestroy() : voiddraw() const : voidgetComponent<T>() const : T &hasComponent<T>() const : _BoolhasGroup(Group mGroup) : boolisActive() const : boolupdate() const : voidactive : boolcomponentArray : ComponentArraycomponentBitSet : ComponentBitSetcomponents : std::vector<std::unique_ptr<Component>>groupBitSet : GroupBitSetmanager : Manager &Vector2DVector2D() : voidVector2D(float x, float y) : voidoperator*(const int & i) : Vector2D &zero() : Vector2D &x : floaty : floatTransformComponentTransformComponent() : voidTransformComponent(int scale) : voidTransformComponent(float x, float y) : voidTransformComponent(float x, float y, int scale) : voidTransformComponent(float x, float y, int w, int h, int scale) : voidinit() : voidupdate() : voidheight : intposition : Vector2Dscale : intspeed : intvelocity : Vector2Dwidth : intTextureDicttextureDictionary : const std::map<int,std::string>TileComponentTileComponent() = default : voidTileComponent(int x, int y, int w, int h, int id) : void~TileComponent() = default : voidinit() : voidpath : const char *sprite : SpriteComponent *textureDict : TextureDicttileID : inttileRect : SDL_Recttransform : TransformComponent *ColliderComponentColliderComponent(const char * tag) : voidinit() : voidremoveCollision() : voidupdate() : voidcollider : SDL_RecthasCollision : booltag : const char *transform : TransformComponent *KeyboardControllerKeyboardController() = default : voidKeyboardController(SDL_Scancode up, SDL_Scancode down, SDL_Scancode left, SDL_Scancode right, SDL_Scancode fire, Vector2D fireVelocity) : void~KeyboardController() constexpr = default : voidinit() : voidupdate() : voiddown : SDL_Scancodefire : SDL_ScancodefireCooldown : Uint32fireVelocity : Vector2Dkeystates : const Uint8 *lastFireTime : Uint32left : SDL_Scancodeplayer : TransformComponent *right : SDL_Scancodesprite : SpriteComponent *transform : TransformComponent *up : SDL_ScancodeProjectileComponentProjectileComponent(int range, int speed, Vector2D velocity, bool source) : void~ProjectileComponent() : voidgetSource() : boolinit() : voidupdate() : voiddistance : intrange : intsource : const boolspeed : inttransformComponent : TransformComponent *velocity : Vector2DHealthComponentHealthComponent(int health, Manager * manager, bool player) : void~HealthComponent() : voidcreateAllHearts() : voidcreateHeartComponents(int x) : voidgetDamage() : voidgetHealth() : intinit() : voidhealth : intmanager : Manager *player : boolAssetManagerAssetManager(Manager * manager) : void~AssetManager() : voidaddTexture(std::string id, const char * path) : voidcreateProjectile(Vector2D pos, Vector2D velocity, bool source, int scale, int range, int speed, const char * texturePath) : voidgetTexture(std::string id) : SDL_Texture *man : Manager *textures : std::map<std::string,SDL_Texture *>GameObjectGameObject(const char * texturesheet, int x, int y) : void~GameObject() constexpr = default : voidrender() : voidupdate() : voiddestRect : SDL_RectobjTexture : SDL_Texture *srcRect : SDL_RectxPos : intyPos : intcollidersassetsmanagerentitytransformpositionvelocitytransformspritetextureDicttransformtransformplayerspritefireVelocitytransformComponentvelocitymanagerman \ No newline at end of file diff --git a/docs/diagrams/howto.md b/docs/diagrams/howto.md new file mode 100644 index 0000000..01260b8 --- /dev/null +++ b/docs/diagrams/howto.md @@ -0,0 +1,12 @@ +Need [clang-uml](https://clang-uml.github.io/index.html) + +```sh +clang-uml +clang-uml --add-compile-flag -I/usr/lib/clang/16/include # might need additional flags, example for my machine +clang-uml --print-from -n load_map_example_sequence # to get availabel commands for sequence diagram +``` + +then use plant uml to generate an actual `.svg` vector graphic +```sh +plantuml -tsvg *.puml +``` \ No newline at end of file diff --git a/docs/diagrams/includes.svg b/docs/diagrams/includes.svg new file mode 100644 index 0000000..b2c3675 --- /dev/null +++ b/docs/diagrams/includes.svg @@ -0,0 +1 @@ +srcincludeGame.cppECS.cppTextureManager.cppMap.cppGameObject.cppKeyboardController.cppmain.cppVector2D.cppGame.hTextureManager.hManager.hConstants.hMap.hEntity.hComponent.hSpriteComponent.hAnimationHandler.hECS.hTransformComponent.hVector2D.hTileComponent.hTextureDict.hColliderComponent.hKeyboardController.hAssetManager.hComponents.hProjectileComponent.hHealthComponent.hGameObject.hstdio.hiostreamSDL.hSDL_image.hvectorstring.hSDL_render.hmaparraymemorybitsetalgorithmstringcstdiostdexceptfstream \ No newline at end of file diff --git a/docs/diagrams/includes_no_external.svg b/docs/diagrams/includes_no_external.svg new file mode 100644 index 0000000..fa6e813 --- /dev/null +++ b/docs/diagrams/includes_no_external.svg @@ -0,0 +1 @@ +srcincludeGame.cppECS.cppTextureManager.cppMap.cppGameObject.cppKeyboardController.cppmain.cppVector2D.cppGame.hTextureManager.hManager.hConstants.hMap.hEntity.hComponent.hSpriteComponent.hAnimationHandler.hECS.hTransformComponent.hVector2D.hTileComponent.hTextureDict.hColliderComponent.hKeyboardController.hAssetManager.hComponents.hProjectileComponent.hHealthComponent.hGameObject.h \ No newline at end of file diff --git a/docs/diagrams/sequence.svg b/docs/diagrams/sequence.svg new file mode 100644 index 0000000..a396b19 --- /dev/null +++ b/docs/diagrams/sequence.svg @@ -0,0 +1 @@ +MapMapGameGameManagerManagerEntityEntityTileComponentTileComponentgetComponentTypeID<TileComponent>()getComponentTypeID<TileComponent>()getNewComponentTypeID()getNewComponentTypeID()ColliderComponentColliderComponentgetComponentTypeID<ColliderComponent>()getComponentTypeID<ColliderComponent>()loadMap(const char *,int,int)looploopaddTile(int,int,int)addEntity()addComponent(int &,int &,const int &,const int &,int &)TileComponent(int,int,int,int,int)init()altaddComponent(const char (&)[6])ColliderComponent(const char *)init()addGroup(Group) \ No newline at end of file