From d29c2f6a21c2e7a49c362f66274223ef35c6fa2c Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Thu, 18 Jan 2024 10:25:35 +0100 Subject: [PATCH] refactored + code doc --- Source/SURREALISM.Target.cs | 4 +- Source/SURREALISM/Private/Item.cpp | 4 +- Source/SURREALISM/Private/JournalPage.cpp | 4 +- Source/SURREALISM/Private/JournalWidget.cpp | 4 +- Source/SURREALISM/Private/MyActor.cpp | 27 -------- Source/SURREALISM/Private/MyUserWidget.cpp | 5 -- Source/SURREALISM/Private/SURREALISM.cpp | 4 +- Source/SURREALISM/Private/utils_functions.cpp | 4 +- Source/SURREALISM/Public/Item.h | 31 ++++++++- Source/SURREALISM/Public/JournalPage.h | 49 ++++++++++++-- Source/SURREALISM/Public/JournalWidget.h | 66 ++++++++++++++++++- Source/SURREALISM/Public/MyActor.h | 26 -------- Source/SURREALISM/Public/MyUserWidget.h | 17 ----- Source/SURREALISM/Public/SURREALISM.h | 4 +- Source/SURREALISM/Public/utils_functions.h | 4 +- Source/SURREALISM/SURREALISM.Build.cs | 4 +- Source/SURREALISMEditor.Target.cs | 4 +- 17 files changed, 169 insertions(+), 92 deletions(-) delete mode 100644 Source/SURREALISM/Private/MyActor.cpp delete mode 100644 Source/SURREALISM/Private/MyUserWidget.cpp delete mode 100644 Source/SURREALISM/Public/MyActor.h delete mode 100644 Source/SURREALISM/Public/MyUserWidget.h diff --git a/Source/SURREALISM.Target.cs b/Source/SURREALISM.Target.cs index ad6e315..7451345 100644 --- a/Source/SURREALISM.Target.cs +++ b/Source/SURREALISM.Target.cs @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ using UnrealBuildTool; using System.Collections.Generic; diff --git a/Source/SURREALISM/Private/Item.cpp b/Source/SURREALISM/Private/Item.cpp index 4628859..937bc11 100644 --- a/Source/SURREALISM/Private/Item.cpp +++ b/Source/SURREALISM/Private/Item.cpp @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #include "Item.h" diff --git a/Source/SURREALISM/Private/JournalPage.cpp b/Source/SURREALISM/Private/JournalPage.cpp index e27e831..d21716e 100644 --- a/Source/SURREALISM/Private/JournalPage.cpp +++ b/Source/SURREALISM/Private/JournalPage.cpp @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #include "JournalPage.h" diff --git a/Source/SURREALISM/Private/JournalWidget.cpp b/Source/SURREALISM/Private/JournalWidget.cpp index c9223b6..8ea6b62 100644 --- a/Source/SURREALISM/Private/JournalWidget.cpp +++ b/Source/SURREALISM/Private/JournalWidget.cpp @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #include "JournalWidget.h" diff --git a/Source/SURREALISM/Private/MyActor.cpp b/Source/SURREALISM/Private/MyActor.cpp deleted file mode 100644 index d4a22d8..0000000 --- a/Source/SURREALISM/Private/MyActor.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "MyActor.h" - -// Sets default values -AMyActor::AMyActor() -{ - // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. - PrimaryActorTick.bCanEverTick = true; - -} - -// Called when the game starts or when spawned -void AMyActor::BeginPlay() -{ - Super::BeginPlay(); - -} - -// Called every frame -void AMyActor::Tick(float DeltaTime) -{ - Super::Tick(DeltaTime); - -} - diff --git a/Source/SURREALISM/Private/MyUserWidget.cpp b/Source/SURREALISM/Private/MyUserWidget.cpp deleted file mode 100644 index 74371b9..0000000 --- a/Source/SURREALISM/Private/MyUserWidget.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "MyUserWidget.h" - diff --git a/Source/SURREALISM/Private/SURREALISM.cpp b/Source/SURREALISM/Private/SURREALISM.cpp index 94004f1..c03311a 100644 --- a/Source/SURREALISM/Private/SURREALISM.cpp +++ b/Source/SURREALISM/Private/SURREALISM.cpp @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #include "SURREALISM.h" #include "Modules/ModuleManager.h" diff --git a/Source/SURREALISM/Private/utils_functions.cpp b/Source/SURREALISM/Private/utils_functions.cpp index b6e46a9..847cd27 100644 --- a/Source/SURREALISM/Private/utils_functions.cpp +++ b/Source/SURREALISM/Private/utils_functions.cpp @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #include "utils_functions.h" diff --git a/Source/SURREALISM/Public/Item.h b/Source/SURREALISM/Public/Item.h index eb91828..fda386d 100644 --- a/Source/SURREALISM/Public/Item.h +++ b/Source/SURREALISM/Public/Item.h @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #pragma once @@ -6,6 +8,9 @@ #include "GameFramework/Actor.h" #include "Item.generated.h" +/** + * @brief This class is the base class for all items in the game. + */ UCLASS(Blueprintable) class SURREALISM_API AItem : public AActor { @@ -23,24 +28,48 @@ public: // Called every frame virtual void Tick(float DeltaTime) override; + /** + * @brief The name of the item. + */ UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Item") FString item_name = "Item name"; + /** + * @brief The description of the item. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item") FString item_description = "Item description"; + /** + * @brief This function returns the name of the item. + */ UFUNCTION(BlueprintCallable,CallInEditor , Category = "Item") FString get_item_name(); + /** + * @brief This function returns the description of the item. + * @return The description of the item. + */ UFUNCTION(BlueprintCallable,CallInEditor, Category = "Item") FString get_item_description(); + /** + * @brief This function sets the name of the item. + * @param new_name The new name of the item. + */ UFUNCTION(BlueprintCallable,CallInEditor, Category = "Item") void set_item_name(FString new_name); + /** + * @brief This function sets the description of the item. + * @param new_description The new description of the item. + */ UFUNCTION(BlueprintCallable,CallInEditor, Category = "Item") void set_item_description(FString new_description); + /** + * @brief This function sends the item to the journal. + */ UFUNCTION(BlueprintCallable,CallInEditor, Category = "Item") void send_item_to_journal(); diff --git a/Source/SURREALISM/Public/JournalPage.h b/Source/SURREALISM/Public/JournalPage.h index 0b55520..31d0e33 100644 --- a/Source/SURREALISM/Public/JournalPage.h +++ b/Source/SURREALISM/Public/JournalPage.h @@ -1,10 +1,16 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #pragma once #include "CoreMinimal.h" #include "JournalPage.generated.h" + +/** + * @brief This struct represents a journal entry. + */ USTRUCT(BlueprintType) struct FJournalEntry { @@ -16,30 +22,65 @@ struct FJournalEntry }; /** - * + * @brief This class represents a journal page. */ UCLASS() class SURREALISM_API UJournalPage : public UObject { GENERATED_BODY() + public: + UJournalPage(); + /** + * @brief Array containing all the entries of the journal page. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Journal") TArray page_entries; + /** + * @brief The maximum number of entries that the journal page can contain. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Journal") int32 max_page_entries; + /** + * @brief This function adds an entry to the journal page. + * @param entry_name The name of the entry to add. + * @param entry_description The description of the entry to add. + */ void add_entry(FString entry_name, FString entry_description); + + /** + * @brief This function removes an entry from the journal page. + * @param entry_name The name of the entry to remove. + */ void remove_entry(FString entry_name); + /** + * @brief This function returns the name of all the entries of the journal page. + * @return An array containing the names of all the entries of the journal page. + */ TArray get_all_entries_names(); + + /** + * @brief This function returns the description of all the entries of the journal page. + * @return An array containing the descriptions of all the entries of the journal page. + */ TArray get_all_entries_descriptions(); + + /** + * @brief This function returns the number of entries of the journal page. + * @return The number of entries of the journal page. + */ int32 get_number_of_entries(); + /** + * @brief This function returns the description of an entry of the journal page selected by its name. + * @param entry_name The name of the entry to get. + * @return The description of the entry. + */ FString get_entry_description(FString entry_name); - - }; diff --git a/Source/SURREALISM/Public/JournalWidget.h b/Source/SURREALISM/Public/JournalWidget.h index 5c4f81e..edb6836 100644 --- a/Source/SURREALISM/Public/JournalWidget.h +++ b/Source/SURREALISM/Public/JournalWidget.h @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #pragma once @@ -10,6 +12,7 @@ /** * + * @brief This class represents the journal widget. */ UCLASS(Blueprintable) class SURREALISM_API UJournalWidget : public UUserWidget @@ -18,58 +21,117 @@ class SURREALISM_API UJournalWidget : public UUserWidget public: + /** + * @brief Array containing all the journal pages. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Journal") TArray journal_pages; + /** + * @brief The maximum number of pages that the journal can contain. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Journal") int max_pages = 10; + /** + * @brief The current number of pages of the journal. + */ UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Journal") int current_number_of_pages = 0; + /** + * @brief The current page number. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Journal") int current_page_number = 0; + /** + * @brief returns the current number of pages. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") int get_current_number_of_page(); + /** + * @brief This function changes the current page to the next one. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") void next_page(); + /** + * @brief This function changes the current page to the previous one. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") void previous_page(); + /** + * @brief This function changes the current page to the one with the specified number. + * @param page_number The number of the page to go to. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") void go_to_page(int page_number); + /** + * @brief This function removes a page from the journal selected by its number. + * @param page_number The number of the page to remove. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") void remove_page(int page_number); + /** + * @brief This function gets all the item name from the current page. + * @return An array containing all the item names from the current page. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") TArray get_current_page_entries_names(); + /** + * @brief This function gets the description from the item oin the current page selected by its name. + * @return The description of the item. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") FString get_entry_description(FString entry_name); + /** + * @brief This function adds a page to the journal. + * @return The number of the page added. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") int add_page(); + /** + * @brief This function adds an item to the journal. + * @param item_name The name of the item to add. + * @param item_description The description of the item to add. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") void add_to_journal(FString item_name, FString item_description); + /** + * @brief This function resets the journal. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") void clear_journal(); + /** + * @brief This function prints the current page. (ONLY FOR DEBUG) + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") void print_current_page(); + /** + * @brief This function returns the current page number. + * @return The current page number. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") int get_current_pages_number(); + /** + * @brief This function returns the number of entries in the current page. + * @return The number of entries in the current page. + */ UFUNCTION(BlueprintCallable, CallInEditor, Category = "Journal") int get_number_of_entries_in_current_page(); - virtual void NativeConstruct() override; }; diff --git a/Source/SURREALISM/Public/MyActor.h b/Source/SURREALISM/Public/MyActor.h deleted file mode 100644 index 9730bf3..0000000 --- a/Source/SURREALISM/Public/MyActor.h +++ /dev/null @@ -1,26 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/Actor.h" -#include "MyActor.generated.h" - -UCLASS() -class SURREALISM_API AMyActor : public AActor -{ - GENERATED_BODY() - -public: - // Sets default values for this actor's properties - AMyActor(); - -protected: - // Called when the game starts or when spawned - virtual void BeginPlay() override; - -public: - // Called every frame - virtual void Tick(float DeltaTime) override; - -}; diff --git a/Source/SURREALISM/Public/MyUserWidget.h b/Source/SURREALISM/Public/MyUserWidget.h deleted file mode 100644 index 75e5a13..0000000 --- a/Source/SURREALISM/Public/MyUserWidget.h +++ /dev/null @@ -1,17 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Blueprint/UserWidget.h" -#include "MyUserWidget.generated.h" - -/** - * - */ -UCLASS() -class SURREALISM_API UMyUserWidget : public UUserWidget -{ - GENERATED_BODY() - -}; diff --git a/Source/SURREALISM/Public/SURREALISM.h b/Source/SURREALISM/Public/SURREALISM.h index 90aad9e..f6da0f5 100644 --- a/Source/SURREALISM/Public/SURREALISM.h +++ b/Source/SURREALISM/Public/SURREALISM.h @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #pragma once diff --git a/Source/SURREALISM/Public/utils_functions.h b/Source/SURREALISM/Public/utils_functions.h index 8c02fdc..04c8c27 100644 --- a/Source/SURREALISM/Public/utils_functions.h +++ b/Source/SURREALISM/Public/utils_functions.h @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ #pragma once diff --git a/Source/SURREALISM/SURREALISM.Build.cs b/Source/SURREALISM/SURREALISM.Build.cs index f8bf7b5..262282c 100644 --- a/Source/SURREALISM/SURREALISM.Build.cs +++ b/Source/SURREALISM/SURREALISM.Build.cs @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ using UnrealBuildTool; diff --git a/Source/SURREALISMEditor.Target.cs b/Source/SURREALISMEditor.Target.cs index 0f8c3a6..f823082 100644 --- a/Source/SURREALISMEditor.Target.cs +++ b/Source/SURREALISMEditor.Target.cs @@ -1,4 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. +/*! + * @author SIMAILA Djalim + */ using UnrealBuildTool; using System.Collections.Generic;